blob: 3f7be5cf823314afe918e4298345ddc157801f71 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: %clangxx_tsan -O1 %s -DLIB -fPIC -fno-sanitize=thread -shared -o %T/libignore_lib3.so
2// RUN: %clangxx_tsan -O1 %s -o %t
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08003// RUN: %env_tsan_opts=suppressions='%s.supp' %deflake %run %t | FileCheck %s
Stephen Hines2d1fdb22014-05-28 23:58:16 -07004
5// Tests that unloading of a library matched against called_from_lib suppression
6// causes program crash (this is not supported).
7
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08008// Some aarch64 kernels do not support non executable write pages
9// REQUIRES: stable-runtime
10
Stephen Hines2d1fdb22014-05-28 23:58:16 -070011#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
20int 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
29extern "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