[compiler-rt] r217031 - tsan: handle early signals

Dmitry Vyukov dvyukov at google.com
Wed Sep 3 05:25:23 PDT 2014


Author: dvyukov
Date: Wed Sep  3 07:25:22 2014
New Revision: 217031

URL: http://llvm.org/viewvc/llvm-project?rev=217031&view=rev
Log:
tsan: handle early signals
The second part of the fix of
https://code.google.com/p/thread-sanitizer/issues/detail?id=71


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
    compiler-rt/trunk/test/tsan/signal_recursive.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=217031&r1=217030&r2=217031&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Wed Sep  3 07:25:22 2014
@@ -151,7 +151,7 @@ void InitializeLibIgnore() {
 
 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;

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=217031&r1=217030&r2=217031&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Wed Sep  3 07:25:22 2014
@@ -356,7 +356,7 @@ struct ThreadState {
   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;

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=217031&r1=217030&r2=217031&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Wed Sep  3 07:25:22 2014
@@ -123,7 +123,6 @@ void ThreadContext::OnStarted(void *arg)
           "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 @@ void ThreadFinish(ThreadState *thr) {
     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);
 }
 

Modified: compiler-rt/trunk/test/tsan/signal_recursive.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/signal_recursive.cc?rev=217031&r1=217030&r2=217031&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/signal_recursive.cc (original)
+++ compiler-rt/trunk/test/tsan/signal_recursive.cc Wed Sep  3 07:25:22 2014
@@ -119,7 +119,6 @@ int main(int argc, const char *argv[]) {
   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");





More information about the llvm-commits mailing list