1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
3 // on_exit() is not available on Darwin.
10 void *thread(void *x
) {
12 barrier_wait(&barrier
);
16 void on_exit_callback(int status
, void *arg
) {
17 fprintf(stderr
, "on_exit_callback(%d, %lu)\n", status
, (long)arg
);
22 on_exit(on_exit_callback
, (void *)42l);
23 barrier_init(&barrier
, 2);
25 pthread_create(&th
, nullptr, thread
, nullptr);
27 barrier_wait(&barrier
);
31 // CHECK: on_exit_callback(2, 42)
32 // CHECK: WARNING: ThreadSanitizer: data race
33 // CHECK: Write of size 8
34 // CHECK: #0 on_exit_callback
35 // CHECK: #1 on_exit_callback_installed_at