summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/sanitizer_common/sanitizer_deadlock_detector.h5
-rw-r--r--test/tsan/real_deadlock_detector_stress_test.cc33
2 files changed, 6 insertions, 32 deletions
diff --git a/lib/sanitizer_common/sanitizer_deadlock_detector.h b/lib/sanitizer_common/sanitizer_deadlock_detector.h
index 90e1cc4eb..c3ca210a1 100644
--- a/lib/sanitizer_common/sanitizer_deadlock_detector.h
+++ b/lib/sanitizer_common/sanitizer_deadlock_detector.h
@@ -50,6 +50,8 @@ class DeadlockDetectorTLS {
if (epoch_ == current_epoch) return;
bv_.clear();
epoch_ = current_epoch;
+ n_recursive_locks = 0;
+ n_all_locks_ = 0;
}
uptr getEpoch() const { return epoch_; }
@@ -83,7 +85,8 @@ class DeadlockDetectorTLS {
}
}
// Printf("remLock: %zx %zx\n", lock_id, epoch_);
- CHECK(bv_.clearBit(lock_id));
+ if (!bv_.clearBit(lock_id))
+ return; // probably addLock happened before flush
if (n_all_locks_) {
for (sptr i = n_all_locks_ - 1; i >= 0; i--) {
if (all_locks_with_contexts_[i].lock == static_cast<u32>(lock_id)) {
diff --git a/test/tsan/real_deadlock_detector_stress_test.cc b/test/tsan/real_deadlock_detector_stress_test.cc
index da72042ee..67c878f45 100644
--- a/test/tsan/real_deadlock_detector_stress_test.cc
+++ b/test/tsan/real_deadlock_detector_stress_test.cc
@@ -1,31 +1,4 @@
-// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
-
-#if 1
-
-#include <stdio.h>
-
-int main() {
- // Currently fails with:
- // CHECK failed: bv_.clearBit(lock_id)
-
- /*
- And in cmake build it also fails with:
- In function `__clang_call_terminate':
- real_deadlock_detector_stress_test.cc:(.text.__clang_call_terminate
- [__clang_call_terminate]+0x12): undefined reference to `__cxa_begin_catch'
- real_deadlock_detector_stress_test.cc:(.text.__clang_call_terminate
- [__clang_call_terminate]+0x17): undefined reference to `std::terminate()'
- In function `std::vector<int, std::allocator<int> >::_M_check_len
- (unsigned long, char const*) const':
- stl_vector.h:1339: undefined reference to `std::__throw_length_error
- (char const*)'
- */
-
- fprintf(stderr, "DONE\n");
- return 0;
-}
-
-#else
+// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
#include <pthread.h>
#include <stdlib.h>
@@ -38,7 +11,7 @@ int main() {
const int kThreads = 4;
const int kMutexes = 16 << 10;
-const int kIters = 1 << 20;
+const int kIters = 400 << 10;
const int kMaxPerThread = 10;
const int kStateInited = 0;
@@ -211,5 +184,3 @@ int main() {
// CHECK-NOT: WARNING: ThreadSanitizer
// CHECK: DONE
-#endif
-