1 #include <pthread.h> 2 #include <unistd.h> 3 4 void *Thread(void *p) { 5 pthread_mutex_lock((pthread_mutex_t*)p); 6 return 0; 7 } 8 9 int main() { 10 pthread_mutex_t m; 11 pthread_mutex_init(&m, 0); 12 pthread_t t; 13 pthread_create(&t, 0, Thread, &m); 14 usleep(1000*1000); 15 pthread_mutex_destroy(&m); 16 pthread_join(t, 0); 17 return 0; 18 } 19 20 // CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex 21 // CHECK: #0 pthread_mutex_destroy 22 // CHECK: #1 main 23 // CHECK: and: 24 // CHECK: #0 pthread_mutex_lock 25 // CHECK: #1 Thread 26 // CHECK: Mutex {{.*}} created at: 27 // CHECK: #0 pthread_mutex_init 28 // CHECK: #1 main 29 30