Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 1 | // RUN: %clang_cl_asan -O0 %s -Fe%t |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 2 | // RUN: not %run %t 2>&1 | FileCheck %s |
| 3 | |
| 4 | #include <windows.h> |
| 5 | |
| 6 | DWORD WINAPI thread_proc(void *) { |
| 7 | int subscript = -1; |
| 8 | volatile char stack_buffer[42]; |
| 9 | stack_buffer[subscript] = 42; |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 10 | // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]] |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 11 | // CHECK: WRITE of size 1 at [[ADDR]] thread T1 |
| 12 | // CHECK: {{#0 .* thread_proc .*thread_stack_array_left_oob.cc}}:[[@LINE-3]] |
| 13 | // CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame |
| 14 | // CHECK: thread_proc |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | int main() { |
| 19 | HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL); |
| 20 | // CHECK: Thread T1 created by T0 here: |
| 21 | // CHECK: {{#[01] .* main .*thread_stack_array_left_oob.cc}}:[[@LINE-2]] |
| 22 | |
| 23 | // A failure to create a thread should fail the test! |
| 24 | if (thr == 0) return 0; |
| 25 | |
| 26 | WaitForSingleObject(thr, INFINITE); |
| 27 | } |