Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / pthread_create_version.cpp
blobefdb8ca97c4f72402294b5bed243784c0e2b942a
1 // RUN: %clangxx_asan -std=c++11 -pthread %s -o %t && %run %t 2>&1
2 // Regression test for the versioned pthread_create interceptor on linux/i386.
3 // pthread_attr_init is not intercepted and binds to the new abi
4 // pthread_create is intercepted; dlsym always returns the oldest version.
5 // This results in a crash inside pthread_create in libc.
7 #include <pthread.h>
8 #include <stdlib.h>
10 void *ThreadFunc(void *) { return nullptr; }
12 int main() {
13 pthread_t t;
14 const size_t sz = 1024 * 1024;
15 void *p = malloc(sz);
16 pthread_attr_t attr;
17 pthread_attr_init(&attr);
18 pthread_attr_setstack(&attr, p, sz);
19 pthread_create(&t, &attr, ThreadFunc, nullptr);
20 pthread_join(t, nullptr);
21 free(p);
22 return 0;