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