| 1 | // RUN: %clang_lsan %s -o %t && %env_lsan_opts=log_threads=1 %run %t 2>&1 | FileCheck %s |
|---|---|
| 2 | |
| 3 | // XFAIL: hwasan |
| 4 | |
| 5 | // No pthread barriers on Darwin. |
| 6 | // UNSUPPORTED: darwin |
| 7 | |
| 8 | #include <assert.h> |
| 9 | #include <pthread.h> |
| 10 | #include <sanitizer/lsan_interface.h> |
| 11 | #include <stdio.h> |
| 12 | #include <stdlib.h> |
| 13 | #include <unistd.h> |
| 14 | |
| 15 | pthread_barrier_t bar; |
| 16 | |
| 17 | void *threadfn(void *arg) { |
| 18 | pthread_barrier_wait(barrier: &bar); |
| 19 | sleep(seconds: 10000); |
| 20 | return 0; |
| 21 | } |
| 22 | |
| 23 | int main(int argc, char *argv[]) { |
| 24 | pthread_t thread_id; |
| 25 | pthread_barrier_init(barrier: &bar, attr: 0, count: 3); |
| 26 | |
| 27 | pthread_create(newthread: &thread_id, attr: 0, start_routine: threadfn, arg: 0); |
| 28 | pthread_create(newthread: &thread_id, attr: 0, start_routine: threadfn, arg: 0); |
| 29 | |
| 30 | pthread_barrier_wait(barrier: &bar); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | // CHECK: Thread T0/{{[0-9]+}} was created by T-1 |
| 35 | // CHECK: Thread T1/{{[0-9]+}} was created by T0/ |
| 36 | // CHECK: Thread T2/{{[0-9]+}} was created by T0/ |
| 37 |
