[ASan Win] Simplify and improve the way we forward ASan interface calls from DLLs
[blocksruntime.git] / test / asan / TestCases / Windows / dll_malloc_uaf.cc
blob9dc3949b6ca680925f22d2858acfe6a251c869d2
1 // RUN: %clangxx_asan -O0 %p/dll_host.cc -Fe%t
2 // RUN: %clangxx_asan -LD -O0 %s -Fe%t.dll
3 // FIXME: 'cat' is needed due to PR19744.
4 // RUN: not %run %t %t.dll 2>&1 | cat | FileCheck %s
6 #include <malloc.h>
8 extern "C" __declspec(dllexport)
9 int test_function() {
10 int *buffer = (int*)malloc(42);
11 free(buffer);
12 buffer[0] = 42;
13 // CHECK: AddressSanitizer: heap-use-after-free on address [[ADDR:0x[0-9a-f]+]]
14 // CHECK: WRITE of size 4 at [[ADDR]] thread T0
15 // CHECK-NEXT: test_function {{.*}}dll_malloc_uaf.cc:[[@LINE-3]]
16 // CHECK-NEXT: main {{.*}}dll_host
18 // CHECK: [[ADDR]] is located 0 bytes inside of 42-byte region
19 // CHECK-LABEL: freed by thread T0 here:
20 // CHECK: free
21 // CHECK: test_function {{.*}}dll_malloc_uaf.cc:[[@LINE-10]]
22 // CHECK-NEXT: main {{.*}}dll_host
24 // CHECK-LABEL: previously allocated by thread T0 here:
25 // CHECK: malloc
26 // CHECK: test_function {{.*}}dll_malloc_uaf.cc:[[@LINE-16]]
27 // CHECK-NEXT: main {{.*}}dll_host
28 return 0;