1 // Test that ASan doesn't deadlock in __interceptor_pthread_create called
2 // from dlopened shared library constructor. The deadlock happens only in shared
3 // ASan runtime with recent Glibc (2.23 fits) when __interceptor_pthread_create
4 // grabs global Glibc's GL(dl_load_lock) and waits for tls_get_addr_tail that
5 // also tries to acquire it.
7 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t-so.so
8 // RUN: %clangxx_asan %s -o %t
11 // dlopen() can not be intercepted on Android
12 // UNSUPPORTED: android
13 // REQUIRES: x86-target-arch
21 void *threadFn(void *) {
22 fprintf(stderr
, "thread started\n");
29 void __attribute__((constructor
)) startPolling() {
30 fprintf(stderr
, "initializing library\n");
32 pthread_create(&t
, 0, &threadFn
, 0);
33 fprintf(stderr
, "done\n");
42 int main(int argc
, char **argv
) {
43 std::string path
= std::string(argv
[0]) + "-so.so";
44 void *handle
= dlopen(path
.c_str(), RTLD_LAZY
);