[ASan/Win] Thread more library functions from the DLL thunk to the main module
[blocksruntime.git] / test / asan / TestCases / Windows / dll_intercept_memcpy.cc
blobffa3bf9ad9ad30857c05260d13f65873a7f99afb
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 <stdio.h>
7 #include <string.h>
9 void call_memcpy(void* (*f)(void *, const void *, size_t),
10 void *a, const void *b, size_t c) {
11 f(a, b, c);
14 extern "C" __declspec(dllexport)
15 int test_function() {
16 char buff1[6] = "Hello", buff2[5];
18 call_memcpy(&memcpy, buff2, buff1, 5);
19 if (buff1[2] != buff2[2])
20 return 2;
21 printf("Initial test OK\n");
22 fflush(0);
23 // CHECK: Initial test OK
25 call_memcpy(&memcpy, buff2, buff1, 6);
26 // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
27 // CHECK: WRITE of size 6 at [[ADDR]] thread T0
28 // CHECK-NEXT: __asan_memcpy
29 // CHECK-NEXT: call_memcpy
30 // CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cc:[[@LINE-5]]
31 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset {{.*}} in frame
32 // CHECK-NEXT: test_function {{.*}}dll_intercept_memcpy.cc
33 // CHECK: 'buff2' <== Memory access at offset {{.*}} overflows this variable