tsan: handle early signals
The second part of the fix of
https://code.google.com/p/thread-sanitizer/issues/detail?id=71
llvm-svn: 217031
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index 6652edb..1c0f2f8 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -151,7 +151,7 @@
static SignalContext *SigCtx(ThreadState *thr) {
SignalContext *ctx = (SignalContext*)thr->signal_ctx;
- if (ctx == 0 && thr->is_alive) {
+ if (ctx == 0 && !thr->is_dead) {
ctx = (SignalContext*)MmapOrDie(sizeof(*ctx), "SignalContext");
MemoryResetRange(thr, (uptr)&SigCtx, (uptr)ctx, sizeof(*ctx));
thr->signal_ctx = ctx;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 7b0b8e0..1a926c0 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -356,7 +356,7 @@
const int unique_id;
bool in_symbolizer;
bool in_ignored_lib;
- bool is_alive;
+ bool is_dead;
bool is_freeing;
bool is_vptr_access;
const uptr stk_addr;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
index a08c1e0..156f3b8 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
@@ -123,7 +123,6 @@
"tls_addr=%zx tls_size=%zx\n",
tid, (uptr)epoch0, args->stk_addr, args->stk_size,
args->tls_addr, args->tls_size);
- thr->is_alive = true;
}
void ThreadContext::OnFinished() {
@@ -284,7 +283,7 @@
DontNeedShadowFor(thr->stk_addr, thr->stk_size);
if (thr->tls_addr && thr->tls_size)
DontNeedShadowFor(thr->tls_addr, thr->tls_size);
- thr->is_alive = false;
+ thr->is_dead = true;
ctx->thread_registry->FinishThread(thr->tid);
}
diff --git a/compiler-rt/test/tsan/signal_recursive.cc b/compiler-rt/test/tsan/signal_recursive.cc
index d3e9dbb..db1d8b0 100644
--- a/compiler-rt/test/tsan/signal_recursive.cc
+++ b/compiler-rt/test/tsan/signal_recursive.cc
@@ -119,7 +119,6 @@
Init();
pthread_t busy_thread;
pthread_create(&busy_thread, NULL, &BusyThread, NULL);
- sleep(1); // Tsan deadlocks without these sleeps
CollectGarbage(busy_thread);
pthread_join(busy_thread, 0);
fprintf(stderr, "DONE\n");