brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d65ecd8 Raw
50 lines · cpp
1// RUN: rm -rf %t-dir2// RUN: mkdir %t-dir3 4// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -shared -o %t-dir/libignore_lib4.so5// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -o %t-dir/executable6// RUN: echo "called_from_lib:libignore_lib4.so" > %t-dir/executable.supp7// RUN: %env_tsan_opts=suppressions='%t-dir/executable.supp' %run %t-dir/executable 2>&1 | FileCheck %s8 9// powerpc64 big endian bots failed with "FileCheck error: '-' is empty" due10// to a segmentation fault.11// UNSUPPORTED: target=powerpc64-unknown-linux-gnu{{.*}}12// aarch64 bots failed with "called_from_lib suppression 'libignore_lib4.so'13//                           is matched against 2 libraries".14// UNSUPPORTED: target=aarch64{{.*}}15 16// Test longjmp in ignored lib.17// It used to crash since we jumped out of ScopedInterceptor scope.18 19#include "test.h"20#include <setjmp.h>21#include <string.h>22#include <errno.h>23#include <libgen.h>24#include <string>25 26#ifdef LIB27 28extern "C" void myfunc() {29  for (int i = 0; i < (1 << 20); i++) {30    jmp_buf env;31    if (!setjmp(env))32      longjmp(env, 1);33  }34}35 36#else37 38int main(int argc, char **argv) {39  std::string lib = std::string(dirname(argv[0])) + "/libignore_lib4.so";40  void *h = dlopen(lib.c_str(), RTLD_GLOBAL | RTLD_NOW);41  void (*func)() = (void(*)())dlsym(h, "myfunc");42  func();43  fprintf(stderr, "DONE\n");44  return 0;45}46 47#endif48 49// CHECK: DONE50