Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / pthread_getattr_np_deadlock.cpp
blob241caa2a211d861e8a00bffae0fb33126697a1b3
1 // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && %run %t
3 // Regression test for a deadlock in pthread_getattr_np
5 #include <assert.h>
6 #include <pthread.h>
7 #if defined(__FreeBSD__)
8 #include <pthread_np.h>
9 #endif
11 void *ThreadFn(void *) {
12 pthread_attr_t attr;
13 #if defined(__FreeBSD__)
14 // On FreeBSD it needs to allocate attr underlying memory
15 int res = pthread_attr_init(&attr);
16 assert(!res);
17 res = pthread_attr_get_np(pthread_self(), &attr);
18 #else
19 int res = pthread_getattr_np(pthread_self(), &attr);
20 #endif
21 assert(!res);
22 return 0;
25 int main(void) {
26 pthread_t t;
27 int res = pthread_create(&t, 0, ThreadFn, 0);
28 assert(!res);
29 res = pthread_join(t, 0);
30 assert(!res);
31 return 0;