首页 > 解决方案 > 为什么 gdb 会抛出内部错误并告诉我有错误?

问题描述

我正在尝试调试一个简单的程序,但 gdb 正在运行。我得到内部错误,然后 gdb 说有一个错误。当我尝试停止正在运行的程序时会发生这种情况。发送键盘中断返回调试器后,我尝试使用quit. 但是当我这样做时,我得到了这个(我还包括当我完成问题时会发生什么):

A debugging session is active.

    Inferior 1 [process 1239] will be killed.

Quit anyway? (y or n) y
../../gdb/target.c:2149: internal-error: void target_mourn_inferior(ptid_t): Assertion `ptid == inferior_ptid' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

../../gdb/target.c:2149: internal-error: void target_mourn_inferior(ptid_t): Assertion `ptid == inferior_ptid' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) y
Abort trap: 6 (core dumped)

有人可以告诉我发生了什么,为什么会发生,以及如何解决它吗?

标签: cgdb

解决方案


有人能告诉我发生了什么吗

GDB 已经告诉过你:

This is a bug, please report it.  For instructions, see:
<https://www.gnu.org/software/gdb/bugs/>.

如果一个程序曾经报告它本身有一个错误,那么它总是正确的。即使它认为的行为实际上不是错误的,那么程序也是错误的。

在这种特殊情况下,GDB 在自己的代码中报告断言失败。这绝对是一个实现错误,而不是错误报告错误。

为什么会这样

它可能是由正在调试的程序的一些不寻常的事情触发的——这本身可能是错误的——但这并不能使它成为 GDB 错误。

以及如何解决它?

您不太可能自己修复 gdb 错误,但可能存在您可以升级到的更新版本,其中错误已得到修复。


推荐阅读