【发布时间】:2011-09-27 11:34:35
【问题描述】:
我有一个问题,在调用第 3 方库例程期间我的进程终止。我完全无法在我的调试器中捕捉到这一点。这可能与这个问题有关:How can I debug a win32 process that unexpectedly terminates silently?。
当我跳过对该库的调用时,正在调试的进程简单地终止。如果此终止是由于未处理的异常或内存访问冲突,调试器将捕获它。所以我最好的猜测是进程以某种方式正常终止。
我尝试过的:
- 在
ExitThread和ExitProcess上设置断点 - 为未处理的异常和无效参数设置处理程序(
set_terminate和_set_invalid_parameter_handler) - 更改
_set_abort_behavior和_set_error_mode。 - 指示调试器停止执行所有抛出的异常。
但无济于事,没有调用任何处理程序,也没有触发断点。
我所观察到的: 当进程崩溃时,我在调试输出窗口中看到两件事:
-
不相关(请参阅下面的更新)
我看到EEFileLoadException被抛出。这个异常的快速谷歌并没有给我一个明确的答案来解释这个异常的含义。First-chance exception at 0x7656b9bc (KernelBase.dll) in Program.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x0030b5ac.. First-chance exception at 0x7656b9bc (KernelBase.dll) in Program.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.. First-chance exception at 0x7656b9bc (KernelBase.dll) in Program.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.. First-chance exception at 0x7656b9bc (KernelBase.dll) in Program.exe: 0xE0434352: 0xe0434352. -
终止时,所有线程都返回相同的错误代码 (STATUS_INVALID_CRUNTIME_PARAMETER)。 据我所知,此错误代码意味着其中一个 c 运行时函数收到了无效参数,并且出于安全原因终止了应用程序。
The thread 'Win32 Thread' (0x12c0) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0xe04) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x53c) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x116c) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x16e0) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x1420) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x13c4) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x40c) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0xc78) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0xd88) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x16c8) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0xcb8) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x584) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x1164) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x1550) has exited with code -1073740777 (0xc0000417). The thread 'Win32 Thread' (0x474) has exited with code -1073740777 (0xc0000417). The program '[5140] Program.exe: Native' has exited with code -1073740777 (0xc0000417).
我真正想知道的是什么导致了这种情况,并且可以选择;我怎样才能在调试器中捕捉到这个?
更新
关于EEFileLoadException,实际上是在程序调用导致它终止之前抛出的,所以它与进程的终止无关。
更新
我刚刚读到set_terminate 在调试器中不起作用,所以这是不可能的。正如我在评论中指出的那样,处理程序是按线程管理的,因此我无权访问相关的处理程序。
此外,程序很可能在我无法访问的工作线程中崩溃,因此很难设置任何断点/处理程序。
有没有更好的方法来找出问题所在?
【问题讨论】:
-
我意识到终止处理程序没有被调用,因为它们是基于每个线程安装的,我无法访问崩溃线程。
-
我遇到了与此类似的情况,但在我的情况下,TRACE 消息也没有传递到输出窗口。当我改为附加 WinDebug 时,我发现有一个
DebugBreak()调用被 VS 忽略,这导致进程到terminate()本身,导致The program [0x2F74] 'OUTLOOK.EXE' has exited with code -1073740777 (0xc0000417).不幸的是,我无法弄清楚为什么 Visual Studio 忽略了它应该正在调试的程序。
标签: visual-studio-2010 debugging winapi