]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/asan-symbolize-sanity-test.cc
1 // Check that asan_symbolize.py script works (for binaries, ASan RTL and
2 // shared object files.
4 // RUN: %clangxx_asan -O0 %p/SharedLibs/shared-lib-test-so.cc -fPIC -shared -o %t-so.so
5 // RUN: %clangxx_asan -O0 %s -ldl -o %t
6 // RUN: ASAN_OPTIONS=symbolize=0 not %run %t 2>&1 | %asan_symbolize | FileCheck %s
15 typedef void (fun_t
)(int*, int);
17 int main(int argc
, char *argv
[]) {
18 string path
= string(argv
[0]) + "-so.so";
19 printf("opening %s ... \n", path
.c_str());
20 void *lib
= dlopen(path
.c_str(), RTLD_NOW
);
22 printf("error in dlopen(): %s\n", dlerror());
25 fun_t
*inc2
= (fun_t
*)dlsym(lib
, "inc2");
28 int *array
= (int*)malloc(40);
30 inc2(array
, -1); // BOOM
31 // CHECK: ERROR: AddressSanitizer: heap-buffer-overflow
32 // CHECK: READ of size 4 at 0x{{.*}}
33 // CHECK: #0 {{.*}} in inc2 {{.*}}shared-lib-test-so.cc:26
34 // CHECK: #1 {{.*}} in main {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-4]]
35 // CHECK: allocated by thread T{{.*}} here:
36 // CHECK: #{{.*}} in {{(wrap_|__interceptor_)?}}malloc
37 // CHECK: #{{.*}} in main {{.*}}asan-symbolize-sanity-test.cc:[[@LINE-9]]