31 lines · cpp
1// This test works on both MSVC and MinGW targets, but they require different2// build commands. By default we use DWARF debug info on MinGW and dbghelp does3// not support it, so we need to specify extra flags to get the compiler to4// generate PDB debug info.5 6// RUN: %clangxx_asan %if target={{.*-windows-gnu}} %{ -gcodeview -gcolumn-info -Wl,--pdb= -ldbghelp %} -O0 %s -o %t7// RUN: %env_asan_opts=external_symbolizer_path=non-existent\\\\asdf not %run %t 2>&1 | FileCheck %s8 9#include <windows.h>10#include <dbghelp.h>11 12#pragma comment(lib, "dbghelp")13 14int main() {15 // Make sure the RTL recovers from "no options enabled" dbghelp setup.16 SymSetOptions(0);17 18 // Make sure the RTL recovers from "fInvadeProcess=FALSE".19 if (!SymInitialize(GetCurrentProcess(), 0, FALSE))20 return 42;21 22 *(volatile int*)0 = 42;23 // CHECK: ERROR: AddressSanitizer: access-violation on unknown address24 // CHECK: The signal is caused by a WRITE memory access.25 // CHECK: Hint: address points to the zero page.26 // CHECK: {{WARNING: .*DbgHelp}}27 // CHECK: {{WARNING: Failed to use and restart external symbolizer}}28 // CHECK: {{#0 0x.* in main.*report_after_syminitialize.cpp:}}[[@LINE-6]]29 // CHECK: AddressSanitizer can not provide additional info.30}31