__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

llvm-svn: 243151
This commit is contained in:
Ismail Pazarbasi 2015-07-24 20:00:49 +00:00
parent dbfc010691
commit 0193c3a40e
1 changed files with 9 additions and 1 deletions

View File

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