1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
2 | #include "test.h" |
3 | |
4 | void *ThreadFunc(void *m) { |
5 | AnnotateRWLockAcquired(__FILE__, __LINE__, m, is_w: 1); |
6 | return 0; |
7 | } |
8 | |
9 | int main() { |
10 | int m = 0; |
11 | AnnotateRWLockAcquired(__FILE__, __LINE__, m: &m, is_w: 1); |
12 | pthread_t th; |
13 | pthread_create(newthread: &th, attr: 0, start_routine: ThreadFunc, arg: &m); |
14 | pthread_join(th: th, thread_return: 0); |
15 | return 0; |
16 | } |
17 | |
18 | // CHECK: WARNING: ThreadSanitizer: double lock of a mutex |
19 | // CHECK: #0 AnnotateRWLockAcquired |
20 | // CHECK: #1 ThreadFunc |
21 | // CHECK: Location is stack of main thread. |
22 | // CHECK: Mutex {{.*}} created at: |
23 | // CHECK: #0 AnnotateRWLockAcquired |
24 | // CHECK: #1 main |
25 | // CHECK: SUMMARY: ThreadSanitizer: double lock of a mutex {{.*}}mutex_double_lock.cpp{{.*}}ThreadFunc |
26 | |
27 | |