brintos

brintos / llvm-project-archived public Read only

0
0
Text · 572 B · 7b832e1 Raw
28 lines · cpp
1// RUN: %clang_cl_asan %Od %s %Fe%t2// RUN: %run %t3 4#include <windows.h>5 6DWORD WINAPI thread_proc(void *) {7  volatile char stack_buffer[42];8  for (int i = 0; i < sizeof(stack_buffer); ++i)9    stack_buffer[i] = 42;10  return 0x42;11}12 13int main() {14  DWORD exitcode;15  HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, CREATE_SUSPENDED, NULL);16  ResumeThread(thr);17  if (thr == 0)18    return 1;19  if (WAIT_OBJECT_0 != WaitForSingleObject(thr, INFINITE))20    return 2;21 22  GetExitCodeThread(thr, &exitcode);23  if (exitcode != 0x42)24    return 3;25  CloseHandle(thr);26}27 28