1 // RUN: %clang_tsan %s -o %t -framework Foundation
2 // RUN: %deflake %run %t 2>&1 | FileCheck %s
9 void __tsan_on_report(void *report);
10 int __tsan_get_report_thread(void *report, unsigned long idx, int *tid,
11 uint64_t *os_id, int *running,
12 const char **name, int *parent_tid, void **trace,
13 unsigned long trace_size);
16 // Required for dyld macOS 12.0+
20 __attribute__((disable_sanitizer_instrumentation))
22 __tsan_on_report(void *report) {
23 fprintf(stderr, "__tsan_on_report(%p)\n", report);
30 void *trace[16] = {0};
31 __tsan_get_report_thread(report, 0, &tid, &os_id, &running, &name, &parent_tid, trace, 16);
32 fprintf(stderr, "tid = %d, os_id = %lu\n", tid, os_id);
36 fprintf(stderr, "Hello world.\n");
39 pthread_threadid_np(NULL, &threadid);
40 fprintf(stderr, "pthread_threadid_np = %llu\n", threadid);
43 pthread_mutex_init(&m, NULL);
44 pthread_mutex_unlock(&m);
45 fprintf(stderr, "Done.\n");
48 // CHECK: Hello world.
49 // CHECK: pthread_threadid_np = [[ADDR:[0-9]+]]
50 // CHECK: WARNING: ThreadSanitizer
51 // CHECK: tid = 0, os_id = [[ADDR]]