[compiler-rt] r224518 - tsan: fix failing CHECK In deadlock detector
Dmitry Vyukov
dvyukov at google.com
Thu Dec 18 06:02:28 PST 2014
Author: dvyukov
Date: Thu Dec 18 08:02:28 2014
New Revision: 224518
URL: http://llvm.org/viewvc/llvm-project?rev=224518&view=rev
Log:
tsan: fix failing CHECK In deadlock detector
and re-enable the test
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector.h
compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector.h?rev=224518&r1=224517&r2=224518&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_deadlock_detector.h Thu Dec 18 08:02:28 2014
@@ -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)) {
Modified: compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc?rev=224518&r1=224517&r2=224518&view=diff
==============================================================================
--- compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc (original)
+++ compiler-rt/trunk/test/tsan/real_deadlock_detector_stress_test.cc Thu Dec 18 08:02:28 2014
@@ -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
-
More information about the llvm-commits
mailing list