Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / create_thread_fail.cpp
blob8ed9b4ccf16c253eaf1507839df44118e5895e30
1 // Sanitizer should not crash if pthread_create fails.
2 // RUN: %clangxx -pthread %s -o %t && %run %t
4 // pthread_create with lsan i386 does not fail here.
5 // UNSUPPORTED: i386-linux && lsan
7 #include <cassert>
8 #include <pthread.h>
9 #include <stdlib.h>
11 void *null_func(void *args) {
12 return NULL;
15 int main(void) {
16 pthread_t thread;
17 pthread_attr_t attrs;
18 pthread_attr_init(&attrs);
19 // Set size huge enough to fail pthread_create.
20 size_t sz = ~0;
21 // Align the size just in case.
22 sz >>= 16;
23 sz <<= 16;
24 int res = pthread_attr_setstacksize(&attrs, sz);
25 assert(res == 0);
26 for (size_t i = 0; i < 10; ++i) {
27 res = pthread_create(&thread, &attrs, null_func, NULL);
28 assert(res != 0);
30 return 0;