From 0c8a594d6f123904fd19eb6bb15e6c20ef60971d Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 24 Jun 2021 16:31:00 -0700 Subject: [PATCH] GH-1500: Mark BasicThread::Done to be ignored by ThreadSanitizer There's a known false positive with the atomic variables in this method that triggers a complaint from ThreadSanitizer. Marking it as ignored avoids the warning. --- src/threading/BasicThread.h | 2 +- zeek-config.h.in | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/threading/BasicThread.h b/src/threading/BasicThread.h index e442a9d8f6..ba26190ffb 100644 --- a/src/threading/BasicThread.h +++ b/src/threading/BasicThread.h @@ -191,7 +191,7 @@ protected: void Kill(); /** Called by child thread's launcher when it's done processing. */ - void Done(); + ZEEK_DISABLE_TSAN void Done(); private: // thread entry function. diff --git a/zeek-config.h.in b/zeek-config.h.in index 0786610807..cd81091b76 100644 --- a/zeek-config.h.in +++ b/zeek-config.h.in @@ -272,3 +272,19 @@ extern const char* BRO_VERSION_FUNCTION(); #define ZEEK_LSAN_DISABLE(x) #define ZEEK_LSAN_DISABLE_SCOPE(x) #endif + +#if defined(__SANITIZE_THREAD__) + #define ZEEK_TSAN +#endif + +#if defined(__has_feature) + #if __has_feature(thread_sanitizer) + #define ZEEK_TSAN + #endif +#endif + +#if defined(ZEEK_TSAN) + #define ZEEK_DISABLE_TSAN __attribute__((no_sanitize("thread"))) +#else + #define ZEEK_DISABLE_TSAN +#endif