1 // RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t 2 // RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll 3 // RUN: %env_asan_opts=detect_stack_use_after_return=1 not %run %t %t.dll 2>&1 | FileCheck %s 4 5 #include <malloc.h> 6 7 char *x; 8 9 void foo() { 10 char stack_buffer[42]; 11 x = &stack_buffer[13]; 12 } 13 14 extern "C" __declspec(dllexport) 15 int test_function() { 16 foo(); 17 *x = 42; 18 // CHECK: AddressSanitizer: stack-use-after-return 19 // CHECK: WRITE of size 1 at [[ADDR:.*]] thread T0 20 // CHECK-NEXT: test_function{{.*}}dll_stack_use_after_return.cc:[[@LINE-3]] 21 // CHECK-NEXT: main 22 // 23 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame 24 // CHECK-NEXT: #0 {{.*}} foo{{.*}}dll_stack_use_after_return.cc 25 // CHECK: 'stack_buffer' <== Memory access at offset [[OFFSET]] is inside this variable 26 return 0; 27 } 28 29