title: Reasons for stack unwinding fail
body: <p>I was debugging an application and encountered following code:</p>
  
  <pre><code>int Func()
  {
  
   try 
   {
  
     CSingleLock aLock(&amp;m_CriticalSection, TRUE);
     {
       //user code
     }
   }
   catch(...)
   {
       //exception handling
   }
   return -1;
  
  }
  </code></pre>
  
  <p>m_CriticalSection is CCricialSection.</p>
  
  <p>I found that user code throws an exception such that m_CriticalSection is not released at all. That means due to some reasons stack is corrupted and hence unwinding failed.</p>
  
  <p>My question is:
  1) In what different scenarios stack unwinding can fail ?</p>
  
  <p>2) what different possibility of exception can be thrown such that stack unwinding fails.</p>
  
  <p>3) Can I solve this problem by putting CSingleLock outside of try block ?</p>
  
  <p>Thanks,</p>