title: VS2008 C++ MFC Access Violation ONLY when stepping through debug mode
body: <p>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.</p>
  
  <p>I'm running this on Win7x64, if that matters. VS2008 SP1.</p>
  
  <p>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:</p>
  
  <pre><code>void CTestProjectDlg::OnBnClickedButton1()
  {
      int i;
  
      i = 2;  // &lt; breakpoint here
      i = 3;
  
  }
  </code></pre>
  
  <p>Click the button, hit the breakpoint.  F10 to step, and boom: "First-chance exception at 0x0398f77b in TestProject.exe: 0xC0000005: Access violation."  </p>
  
  <p>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.</p>
  
  <p>If I Break, the call stack just shows me the line where the breakpoint is.  If I F10 <em>again</em>.. 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.  </p>
  
  <p>It doesn't matter where I put the breakpoint.</p>
  
  <p>If, instead of F10, I just continue with F5, it works normally.</p>
  
  <p>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  </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>What do you think?  Is VS2008 corrupted?  </p>
  
  <p>Thanks.  </p>
  
  <p>Edit: Additional Information.  This does not happen if I build/debug the x64 platform.  Only for Win32.<br>
  I also took a look at all of the hotfixes/security updates for VS2008 on the box.  They are</p>
  
  <ul>
  <li><a href="http://support.microsoft.com/kb/971092" rel="noreferrer">kb971092</a>  and</li>
  <li><a href="http://support.microsoft.com/kb/972222" rel="noreferrer">kb972222</a></li>
  </ul>
  
  <p>Finally, I put the project on a different machine that has not been updated for the past 2-3 weeks.  It works find on there, and it has these same VS updates installed.</p>
  
  <p>I have also altered the code that is being stepped over for the purpose of this post. .. It is a simple integer assignment, no MFC involved.</p>
  
  <p>At the moment I am in the middle of re-installing VS2008.</p>