First chance exception 与 Second chance exception

1. 当异常发生后,系统会首先检查是否有调试器加载,如果有则调试器会收到异常消息,并决定是否中断程序的执行。这叫First chance exception。如果没有调试器加载,则转2,如果调试器决定忽略First chance exception,同样转2,如果调试器不忽略,则程序被中断,这意味着如果程序中即使有异常处理代码(catch块)它们也不会被执行。所以调试器通常忽略First chance exception,而让用户的异常处理代码(catch块)去处理。

2. 如果没有调试器加载或者调试器忽略了First chance exception,控制流程转向用户的异常处理代码(catch块)。如果没有发现相应的catch块,系统使用自带的异常处理块处理这个异常(转3),如果发现相应的catch块,则执行之,异常处理结束。

3. 系统自带的异常处理程序检查是否有调试器加载,如果有,则中断程序并将控制权交给调试器。这时的异常叫做Second chance exception。此时调试器就完全控制了程序,程序实际上已经挂掉了。如果没有调试器加载,转4.

4. 异常发生了,但用户没有相应的异常处理代码,也有没有调试器加载,这时候就会弹出程序崩溃(Crash)提示。Windows启动注册在注册表里面的默认调试器,一般情况下,Windows的默认调试器是Dr Watson,这个调试器的工作就是弹出著名的“调试还是终止,这个问题”对话框(或者是“是否将错误报告发送给微软?”对话框)。.

比如VS在调试模式下运行程序,输出窗口信息为:


First-chance exception at 0x004117fe in ***: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x004117fe in ***: 0xC0000005: Access violation writing location 0x00000000.

其中0xC0000005是访问违例的异常标识符,0x004117fe是异常产生时的程序地址,0x00000000是Access violation的地址。这说明VS收到了First chance exception但将其忽略了,但程序中没有相应的catch块,导致第二行消息出现,Unhandled exception ,即Second chance exception,VS弹出一个对话框提示说Unhandled exception...,并有Break, Continue, Ignore(灰色)可供选择)。如果有相应的catch块,则不会输出第二行信息,也不会有对话框弹出。


As an AI language model, I do not have access to your system's context or logs to provide a specific solution to your issue. However, I can provide general information about the error message you have reported. A "break instruction exception" is a type of software exception that occurs when the CPU encounters a breakpoint instruction in the code. This instruction is typically inserted by developers during debugging to halt the program execution at a specific point so that they can inspect the program state and variables. The code "80000003" is a hexadecimal representation of the exception code, which indicates the type of exception that occurred. In this case, it is a first chance exception, which means that the exception was caught by the debugger before it caused any harm to the program. To troubleshoot this error, you can try the following steps: 1. Check if any debugging tools or breakpoints are active in your code. If yes, disable them and see if the error still occurs. 2. Check if any third-party software or drivers are interfering with your program's execution. You can try disabling them one by one and see if the error goes away. 3. If the error persists, you may need to analyze the program's code and identify the specific instruction that is causing the exception. You can use a debugger or a code analysis tool for this purpose. 4. Once you have identified the problematic instruction, you can try fixing the code or updating any related libraries or dependencies. It is recommended to seek assistance from a qualified professional or the software vendor in case you are not comfortable with the above steps.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值