threads: disable thread attributes when compiled with TSAN

TSAN doesn't work well then threads are created with attributes
thar require root rights but the process is run as normal user.

this patch avoid the thread attributes in this case. TSAN isn't going
to be used for production builds.
master
Andre Puschmann 3 years ago
parent b88f22b9fe
commit 7ee38e6255

@ -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)

@ -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) {

Loading…
Cancel
Save