[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / tsan / race_on_mutex2.c
blobc860fc6d8eb61611aa96ee27c5c6b2771cfbd488
1 // RUN: %clang_tsan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 #include <pthread.h>
3 #include <stdio.h>
4 #include <stddef.h>
5 #include <unistd.h>
7 void *Thread(void *x) {
8 pthread_mutex_lock((pthread_mutex_t*)x);
9 pthread_mutex_unlock((pthread_mutex_t*)x);
10 return 0;
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;
24 // CHECK: WARNING: ThreadSanitizer: data race