1// RUN: %clang_cl_asan %Od %s %Fe%t
2// RUN: not %run %t 2>&1 | FileCheck %s
3
4#include <windows.h>
5
6HANDLE done;
7
8DWORD 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 T-1
14 // CHECK: {{#0 .* work_item.*queue_user_work_item_report.cpp}}:[[@LINE-3]]
15 SetEvent(done);
16 return 0;
17}
18
19int main(int argc, char **argv) {
20 done = CreateEvent(0, false, false, "job is done");
21 if (!done)
22 return 1;
23 // CHECK-NOT: Thread {{.*}} created
24 QueueUserWorkItem(&work_item, nullptr, 0);
25 if (WAIT_OBJECT_0 != WaitForSingleObject(done, 10 * 1000))
26 return 2;
27}
28

source code of compiler-rt/test/asan/TestCases/Windows/queue_user_work_item_report.cpp