1 // RUN: %clangxx_asan -O0 %p/dll_host.cc -Fe%t
2 // RUN: %clangxx_asan -LD -O0 %s -Fe%t.dll
3 // RUN: not %run %t %t.dll 2>&1 | FileCheck %s
5 #include <sanitizer/asan_interface.h>
7 void should_not_crash(volatile char *c
) {
11 void should_crash(volatile char *c
) {
15 extern "C" __declspec(dllexport
)
18 should_not_crash(&buffer
[0]);
19 __asan_poison_memory_region(buffer
, 128);
20 should_not_crash(&buffer
[192]);
21 __asan_unpoison_memory_region(buffer
, 64);
22 should_not_crash(&buffer
[32]);
24 should_crash(&buffer
[96]);
25 // CHECK: AddressSanitizer: use-after-poison on address [[ADDR:0x[0-9a-f]+]]
26 // CHECK-NEXT: WRITE of size 1 at [[ADDR]] thread T0
27 // CHECK-NEXT: should_crash {{.*}}\dll_poison_unpoison.cc
28 // CHECK-NEXT: test_function {{.*}}\dll_poison_unpoison.cc:[[@LINE-4]]
31 // CHECK: [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
32 // CHECK-NEXT: test_function {{.*}}\dll_poison_unpoison.cc
33 // CHECK: 'buffer' <== Memory access at offset [[OFFSET]] is inside this variable