[Tsan] Make calloc() to not track allocated space unless thread is completely initialized

Differential Revision: http://reviews.llvm.org/D5992

llvm-svn: 220673
This commit is contained in:
Viktor Kutuzov 2014-10-27 11:19:08 +00:00
parent a58fed9ab7
commit 9deb007191
1 changed files with 2 additions and 0 deletions

View File

@ -872,11 +872,13 @@ extern "C" void *__tsan_thread_start_func(void *arg) {
ThreadState *thr = cur_thread();
// Thread-local state is not initialized yet.
ScopedIgnoreInterceptors ignore;
ThreadIgnoreBegin(thr, 0);
if (pthread_setspecific(g_thread_finalize_key,
(void *)kPthreadDestructorIterations)) {
Printf("ThreadSanitizer: failed to set thread key\n");
Die();
}
ThreadIgnoreEnd(thr, 0);
while ((tid = atomic_load(&p->tid, memory_order_acquire)) == 0)
pthread_yield();
atomic_store(&p->tid, 0, memory_order_release);