brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · a04661b Raw
37 lines · cpp
1// RUN: %clang_cl_asan %Od %s %Fe%t2// RUN: env ASAN_OPTIONS=handle_segv=0 %run %t 2>&1 | FileCheck %s --check-prefix=USER3// RUN: env ASAN_OPTIONS=handle_segv=1 not %run %t 2>&1 | FileCheck %s --check-prefix=ASAN4// Test the default.5// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=ASAN6 7// This test exits zero when its unhandled exception filter is set. ASan should8// not disturb it when handle_segv=0.9 10// USER: in main11// USER: in SEHHandler12 13// ASAN: in main14// ASAN: ERROR: AddressSanitizer: access-violation15 16#include <windows.h>17#include <stdio.h>18 19static long WINAPI SEHHandler(EXCEPTION_POINTERS *info) {20  DWORD exception_code = info->ExceptionRecord->ExceptionCode;21  if (exception_code == EXCEPTION_ACCESS_VIOLATION) {22    fprintf(stderr, "in SEHHandler\n");23    fflush(stderr);24    TerminateProcess(GetCurrentProcess(), 0);25  }26  return EXCEPTION_CONTINUE_SEARCH;27}28 29int main() {30  SetUnhandledExceptionFilter(SEHHandler);31  fprintf(stderr, "in main\n");32  fflush(stderr);33 34  volatile int *p = nullptr;35  *p = 42;36}37