1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 // CHECK-NOT: unlock of unlocked mutex
3 // CHECK: ThreadSanitizer: data race
4 // CHECK: pthread_cond_signal
16 pthread_mutex_lock(&c
->m
);
18 pthread_mutex_unlock(&c
->m
);
19 pthread_cond_signal(&c
->c
);
20 barrier_wait(&barrier
);
25 barrier_init(&barrier
, 2);
27 pthread_mutex_init(&c
->m
, 0);
28 pthread_cond_init(&c
->c
, 0);
30 pthread_create(&th
, 0, thr
, c
);
31 pthread_mutex_lock(&c
->m
);
33 pthread_cond_wait(&c
->c
, &c
->m
);
34 pthread_mutex_unlock(&c
->m
);
35 // otherwise it can be reported as use-after-free
36 barrier_wait(&barrier
);