在调试器中运行程序时,如果程序产生异常,调试器会首先获得通知(即First-chance exception),而后此异常由产生它的程序负责捕获。
如果程序没有捕获并处理此异常,那么调试器会再次被通知(即Second-chance exception,Last-chance exception),并结束程序。
通常见到的“First-chance exception”一般是“0xC0000005: Access Violation”,“0xC00000FD: Stack Overflow”等,这些都说明程序中有缺陷,需要修正。
http://niernocry.blog.163.com/blog/static/1545292020071015105559513/
First-chance exception
What is a first chance exception?
When an application is being debugged, the debugger gets notified whenever an exception is encountered.
At this point, the application is suspended and the debugger decides how to handle the exception.
The first pass through this mechanism is called a "first chance" exception. Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode.
If the application handles the exception, it continues to run normally.
如果程序遇到异常,首先会被"first chance" exception这种机制来捕获和进行后续处理,如果程序处理了异常,即可进行正常运行。
Second-chance exception
If the application does not handle the exception, the debugger is re-notified. This is known as a "second chance" exception. The debugger again suspends the application and determines how to handle this exception. Typically, debuggers are configured to stop on second chance (unhandled) exceptions and debug mode is entered, allowing you to debug.
如果捕获到异常后,程序没有进行处理,这时候的叫做"second chance" exception。程序会再次暂停,并决定去如何去处理这个异常。
示意图
References:
http://niernocry.blog.163.com/blog/static/1545292020071015105559513/
http://blog.csdn.net/m_star_jy_sy/article/details/5578998
http://blog.163.com/cp7618%40yeah/blog/static/702347772010226112255101/