• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
2 #include "test.h"
3 
Thread(void * x)4 void *Thread(void *x) {
5   barrier_wait(&barrier);
6   return 0;
7 }
8 
main()9 int main() {
10   volatile int N = 5;  // prevent loop unrolling
11   barrier_init(&barrier, N + 1);
12   for (int i = 0; i < N; i++) {
13     pthread_t t;
14     pthread_create(&t, 0, Thread, 0);
15   }
16   barrier_wait(&barrier);
17   sleep(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