Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 1 | // RUN: %clang_cl_asan -O0 %p/dll_host.cc -Fe%t |
| 2 | // RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 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); |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 12 | // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]] |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 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 | } |