From a8def72dd6bb8213dc8cca41f81e5610dabce4f0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 18 Dec 2014 14:02:28 +0000 Subject: [PATCH] tsan: fix failing CHECK In deadlock detector and re-enable the test llvm-svn: 224518 --- .../sanitizer_common/sanitizer_deadlock_detector.h | 5 +++- .../tsan/real_deadlock_detector_stress_test.cc | 33 ++-------------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector.h b/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector.h index 90e1cc4..c3ca210 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector.h +++ b/compiler-rt/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(lock_id)) { diff --git a/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc b/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc index da72042..67c878f 100644 --- a/compiler-rt/test/tsan/real_deadlock_detector_stress_test.cc +++ b/compiler-rt/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 - -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 >::_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 #include @@ -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 - -- 2.7.4