1 // Regression test for http://llvm.org/bugs/show_bug.cgi?id=21621
2 // This test relies on timing between threads, so any failures will be flaky.
3 // RUN: %clangxx_lsan %s -o %t
4 // RUN: %env_lsan_opts="log_pointers=1:log_threads=1" %run %t
10 pthread_cond_t cond
= PTHREAD_COND_INITIALIZER
;
11 pthread_mutex_t mutex
= PTHREAD_MUTEX_INITIALIZER
;
14 void *func(void *arg
) {
15 // This mutex will never be grabbed.
16 fprintf(stderr
, "entered func()\n");
17 pthread_mutex_lock(&mutex
);
19 pthread_mutex_unlock(&mutex
);
23 void create_detached_thread() {
27 pthread_attr_init(&attr
);
28 pthread_attr_setdetachstate(&attr
, PTHREAD_CREATE_DETACHED
);
30 void *arg
= malloc(1337);
32 // This mutex is never unlocked by the main thread.
33 pthread_mutex_lock(&mutex
);
34 int res
= pthread_create(&thread_id
, &attr
, func
, arg
);
39 create_detached_thread();