title: How do identify STATUS_INVALID_CRUNTIME_PARAMETER exception
body: <p>Platform is Windows 7 SP1.</p>
  
  <p>I recently spent some time debugging an issue that was caused because a code was passing an invalid parameter to one of the "safe" CRT functions. As a result my application was aborted right away with no warning or anything -- not even a crash dialog.</p>
  
  <p>At first, I tried to figure this out by attaching Windbg to my application. However when the crash happened, by the time the code broke into Windbg pretty much every thread had been killed save for ONE thread on which Windbg had to break into. There was no clue as to what was wrong. So, I attached Visual Studio as a debugger instead and when my application terminated, I saw every thread exiting with error code <strong>0xc0000417</strong>. <em>That</em> is what gave me the clue that there is an invalid parameter issue somewhere.</p>
  
  <p>Next, the way I went about trying to debug this is to once again attach Windbg to my application but this time randomly (by trial &amp; error) place breakpoints in various places like <code>kernel32!TerminateThread</code>, <code>kernel32!UnhandledExceptionFilter</code> and <code>kernel32!SetUnhandledExceptionFilter</code>.</p>
  
  <p>Of the lot, placing a break point at <code>SetUnhandledExceptionFilter</code> immediately showed the callstack of the offending thread when the crash occurred and the CRT function that we were calling incorrectly.</p>
  
  <p>Question: Is there anything intuitive that should have told me to place bp on <strong>SUEF</strong> right away? I would like to understand this a bit better and not do this by trial and error. Second question is w.r.t to the error code I determined via Visual Studio. Without resorting to VS, how do I determine thread exit codes on Windbg?</p>