]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/mutex_double_lock.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / test / tsan / mutex_double_lock.cc
CommitLineData
92a42be0 1// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
1a4d82fc
JJ
2#include <pthread.h>
3#include <unistd.h>
4
5extern "C" void AnnotateRWLockAcquired(const char *f, int l, void *m, long rw);
6
7void *ThreadFunc(void *m) {
8 AnnotateRWLockAcquired(__FILE__, __LINE__, m, 1);
9 return 0;
10}
11
12int main() {
13 int m = 0;
14 AnnotateRWLockAcquired(__FILE__, __LINE__, &m, 1);
15 pthread_t th;
16 pthread_create(&th, 0, ThreadFunc, &m);
17 pthread_join(th, 0);
18 return 0;
19}
20
21// CHECK: WARNING: ThreadSanitizer: double lock of a mutex
22// CHECK: #0 AnnotateRWLockAcquired
23// CHECK: #1 ThreadFunc
24// CHECK: Location is stack of main thread.
25// CHECK: Mutex {{.*}} created at:
26// CHECK: #0 AnnotateRWLockAcquired
27// CHECK: #1 main
28// CHECK: SUMMARY: ThreadSanitizer: double lock of a mutex {{.*}}mutex_double_lock.cc{{.*}}ThreadFunc
29