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: not %run %t %t.dll 2>&1 | FileCheck %s 4 5 #include <process.h> 6 7 void noreturn_f() { 8 int subscript = -1; 9 char buffer[42]; 10 buffer[subscript] = 42; 11 _exit(1); 12 // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] 13 // CHECK: WRITE of size 1 at [[ADDR]] thread T0 14 // CHECK-NEXT: noreturn_f {{.*}}dll_noreturn.cc:[[@LINE-4]] 15 // CHECK-NEXT: test_function {{.*}}dll_noreturn.cc 16 // CHECK-NEXT: main {{.*}}dll_host.cc 17 // 18 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame 19 // CHECK-NEXT: noreturn_f {{.*}}dll_noreturn.cc 20 // CHECK: 'buffer' <== Memory access at offset [[OFFSET]] underflows this variable 21 // CHECK-LABEL: SUMMARY 22 } 23 24 extern "C" __declspec(dllexport) 25 int test_function() { 26 noreturn_f(); 27 return 0; 28 } 29