1 // RUN: %clangxx_tsan %s -o %t
2 // RUN: TSAN_OPTIONS=detect_deadlocks=1 not %run %t 2>&1 | FileCheck %s
3 // RUN: echo "deadlock:main" > sup
4 // RUN: TSAN_OPTIONS="detect_deadlocks=1 suppressions=sup" %run %t
5 // RUN: echo "deadlock:zzzz" > sup
6 // RUN: TSAN_OPTIONS="detect_deadlocks=1 suppressions=sup" not %run %t 2>&1 | FileCheck %s
10 pthread_mutex_t mu1
, mu2
;
11 pthread_mutex_init(&mu1
, NULL
);
12 pthread_mutex_init(&mu2
, NULL
);
15 pthread_mutex_lock(&mu1
);
16 pthread_mutex_lock(&mu2
);
17 pthread_mutex_unlock(&mu2
);
18 pthread_mutex_unlock(&mu1
);
21 pthread_mutex_lock(&mu2
);
22 pthread_mutex_lock(&mu1
);
23 // CHECK: ThreadSanitizer: lock-order-inversion (potential deadlock)
24 pthread_mutex_unlock(&mu1
);
25 pthread_mutex_unlock(&mu2
);
27 pthread_mutex_destroy(&mu1
);
28 pthread_mutex_destroy(&mu2
);