在調(diào)試器中運(yùn)行程序時(shí),如果程序產(chǎn)生異常,調(diào)試器會(huì)首先獲得通知(即First-chance exception),而后此異常由產(chǎn)生它的程序負(fù)責(zé)捕獲。
如果程序沒(méi)有捕獲并處理此異常,那么調(diào)試器會(huì)再次被通知(即Second-chance exception,Last-chance exception),并結(jié)束程序。
通常見(jiàn)到的“First-chance exception”一般是“0xC0000005: Access Violation”,“0xC00000FD: Stack Overflow”等,這些都說(shuō)明程序中有缺陷,需要修正。
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.
如果程序遇到異常,首先會(huì)被"first chance" exception這種機(jī)制來(lái)捕獲和進(jìn)行后續(xù)處理,如果程序處理了異常,即可進(jìn)行正常運(yùn)行。
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.
如果捕獲到異常后,程序沒(méi)有進(jìn)行處理,這時(shí)候的叫做"second chance" exception。程序會(huì)再次暫停,并決定去如何去處理這個(gè)異常。
示意圖

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/