diff options
| author | Kostya Serebryany <kcc@google.com> | 2014-02-14 12:20:42 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2014-02-14 12:20:42 +0000 |
| commit | a63632a5c6acd6e8865cb0ffc060be1321db7298 (patch) | |
| tree | 69957e8d6f0c9ee22ad72e2284c123d22fbba9b5 /compiler-rt/lib/tsan/lit_tests | |
| parent | 127e93e4dcd06d6b965f66ae8eeab6ddc651b759 (diff) | |
| download | bcm5719-llvm-a63632a5c6acd6e8865cb0ffc060be1321db7298.tar.gz bcm5719-llvm-a63632a5c6acd6e8865cb0ffc060be1321db7298.zip | |
[tsan] rudimentary support for deadlock detector in tsan (nothing really works yet except for a single tiny test). Also rename tsan's DeadlockDetector to InternalDeadlockDetector
llvm-svn: 201407
Diffstat (limited to 'compiler-rt/lib/tsan/lit_tests')
| -rw-r--r-- | compiler-rt/lib/tsan/lit_tests/mutex_cycle2.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/lit_tests/mutex_cycle2.c b/compiler-rt/lib/tsan/lit_tests/mutex_cycle2.c new file mode 100644 index 00000000000..cd1006d4760 --- /dev/null +++ b/compiler-rt/lib/tsan/lit_tests/mutex_cycle2.c @@ -0,0 +1,25 @@ +// RUN: %clangxx_tsan %s -o %t +// RUN: TSAN_OPTIONS=detect_deadlocks=1 %t 2>&1 | FileCheck %s +#include <pthread.h> + +int main() { + pthread_mutex_t mu1, mu2; + pthread_mutex_init(&mu1, NULL); + pthread_mutex_init(&mu2, NULL); + + // mu1 => mu2 + pthread_mutex_lock(&mu1); + pthread_mutex_lock(&mu2); + pthread_mutex_unlock(&mu2); + pthread_mutex_unlock(&mu1); + + // mu2 => mu1 + pthread_mutex_lock(&mu2); + pthread_mutex_lock(&mu1); + // CHECK: ThreadSanitizer: lock-order-inversion (potential deadlock) + pthread_mutex_unlock(&mu1); + pthread_mutex_unlock(&mu2); + + pthread_mutex_destroy(&mu1); + pthread_mutex_destroy(&mu2); +} |

