1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include <pthread.h>
3 #include <unistd.h>
4
5 extern "C" void AnnotateRWLockAcquired(const char *f, int l, void *m, long rw);
6
ThreadFunc(void * m)7 void *ThreadFunc(void *m) {
8 AnnotateRWLockAcquired(__FILE__, __LINE__, m, 1);
9 return 0;
10 }
11
main()12 int 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.cpp{{.*}}ThreadFunc
29
30