[compiler-rt] r243151 - __tsan::ThreadCreate takes incorrect value for detached argument
Ismail Pazarbasi
ismail.pazarbasi at gmail.com
Fri Jul 24 13:00:49 PDT 2015
Author: ismailp
Date: Fri Jul 24 15:00:49 2015
New Revision: 243151
URL: http://llvm.org/viewvc/llvm-project?rev=243151&view=rev
Log:
__tsan::ThreadCreate takes incorrect value for detached argument
Summary:
PTHREAD_CREATE_DETACHED has a different value on Mac OS X. Since both
PTHREAD_CREATE_JOINABLE and PTHREAD_CREATE_DETACHED are non-zero,
`__tsan::ThreadCreate` always creates detached threads.
Reviewers: kcc, samsonov, glider
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D10606
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=243151&r1=243150&r2=243151&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Fri Jul 24 15:00:49 2015
@@ -38,6 +38,13 @@ using namespace __tsan; // NOLINT
#define stderr __stderrp
#endif
+#if SANITIZER_LINUX || SANITIZER_FREEBSD
+#define PTHREAD_CREATE_DETACHED 1
+#elif SANITIZER_MAC
+#define PTHREAD_CREATE_DETACHED 2
+#endif
+
+
#ifdef __mips__
const int kSigCount = 129;
#else
@@ -880,7 +887,8 @@ TSAN_INTERCEPTOR(int, pthread_create,
ThreadIgnoreEnd(thr, pc);
}
if (res == 0) {
- int tid = ThreadCreate(thr, pc, *(uptr*)th, detached);
+ int tid = ThreadCreate(thr, pc, *(uptr*)th,
+ detached == PTHREAD_CREATE_DETACHED);
CHECK_NE(tid, 0);
// Synchronization on p.tid serves two purposes:
// 1. ThreadCreate must finish before the new thread starts.
More information about the llvm-commits
mailing list