1 // RUN: %clangxx_tsan -O1 --std=c++11 %s -o %t
2 // RUN: %env_tsan_opts=report_destroy_locked=0 %run %t 2>&1 | FileCheck %s
3 #include "custom_mutex.h"
5 // Regression test for a bug.
6 // Thr1 destroys a locked mutex, previously such mutex was not removed from
7 // sync map and as the result subsequent uses of a mutex located at the same
8 // address caused false race reports.
10 Mutex
mu(false, __tsan_mutex_write_reentrant
);
13 void *thr1(void *arg
) {
16 new(&mu
) Mutex(true, __tsan_mutex_write_reentrant
);
20 void *thr2(void *arg
) {
21 barrier_wait(&barrier
);
29 barrier_init(&barrier
, 2);
31 pthread_create(&th
, 0, thr1
, 0);
34 barrier_init(&barrier
, 2);
35 pthread_create(&th
, 0, thr2
, 0);
39 barrier_wait(&barrier
);
41 fprintf(stderr
, "DONE\n");
45 // CHECK-NOT: WARNING: ThreadSanitizer: data race