diff --git a/CMakeLists.txt b/CMakeLists.txt index 33418cf05b..908c15a057 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,10 @@ if ( ZEEK_SANITIZERS ) set(ZEEK_SANITIZERS "${ZEEK_SANITIZERS},") endif () + if ( _sanitizer STREQUAL "thread" ) + set(ZEEK_TSAN true) + endif () + if ( NOT _sanitizer STREQUAL "undefined" ) set(ZEEK_SANITIZERS "${ZEEK_SANITIZERS}${_sanitizer}") continue() diff --git a/testing/btest/scripts/base/frameworks/logging/sqlite/simultaneous-writes.zeek b/testing/btest/scripts/base/frameworks/logging/sqlite/simultaneous-writes.zeek index fcdbd928ee..67de58471f 100644 --- a/testing/btest/scripts/base/frameworks/logging/sqlite/simultaneous-writes.zeek +++ b/testing/btest/scripts/base/frameworks/logging/sqlite/simultaneous-writes.zeek @@ -2,6 +2,10 @@ # # @TEST-REQUIRES: which sqlite3 # @TEST-REQUIRES: has-writer Zeek::SQLiteWriter + +# Don't run this test if we build with '--sanitizers=thread' because we +# disable the shared cache in that case due to a SQLite bug. +# @TEST-REQUIRES: grep -q "#define ZEEK_TSAN" zeek-config.h || test $? == 0 # @TEST-GROUP: sqlite # # @TEST-EXEC: zeek -b %INPUT @@ -87,4 +91,3 @@ event zeek_init() Log::write(SSH::LOG, out); Log::write(SSH::LOG2, out); } - diff --git a/zeek-config.h.in b/zeek-config.h.in index 90570a81d8..3c90bd5ceb 100644 --- a/zeek-config.h.in +++ b/zeek-config.h.in @@ -276,13 +276,17 @@ extern const char* BRO_VERSION_FUNCTION(); #define ZEEK_LSAN_DISABLE_SCOPE(x) #endif +// This part is dependent on calling configure with '--sanitizers=thread' +// and not manually setting CFLAGS/CXXFLAGS to include --fsanitize=thread. +// This is because some of the unit tests only work when built without +// TSan, at least until SQLite opts to fix their problems with atomics. #if defined(__SANITIZE_THREAD__) - #define ZEEK_TSAN + #cmakedefine ZEEK_TSAN #endif #if defined(__has_feature) #if __has_feature(thread_sanitizer) - #define ZEEK_TSAN + #cmakedefine ZEEK_TSAN #endif #endif