为什么 gdb 抛出内部错误并告诉我有错误?

Why is gdb throwing internal errors and telling me that there is a bug?

我正在尝试调试一个简单的程序,但 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)

谁能告诉我这是怎么回事,为什么会这样,如何解决?

what is going on

您的 GDB 版本存在错误。

why it's happening

GDB 是一个程序。程序有错误。你设法击中了其中一​​个。也许 this one?

and how to fix it please?

如果您使用的是 MacOS,请使用演示此行为的最简单程序更新上述错误,希望一些 GDB 开发人员会尽快修复该错误。

Can someone tell me what is going on

GDB已经告诉你了:

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

如果一个程序报告说它本身有错误,那么它总是正确的。即使它认为是 buggy 的行为实际上不是,那么程序就是 buggy 否则的话。

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

why it's happening

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

and how to fix it please?

您不太可能自己修复 gdb 错误,但可能有一个您可以升级到的更新版本,其中错误已被修复。