1 // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK 2 #include "test.h" 3 Thread2(void * a)4void *Thread2(void *a) { 5 barrier_wait(&barrier); 6 *(int*)a = 43; 7 return 0; 8 } 9 Thread(void * a)10void *Thread(void *a) { 11 static __thread int Var = 42; 12 pthread_t t; 13 pthread_create(&t, 0, Thread2, &Var); 14 Var = 42; 15 barrier_wait(&barrier); 16 pthread_join(t, 0); 17 return 0; 18 } 19 main()20int main() { 21 barrier_init(&barrier, 2); 22 pthread_t t; 23 pthread_create(&t, 0, Thread, 0); 24 pthread_join(t, 0); 25 } 26 27 // CHECK: WARNING: ThreadSanitizer: data race 28 // CHECK-Linux: Location is TLS of thread T1. 29 // CHECK-FreeBSD: Location is TLS of thread T1. 30 // CHECK-Darwin: Location is heap block of size 4 31