• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -shared -o %T/libignore_lib4.so
2 // RUN: %clangxx_tsan -O1 %s -o %t
3 // RUN: echo "called_from_lib:libignore_lib4.so" > %t.supp
4 // RUN: %env_tsan_opts=suppressions='%t.supp' %run %t 2>&1 | FileCheck %s
5 
6 // Longjmp assembly has not been implemented for mips64 yet
7 // XFAIL: mips64
8 // powerpc64 big endian bots failed with "FileCheck error: '-' is empty" due
9 // to a segmentation fault.
10 // UNSUPPORTED: powerpc64-unknown-linux-gnu
11 // aarch64 bots failed with "called_from_lib suppression 'libignore_lib4.so'
12 //                           is matched against 2 libraries".
13 // UNSUPPORTED: aarch64
14 
15 // Test longjmp in ignored lib.
16 // It used to crash since we jumped out of ScopedInterceptor scope.
17 
18 #include "test.h"
19 #include <setjmp.h>
20 #include <string.h>
21 #include <errno.h>
22 #include <libgen.h>
23 #include <string>
24 
25 #ifdef LIB
26 
myfunc()27 extern "C" void myfunc() {
28   for (int i = 0; i < (1 << 20); i++) {
29     jmp_buf env;
30     if (!setjmp(env))
31       longjmp(env, 1);
32   }
33 }
34 
35 #else
36 
main(int argc,char ** argv)37 int main(int argc, char **argv) {
38   std::string lib = std::string(dirname(argv[0])) + "/libignore_lib4.so";
39   void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW);
40   void (*func)() = (void(*)())dlsym(h, "myfunc");
41   func();
42   fprintf(stderr, "DONE\n");
43   return 0;
44 }
45 
46 #endif
47 
48 // CHECK: DONE
49