Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 1 | // RUN: %clang_cl_asan -O0 %s -Fe%t |
| 2 | // RUN: not %run %t 2>&1 | FileCheck %s |
| 3 | |
| 4 | #include <windows.h> |
| 5 | |
| 6 | HANDLE done; |
| 7 | |
| 8 | DWORD CALLBACK work_item(LPVOID) { |
| 9 | int subscript = -1; |
| 10 | volatile char stack_buffer[42]; |
| 11 | stack_buffer[subscript] = 42; |
| 12 | // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]] |
| 13 | // CHECK: WRITE of size 1 at [[ADDR]] thread T1 |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 14 | // CHECK: {{#0 .* work_item.*queue_user_work_item_report.cc}}:[[@LINE-3]] |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 15 | // CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame |
| 16 | // CHECK: work_item |
| 17 | SetEvent(done); |
| 18 | return 0; |
| 19 | } |
| 20 | |
| 21 | int main(int argc, char **argv) { |
| 22 | done = CreateEvent(0, false, false, "job is done"); |
| 23 | if (!done) |
| 24 | return 1; |
| 25 | // CHECK-NOT: Thread T1 created |
| 26 | QueueUserWorkItem(&work_item, nullptr, 0); |
| 27 | if (WAIT_OBJECT_0 != WaitForSingleObject(done, INFINITE)) |
| 28 | return 2; |
| 29 | } |