Windows 7 64 bit, Visual Studio 2010, Console C++ application, Win32 Debug configuration:
#include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { char* p = NULL; *p = 1; return 0; }
Start Debugging. Obviously, I get this error messsge:
Unhandled exception at 0x77d915de in test.exe: 0xC0000005: Access violation writing location 0x00000000.
I select Debug and see the following stack:
ntdll.dll!77d915de() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] ntdll.dll!77d915de() ntdll.dll!77d8014e() msvcr100d.dll!_heap_alloc_dbg_impl(unsigned int nSize, int nBlockUse, const char * szFileName, int nLine, int * errno_tmp) Line 504 + 0xc bytes C++ >ffffffff()
Debugger breaks on __finally
line in dbgheap.c. Stack is corrupted, the line *p = 1
is missing in the stack. Output window:
'test.exe': Loaded 'C:\tmp\test\Debug\test.exe', Symbols loaded. 'test.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file 'test.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded. First-chance exception at 0x010f13a8 in test.exe: 0xC0000005: Access violation writing location 0x00000000. Unhandled exception at 0x77d915de in test.exe: 0xC0000005: Access violation writing location 0x00000000.
Now, if I run the same program in x64 Debug configuration, everything is OK - debugger breaks on the line *p = 1
. How can I get correct debugging for Win32 program?
Debug->Exceptions->win32 Exception->c0000005 tick the box in "Thrown" column or in the "Thrown" column for entire Win32 Exceptions http://msdn.microsoft.com/en-us/library/038tzxdw(v=vs.100).aspx
*p = 1;
00041375 mov eax,dword ptr [p]
00041378 mov byte ptr [eax],1
First-chance exception at 0x00041378 in test2.exe: 0xC0000005: Access violation writing location 0x00000000