tsan: fix ignore handling in signal handlers
authorDmitry Vyukov <dvyukov@google.com>
Mon, 4 Apr 2016 10:52:59 +0000 (10:52 +0000)
committerDmitry Vyukov <dvyukov@google.com>
Mon, 4 Apr 2016 10:52:59 +0000 (10:52 +0000)
We've reset thr->ignore_reads_and_writes, but forget to do
thr->fast_state.ClearIgnoreBit(). So ignores were not effective
reset and fast_state.ignore_bit was corrupted if signal handler
itself uses ignores.

Properly reset/restore fast_state.ignore_bit around signal handlers.

llvm-svn: 265288

compiler-rt/lib/tsan/rtl/tsan_interceptors.cc

index 2b84632..6bddc3f 100644 (file)
@@ -1887,6 +1887,7 @@ static void CallUserSignalHandler(ThreadState *thr, bool sync, bool acquire,
   int ignore_sync = thr->ignore_sync;
   if (!ctx->after_multithreaded_fork) {
     thr->ignore_reads_and_writes = 0;
+    thr->fast_state.ClearIgnoreBit();
     thr->ignore_interceptors = 0;
     thr->ignore_sync = 0;
   }
@@ -1907,6 +1908,8 @@ static void CallUserSignalHandler(ThreadState *thr, bool sync, bool acquire,
   }
   if (!ctx->after_multithreaded_fork) {
     thr->ignore_reads_and_writes = ignore_reads_and_writes;
+    if (ignore_reads_and_writes)
+      thr->fast_state.SetIgnoreBit();
     thr->ignore_interceptors = ignore_interceptors;
     thr->ignore_sync = ignore_sync;
   }