Skip to content

Commit

Permalink
ci: enable MSAN except extensions (envoyproxy#21348)
Browse files Browse the repository at this point in the history
Signed-off-by: Lizan Zhou <[email protected]>
  • Loading branch information
lizan authored May 19, 2022
1 parent 4c866ac commit 0d08d60
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .azure-pipelines/pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ stages:
CI_TARGET: "bazel.clang_tidy"
asan:
CI_TARGET: "bazel.asan"
msan:
CI_TARGET: "bazel.msan"
tsan:
CI_TARGET: "bazel.tsan"
compile_time_options:
Expand Down
4 changes: 3 additions & 1 deletion ci/do_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ else
if [[ "$CI_TARGET" == "bazel.release" ]]; then
# We test contrib on release only.
COVERAGE_TEST_TARGETS=("${COVERAGE_TEST_TARGETS[@]}" "//contrib/...")
elif [[ "${CI_TARGET}" == "bazel.msan" ]]; then
COVERAGE_TEST_TARGETS=("${COVERAGE_TEST_TARGETS[@]}" "-//test/extensions/...")
fi
TEST_TARGETS=("${COVERAGE_TEST_TARGETS[@]}" "@com_github_google_quiche//:ci_tests")
fi
Expand Down Expand Up @@ -338,7 +340,7 @@ elif [[ "$CI_TARGET" == "bazel.msan" ]]; then
BAZEL_BUILD_OPTIONS=("--config=rbe-toolchain-msan" "${BAZEL_BUILD_OPTIONS[@]}" "-c" "dbg" "--build_tests_only")
echo "bazel MSAN debug build with tests"
echo "Building and testing envoy tests ${TEST_TARGETS[*]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" "${TEST_TARGETS[@]}"
bazel_with_collection test "${BAZEL_BUILD_OPTIONS[@]}" -- "${TEST_TARGETS[@]}"
exit 0
elif [[ "$CI_TARGET" == "bazel.dev" ]]; then
setup_clang_toolchain
Expand Down
2 changes: 1 addition & 1 deletion source/common/io/io_uring_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class IoUringImpl : public IoUring, public ThreadLocal::ThreadLocalObject {

private:
const uint32_t io_uring_size_;
struct io_uring ring_;
struct io_uring ring_ {};
std::vector<struct io_uring_cqe*> cqes_;
os_fd_t event_fd_{INVALID_SOCKET};
};
Expand Down
6 changes: 4 additions & 2 deletions source/common/network/io_socket_handle_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ absl::optional<int> IoSocketHandleImpl::domain() { return domain_; }
Address::InstanceConstSharedPtr IoSocketHandleImpl::localAddress() {
sockaddr_storage ss;
socklen_t ss_len = sizeof(ss);
memset(&ss, 0, ss_len);
auto& os_sys_calls = Api::OsSysCallsSingleton::get();
Api::SysCallIntResult result =
os_sys_calls.getsockname(fd_, reinterpret_cast<sockaddr*>(&ss), &ss_len);
Expand All @@ -517,7 +518,8 @@ Address::InstanceConstSharedPtr IoSocketHandleImpl::localAddress() {

Address::InstanceConstSharedPtr IoSocketHandleImpl::peerAddress() {
sockaddr_storage ss;
socklen_t ss_len = sizeof ss;
socklen_t ss_len = sizeof(ss);
memset(&ss, 0, ss_len);
auto& os_sys_calls = Api::OsSysCallsSingleton::get();
Api::SysCallIntResult result =
os_sys_calls.getpeername(fd_, reinterpret_cast<sockaddr*>(&ss), &ss_len);
Expand All @@ -530,7 +532,7 @@ Address::InstanceConstSharedPtr IoSocketHandleImpl::peerAddress() {
// For Unix domain sockets, can't find out the peer name, but it should match our own
// name for the socket (i.e. the path should match, barring any namespace or other
// mechanisms to hide things, of which there are many).
ss_len = sizeof ss;
ss_len = sizeof(ss);
result = os_sys_calls.getsockname(fd_, reinterpret_cast<sockaddr*>(&ss), &ss_len);
if (result.return_value_ != 0) {
throw EnvoyException(
Expand Down
2 changes: 1 addition & 1 deletion test/common/buffer/watermark_buffer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ TEST_F(WatermarkBufferTest, OverflowWatermarkDisabled) {
TEST_F(WatermarkBufferTest, OverflowWatermarkDisabledOnVeryHighValue) {
// Disabling execution with TSAN as it causes the test to use too much memory
// and time, making the test fail in some settings (such as CI)
#if defined(__has_feature) && __has_feature(thread_sanitizer)
#if defined(__has_feature) && (__has_feature(thread_sanitizer) || __has_feature(memory_sanitizer))
ENVOY_LOG_MISC(critical, "WatermarkBufferTest::OverflowWatermarkDisabledOnVeryHighValue not "
"supported by this compiler configuration");
#else
Expand Down
6 changes: 5 additions & 1 deletion test/common/signal/signals_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ namespace Envoy {
#if __has_feature(address_sanitizer)
#define ASANITIZED /* Sanitized by Clang */
#endif

#if __has_feature(memory_sanitizer)
#define MSANITIZED /* Sanitized by Clang */
#endif
#endif

#if defined(__SANITIZE_ADDRESS__)
Expand Down Expand Up @@ -71,7 +75,7 @@ class SegfaultFatalAction : public Server::Configuration::FatalAction {
// The sanitizer does its own special signal handling and prints messages that are
// not ours instead of what this test expects. As of latest Clang this appears
// to include abort() as well.
#ifndef ASANITIZED
#if !defined(ASANITIZED) && !defined(MSANITIZED)
TEST(SignalsDeathTest, InvalidAddressDeathTest) {
SignalAction actions;
EXPECT_DEATH(
Expand Down
2 changes: 1 addition & 1 deletion test/mocks/router/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class MockPathMatchCriterion : public PathMatchCriterion {
MOCK_METHOD(PathMatchType, matchType, (), (const));
MOCK_METHOD(const std::string&, matcher, (), (const));

PathMatchType type_;
PathMatchType type_{};
std::string matcher_;
};

Expand Down

0 comments on commit 0d08d60

Please sign in to comment.