1 // RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s 2 #include <pthread.h> 3 #include <stdio.h> 4 #include <stddef.h> 5 #include <unistd.h> 6 7 void *Thread(void *x) { 8 pthread_mutex_lock((pthread_mutex_t*)x); 9 pthread_mutex_unlock((pthread_mutex_t*)x); 10 return 0; 11 } 12 13 int main() { 14 pthread_mutex_t Mtx; 15 pthread_mutex_init(&Mtx, 0); 16 pthread_t t; 17 pthread_create(&t, 0, Thread, &Mtx); 18 sleep(1); 19 pthread_mutex_destroy(&Mtx); 20 pthread_join(t, 0); 21 return 0; 22 } 23 24 // CHECK: WARNING: ThreadSanitizer: data race 25