Index: lib/tsan/tests/rtl/tsan_test_util_posix.cc =================================================================== --- lib/tsan/tests/rtl/tsan_test_util_posix.cc +++ lib/tsan/tests/rtl/tsan_test_util_posix.cc @@ -38,6 +38,7 @@ #define __interceptor_memset wrap_memset #define __interceptor_pthread_create wrap_pthread_create #define __interceptor_pthread_join wrap_pthread_join +#define __interceptor_pthread_detach wrap_pthread_detach #endif extern "C" void *__interceptor_memcpy(void *, const void *, uptr); @@ -47,6 +48,7 @@ void *(*start_routine)(void *), void *arg); extern "C" int __interceptor_pthread_join(pthread_t thread, void **value_ptr); +extern "C" int __interceptor_pthread_detach(pthread_t thread); static void *BeforeInitThread(void *param) { (void)param; @@ -381,7 +383,8 @@ if (!main) { pthread_attr_t attr; pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, detached); + pthread_attr_setdetachstate( + &attr, detached ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE); pthread_attr_setstacksize(&attr, 64*1024); __interceptor_pthread_create(&impl_->thread, &attr, ScopedThread::Impl::ScopedThreadCallback, impl_); @@ -402,7 +405,7 @@ CHECK(!impl_->main); CHECK(!impl_->detached); impl_->detached = true; - pthread_detach(impl_->thread); + __interceptor_pthread_detach(impl_->thread); } void ScopedThread::Access(void *addr, bool is_write,