1 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib3.so
2 // RUN: %clangxx_tsan -O1 %s -o %t
3 // RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t | FileCheck %s
4 
5 // Tests that unloading of a library matched against called_from_lib suppression
6 // causes program crash (this is not supported).
7 
8 // Some aarch64 kernels do not support non executable write pages
9 // REQUIRES: stable-runtime
10 
11 #ifndef LIB
12 
13 #include <dlfcn.h>
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <errno.h>
17 #include <libgen.h>
18 #include <string>
19 
main(int argc,char ** argv)20 int main(int argc, char **argv) {
21   std::string lib = std::string(dirname(argv[0])) + "/libignore_lib3.so";
22   void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW);
23   dlclose(h);
24   fprintf(stderr, "OK\n");
25 }
26 
27 #else  // #ifdef LIB
28 
libfunc()29 extern "C" void libfunc() {
30 }
31 
32 #endif  // #ifdef LIB
33 
34 // CHECK: ThreadSanitizer: library {{.*}} that was matched against called_from_lib suppression 'ignore_lib3.so' is unloaded
35 // CHECK-NOT: OK
36 
37