The following code will crash when working under Windows 7 32bit:
void CTestView::OnDraw(CDC* /*pDC*/) { *(int*)0 = 0; // Crash CTestDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: add draw code for native data here }
However, if I try this on Windows 7 64bit, I just get this in the output window:
The first chance exception in 0x13929384 in Test.exe is: 0xC0000005: access is the location of the 0x00000000 violation record.
First chance exception in 0x77c6ee42 in Test.exe: 0xC0150010: context activation is deactivated inactive for the current thread of execution.
What is the reason for this? I know this is a hardware exception ( http://msdn.microsoft.com/en-us/library/aa363082.aspx ), but why the difference when running under 32-bit and 64-bit? And what can I do to handle such errors correctly? Because they really need to be captured and secured, unlike what is currently happening, what Windows just carries is pumping the application and let it work (so the user and developers are completely unaware of any problems actually happened).
Update: Our regular SetUnhandledExceptionFilter reporting software uses SetUnhandledExceptionFilter , but this is not caused by the x64 call for hardware exceptions inside WndProc. Does anyone have any info on this or a workaround?
Update2: I reported this issue in Microsoft Connect:
https://connect.microsoft.com/VisualStudio/feedback/details/550944/hardware-exceptions-on-x64-machines-are-silently-caught-in-wndproc-messages
c ++ windows exception-handling 64bit seh
Mark ingram
source share