1 // RUN: rm -rf %t-dir 2 // RUN: mkdir %t-dir 3 4 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %t-dir/libignore_lib3.so 5 // RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable 6 // RUN: %env_tsan_opts=suppressions='%s.supp':verbosity=1 %run %t-dir/executable 2>&1 | FileCheck %s 7 8 // Tests that unloading of a library matched against called_from_lib suppression 9 // is supported. 10 11 // Some aarch64 kernels do not support non executable write pages 12 // REQUIRES: stable-runtime 13 14 #ifndef LIB 15 16 #include <dlfcn.h> 17 #include <stdlib.h> 18 #include <stdio.h> 19 #include <errno.h> 20 #include <libgen.h> 21 #include <string> 22 23 int main(int argc, char **argv) { 24 std::string lib = std::string(dirname(argv[0])) + "/libignore_lib3.so"; 25 void *h; 26 void (*f)(); 27 // Try opening, closing and reopening the ignored lib. 28 for (unsigned int k = 0; k < 2; k++) { 29 h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW); 30 if (h == 0) 31 exit(printf("failed to load the library (%d)\n", errno)); 32 f = (void (*)())dlsym(h, "libfunc"); 33 if (f == 0) 34 exit(printf("failed to find the func (%d)\n", errno)); 35 f(); 36 dlclose(h); 37 } 38 fprintf(stderr, "OK\n"); 39 } 40 41 #else // #ifdef LIB 42 43 # include "ignore_lib_lib.h" 44 45 #endif // #ifdef LIB 46 47 // CHECK: Matched called_from_lib suppression 'ignore_lib3.so' 48 // CHECK: library '{{.*}}ignore_lib3.so' that was matched against called_from_lib suppression 'ignore_lib3.so' is unloaded 49 // CHECK: Matched called_from_lib suppression 'ignore_lib3.so' 50 // CHECK: library '{{.*}}ignore_lib3.so' that was matched against called_from_lib suppression 'ignore_lib3.so' is unloaded 51 // CHECK: OK 52