1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
2 | #include <pthread.h> |
3 | #include <unistd.h> |
4 | |
5 | void *thread(void *arg) { |
6 | pthread_mutex_t m; |
7 | pthread_mutex_init(mutex: &m, mutexattr: 0); |
8 | pthread_mutex_lock(mutex: &m); |
9 | pthread_mutex_destroy(mutex: &m); |
10 | return 0; |
11 | } |
12 | |
13 | int main() { |
14 | pthread_t th; |
15 | pthread_create(newthread: &th, attr: 0, start_routine: thread, arg: 0); |
16 | pthread_join(th: th, thread_return: 0); |
17 | return 0; |
18 | } |
19 | |
20 | // CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex |
21 | // CHECK: #0 pthread_mutex_destroy |
22 | // CHECK: #1 thread |
23 | // CHECK: and: |
24 | // CHECK: #0 pthread_mutex_lock |
25 | // CHECK: #1 thread |
26 | // CHECK: Mutex {{.*}} created at: |
27 | // CHECK: #0 pthread_mutex_init |
28 | // CHECK: #1 thread |
29 | // CHECK: SUMMARY: ThreadSanitizer: destroy of a locked mutex {{.*}} in thread |
30 | |