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

llvm-svn: 246592
This commit is contained in:
Kostya Serebryany 2015-09-01 21:36:18 +00:00
parent b8ed364d8a
commit 94dd76aefa
2 changed files with 15 additions and 1 deletions

View File

@ -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),

View File

@ -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
}