[compiler-rt] r246592 - [tsan] workaround for a crash in deadlock detector, bug https://github.com/google/sanitizers/issues/594

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 14:36:18 PDT 2015


Author: kcc
Date: Tue Sep  1 16:36:18 2015
New Revision: 246592

URL: http://llvm.org/viewvc/llvm-project?rev=246592&view=rev
Log:
[tsan] workaround for a crash in deadlock detector, bug https://github.com/google/sanitizers/issues/594

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
    compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc?rev=246592&r1=246591&r2=246592&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc Tue Sep  1 16:36:18 2015
@@ -472,7 +472,7 @@ void ReportDeadlock(ThreadState *thr, up
   for (int i = 0; i < r->n; i++) {
     for (int j = 0; j < (flags()->second_deadlock_stack ? 2 : 1); j++) {
       u32 stk = r->loop[i].stk[j];
-      if (stk) {
+      if (stk && stk != 0xffffffff) {
         rep.AddStack(StackDepotGet(stk), true);
       } else {
         // Sometimes we fail to extract the stack trace (FIXME: investigate),

Modified: compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc?rev=246592&r1=246591&r2=246592&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc (original)
+++ compiler-rt/trunk/test/tsan/deadlock_detector_stress_test.cc Tue Sep  1 16:36:18 2015
@@ -498,6 +498,19 @@ class LockTest {
     delete [] l;
   }
 
+  void Test19() {
+    if (test_number > 0 && test_number != 19) return;
+    fprintf(stderr, "Starting Test19: lots of lock inversions\n");
+    const int kNumLocks = 45;
+    Init(kNumLocks);
+    for (int i = 0; i < kNumLocks; i++) {
+      for (int j = 0; j < kNumLocks; j++)
+        L((i + j) % kNumLocks);
+      for (int j = 0; j < kNumLocks; j++)
+        U((i + j) % kNumLocks);
+    }
+  }
+
  private:
   void Lock2(size_t l1, size_t l2) { L(l1); L(l2); U(l2); U(l1); }
 
@@ -602,6 +615,7 @@ int main(int argc, char **argv) {
   LockTest().Test16();
   LockTest().Test17();
   LockTest().Test18();
+  LockTest().Test19();
   fprintf(stderr, "ALL-DONE\n");
   // CHECK: ALL-DONE
 }




More information about the llvm-commits mailing list