diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b9e86333..a5682e077 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -486,7 +486,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang") endif (ENABLE_ASAN) if (ENABLE_TSAN) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -DHAVE_TSAN") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread") endif (ENABLE_TSAN) diff --git a/lib/src/common/threads.c b/lib/src/common/threads.c index a53aebfa8..bad3d05d7 100644 --- a/lib/src/common/threads.c +++ b/lib/src/common/threads.c @@ -136,6 +136,11 @@ bool threads_new_rt_cpu(pthread_t* thread, void* (*start_routine)(void*), void* } } +// TSAN seems to have issues with thread attributes when running as normal user, disable them in that case +#if HAVE_TSAN + attr_enable = false; +#endif + int err = pthread_create(thread, attr_enable ? &attr : NULL, start_routine, arg); if (err) { if (EPERM == err) {