From d0f2a0ac4d1598e65a69ec9066c010f6767830a5 Mon Sep 17 00:00:00 2001 From: Nick Gregory Date: Wed, 26 Apr 2023 17:30:06 +0200 Subject: [PATCH] One more TSAN fix (#1079) --- .github/workflows/sanitizers.yml | 2 +- .../santad/EventProviders/SNTEndpointSecurityClientTest.mm | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index d1278d9d3..c0fb9aa81 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -18,7 +18,7 @@ jobs: DYLIB_PATH="$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/${CLANG_VERSION}/lib/darwin/libclang_rt.${{ matrix.sanitizer }}_osx_dynamic.dylib" bazel test --config=${{ matrix.sanitizer }} \ - --test_strategy=exclusive --test_output=errors \ + --test_strategy=exclusive --test_output=all \ --test_env=DYLD_INSERT_LIBRARIES=${DYLIB_PATH} \ --runs_per_test 5 -t- :unit_tests \ --define=SANTA_BUILD_TYPE=adhoc diff --git a/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm b/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm index 852a0021e..755a45218 100644 --- a/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm +++ b/Source/santad/EventProviders/SNTEndpointSecurityClientTest.mm @@ -414,6 +414,13 @@ - (void)testProcessEnrichedMessageHandler { [client processEnrichedMessage:enrichedMsg handler:^(std::shared_ptr msg) { + // reset the shared_ptr to drop the held message. + // This is a workaround for a TSAN only false positive + // which happens if we switch back to the sem wait + // after signaling, but _before_ the implicit release + // of msg. In that case, the mock verify and the + // call of the mock's Release method can data race. + msg.reset(); dispatch_semaphore_signal(sema); }];