1 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
4 // This test is failing on powerpc64 (VMA=44). After calling pthread_cancel,
5 // the Thread-specific data destructors are not called, so the destructor
6 // "thread_finalize" (defined in tsan_interceptors.cpp) can not set the status
7 // of the thread to "ThreadStatusFinished" failing a check in "SetJoined"
8 // (defined in sanitizer_thread_registry.cpp). It might seem a bug on glibc,
9 // however the same version GLIBC-2.17 will not make fail the test on
10 // powerpc64 BE (VMA=46)
11 // UNSUPPORTED: target=powerpc64-unknown-linux-gnu{{.*}}
19 static void my_cleanup(void *arg
) {
20 printf("my_cleanup\n");
21 pthread_mutex_unlock((pthread_mutex_t
*)arg
);
25 pthread_mutex_lock(&m
);
26 pthread_cleanup_push(my_cleanup
, &m
);
27 barrier_wait(&barrier
);
29 pthread_cond_wait(&c
, &m
);
30 pthread_cleanup_pop(1);
35 barrier_init(&barrier
, 2);
39 pthread_mutex_init(&m
, 0);
40 pthread_cond_init(&c
, 0);
42 pthread_create(&th
, 0, thr1
, 0);
43 barrier_wait(&barrier
);
44 sleep(1); // let it block on cond var
48 pthread_mutex_lock(&m
);
49 pthread_mutex_unlock(&m
);
50 fprintf(stderr
, "OK\n");