[ASan tests] Add the first Windows-only lit test
[blocksruntime.git] / test / asan / TestCases / Windows / thread_stack_array_left_oob.cc
blobcab8228a9962ab7a0070a8cf727d02cbdef54f08
1 // RUN: %clangxx_asan -O0 %s -Fe%t 2>&1
2 // 'cat' is used below to work around FileCheck buffering bug which makes this
3 // test flaky. FIXME: file an issue.
4 // RUN: not %run %t 2>&1 | cat | FileCheck %s --check-prefix=CHECK
6 #include <windows.h>
8 DWORD WINAPI thread_proc(void *context) {
9 int subscript = -1;
10 volatile char stack_buffer[42];
11 stack_buffer[subscript] = 42;
12 // CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
13 // CHECK: WRITE of size 1 at [[ADDR]] thread T1
14 // CHECK: {{#0 .* thread_proc .*thread_stack_array_left_oob.cc}}:[[@LINE-3]]
15 // CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame
16 // CHECK: thread_proc
17 return 0;
20 int main(void) {
21 HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL);
22 // CHECK: Thread T1 created by T0 here:
23 // CHECK: {{#[01] .* main .*thread_stack_array_left_oob.cc}}:[[@LINE-2]]
24 WaitForSingleObject(thr, INFINITE);
25 return 0;