1// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2#include "test.h"
3
4void *Thread(void *x) {
5 barrier_wait(barrier: &barrier);
6 return 0;
7}
8
9int main() {
10 barrier_init(barrier: &barrier, count: 2);
11 pthread_t t;
12 pthread_create(newthread: &t, attr: 0, start_routine: Thread, arg: 0);
13 barrier_wait(barrier: &barrier);
14 sleep(seconds: 1); // wait for the thread to finish and exit
15 return 0;
16}
17
18// CHECK: WARNING: ThreadSanitizer: thread leak
19// CHECK: SUMMARY: ThreadSanitizer: thread leak{{.*}}main
20

source code of compiler-rt/test/tsan/thread_leak3.c