summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2015-09-01 21:36:18 +0000
committerKostya Serebryany <kcc@google.com>2015-09-01 21:36:18 +0000
commit129c40172fe58d43a152bcc51f19ed283879539b (patch)
treec2b9e2c7db82c9674c278fb4c7c4dc3a637cc803
parenta676372691b9f52da785be29c9d5323d39559abe (diff)
[tsan] workaround for a crash in deadlock detector, bug https://github.com/google/sanitizers/issues/594
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@246592 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/tsan/rtl/tsan_rtl_mutex.cc2
-rw-r--r--test/tsan/deadlock_detector_stress_test.cc14
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_mutex.cc b/lib/tsan/rtl/tsan_rtl_mutex.cc
index 09180d88a..62ab7aa6b 100644
--- a/lib/tsan/rtl/tsan_rtl_mutex.cc
+++ b/lib/tsan/rtl/tsan_rtl_mutex.cc
@@ -472,7 +472,7 @@ void ReportDeadlock(ThreadState *thr, uptr pc, DDReport *r) {
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),
diff --git a/test/tsan/deadlock_detector_stress_test.cc b/test/tsan/deadlock_detector_stress_test.cc
index c77ffe555..efc13ae26 100644
--- a/test/tsan/deadlock_detector_stress_test.cc
+++ b/test/tsan/deadlock_detector_stress_test.cc
@@ -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
}