1 // RUN: %clang_tsan -O1 %s -o %t
2 // RUN: not %t 2>&1 | FileCheck %s --check-prefix=CHECK-NOZUPP
3 // RUN: TSAN_OPTIONS="suppressions=%s.supp print_suppressions=1" %t 2>&1 | FileCheck %s --check-prefix=CHECK-SUPP
14 void *Thread1(void *x
) {
15 pthread_mutex_lock(&mtx
);
17 pthread_mutex_unlock(&mtx
);
21 void *Thread2(void *x
) {
23 pthread_mutex_lock(&mtx
);
25 pthread_mutex_unlock(&mtx
);
30 mem
= (int*)malloc(100);
31 pthread_mutex_init(&mtx
, 0);
33 pthread_create(&t
, NULL
, Thread1
, NULL
);
35 pthread_join(t
, NULL
);
36 pthread_mutex_destroy(&mtx
);
40 // CHECK-NOZUPP: WARNING: ThreadSanitizer: heap-use-after-free
41 // CHECK-NOZUPP: Write of size 4 at {{.*}} by main thread{{.*}}:
42 // CHECK-NOZUPP: #0 Thread2
43 // CHECK-NOZUPP: #1 main
44 // CHECK-NOZUPP: Previous write of size 8 at {{.*}} by thread T1{{.*}}:
45 // CHECK-NOZUPP: #0 free
46 // CHECK-NOZUPP: #{{(1|2)}} Thread1
47 // CHECK-NOZUPP: SUMMARY: ThreadSanitizer: heap-use-after-free{{.*}}Thread2
48 // CHECK-SUPP: ThreadSanitizer: Matched 1 suppressions
49 // CHECK-SUPP: 1 race:^Thread2$