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 volatile int N = 5; // prevent loop unrolling
11 barrier_init(barrier: &barrier, count: N + 1);
12 for (int i = 0; i < N; i++) {
13 pthread_t t;
14 pthread_create(newthread: &t, attr: 0, start_routine: Thread, arg: 0);
15 }
16 barrier_wait(barrier: &barrier);
17 sleep(seconds: 1); // wait for the threads to finish and exit
18 return 0;
19}
20
21// CHECK: WARNING: ThreadSanitizer: thread leak
22// CHECK: And 4 more similar thread leaks
23

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