brintos

brintos / llvm-project-archived public Read only

0
0
Text · 881 B · 529d6bb Raw
28 lines · cpp
1// RUN: %clang_cl_asan %Od %s %Fe%t2// RUN: not %run %t 2>&1 | FileCheck %s3 4#include <windows.h>5 6DWORD WINAPI thread_proc(void *) {7  int subscript = 42;8  volatile char stack_buffer[42];9  stack_buffer[subscript] = 42;10// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]11// CHECK: WRITE of size 1 at [[ADDR]] thread T112// CHECK:   {{#0 .* thread_proc.*thread_stack_array_right_oob.cpp}}:[[@LINE-3]]13// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame14// CHECK:   thread_proc15  return 0;16}17 18int main(void) {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_right_oob.cpp}}:[[@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}28