[ASan/Win] Add a comment about DCL-using-static vs threads
[blocksruntime.git] / test / tsan / longjmp3.cc
blobafb4996d433b6e7528d8655e623166b399b0bfe7
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 <stdlib.h>
5 #include <setjmp.h>
7 void bar(jmp_buf env) {
8 volatile int x = 42;
9 longjmp(env, 42);
10 x++;
13 void foo(jmp_buf env) {
14 volatile int x = 42;
15 bar(env);
16 x++;
19 void badguy() {
20 pthread_mutex_t mtx;
21 pthread_mutex_init(&mtx, 0);
22 pthread_mutex_lock(&mtx);
23 pthread_mutex_destroy(&mtx);
26 void mymain() {
27 jmp_buf env;
28 if (setjmp(env) == 42) {
29 badguy();
30 return;
32 foo(env);
33 printf("FAILED\n");
36 int main() {
37 volatile int x = 42;
38 mymain();
39 return x;
42 // CHECK-NOT: FAILED
43 // CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex
44 // CHECK: #0 pthread_mutex_destroy
45 // CHECK: #1 badguy
46 // CHECK: #2 mymain
47 // CHECK: #3 main