1 // RUN: %clangxx_tsan %darwin_min_target_with_tls_support -O1 %s -o %t && \
2 // RUN: %deflake %run %t | FileCheck %s
6 __thread
int huge
[1024*1024];
8 void *Thread1(void *x
) {
9 barrier_wait(&barrier
);
14 void *Thread2(void *x
) {
15 pthread_mutex_t
*mtx
= new pthread_mutex_t
;
16 pthread_mutex_init(mtx
, 0);
17 pthread_mutex_lock(mtx
);
19 pthread_mutex_unlock(mtx
);
20 pthread_mutex_destroy(mtx
);
22 barrier_wait(&barrier
);
27 barrier_init(&barrier
, 2);
29 pthread_create(&t
[0], NULL
, Thread1
, NULL
);
30 pthread_create(&t
[1], NULL
, Thread2
, NULL
);
31 pthread_join(t
[0], NULL
);
32 pthread_join(t
[1], NULL
);
35 // CHECK: WARNING: ThreadSanitizer: data race
36 // CHECK: Write of size 4 at {{.*}} by thread T1:
37 // CHECK: Previous write of size 4 at {{.*}} by thread T2
38 // CHECK: (mutexes: write [[M1:M[0-9]+]]):
39 // CHECK: Mutex [[M1]] (0x{{.*}}) created at:
40 // CHECK: #0 pthread_mutex_init