VS2008 C++ MFC Access Violation ONLY when stepping through debug mode
- by HotOil
Hi.
This is crazy. It started happening in my main project, so I created a tiny sample brand-new project to reproduce it in and sure enough.. It does NOT happen in a sample project I created that is only a Win32 console app.
I'm running this on Win7x64, if that matters. VS2008 SP1.
Here goes. I create a small dialog app with a button. Put a breakpoint in the handler function for that button. The button handler function looks like this:
void CTestProjectDlg::OnBnClickedButton1()
{
int i=2;
m_csHello.Format(_T("Hello World!")); << breakpoint here
UpdateData(FALSE);
}
Click the button, hit the breakpoint. F10 to step, and boom: "First-chance exception at 0x0398f77b in TestProject.exe: 0xC0000005: Access violation."
It gives me the option to Break or Continue. If I Continue, it just hits it again, only not "First Chance". Yes I have that exception checked in the Debug-Exceptions dlg.
If I Break, the call stack just shows me the line where the breakpoint is. If I F10 again.. I get the exception again, only now the callstack shows me in the _AfxDispatchCmdMsg() function, and my original OnBnClickedButton1() is not in the callstack anymore.
It doesn't matter where I put the breakpoint.
If, instead of F10, I just continue with F5, it works normally.
Now.. if I build a Release version and run in debugging mode: I hit the breakpoint, and all the pointers, variable values look normal. F10, and these turn to garbage. The this pointer is now zero. The m_csHello is now
However, in Release mode, an exception is not caught, and it all runs fine. The "hello World string gets displayed in the dialog box as it should.
I have put in an inquiry to see if some patch was installed on my box by the IT dept in the last day or two. This wasn't happening 2 days ago.
What do you think? Is VS2008 corrupted?
Thanks.