GDB 调试器:检测到 GDB 的内部问题

GDB Debugger: An internal issue to GDB has been detected

我是 GNU 调试器的新手。我一直在玩弄它,调试汇编文件 (x86_64 Linux) 一天左右,就在几个小时前,我 ''discovered'' TUI 界面。

我第一次尝试使用 TUI 界面是为了在执行一个简单的 Hello World 程序(在 asm 中)时查看寄存器的变化。这是程序的代码

section .data
        text db "Hello, World!", 10
        len equ $-text
section .text

        global _start

_start:

        nop

        call _printText

        mov rax, 60
        mov rdi, 0
        syscall

_printText:

        nop

        mov rax, 1
        mov rdi, 1
        mov rsi, text
        mov rdx, len
        syscall
        ret

在 linux 的终端创建可执行文件后,我写

$ gdb -q ./hello -tui

然后我创建了三个断点:一个在 _start 的右侧,另一个在 _printText 之后,最后一个在 SYS_EXITmov rax, 60 上方。

之后:

1) 我运行程序。

2)在gdb模式下我写layout asm看写的代码。

3) 我写layout regs.

4) 最后我使用 stepi 来查看寄存器如何根据编写的 hello world 程序进行更改。

问题是,当 RIP 寄存器指向 ret 的地址时,对应于 SYS_EXIT 并且我点击 Enter 我在控制台中收到以下消息

[Inferior 1 (process 2059) exited normally]
/build/gdb-cXfXJ3/gdb-7.11.1/gdb/thread.c:1100: internal-error: finish_thread_st
ate: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)

如果我输入 n 它会出现这个(正如它所说,如果我输入 y 它会退出):

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

    /build/gdb-cXfXJ3/gdb-7.11.1/gdb/thread.c:1100: internal-error: finish_thread_st
    ate: Assertion `tp' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Create a core file of GDB? (y or n) 

因为我不知道GDB的核心文件是什么(以及有什么用),所以我输入n然后调试会话关闭。

有谁知道为什么会发生这种情况以及如何解决?

顺便说一句,我也是 Assembly 的新手,所以如果由于程序中的错误而发生这种情况,如果有人能指出这一点,我也将不胜感激。

Does anyone know why this is happening

这是因为 GDB 中存在错误(更准确地说,GDB 内部变量 tp 不是 NULL 的断言已被违反)。

and how can be fixed?

您应该尝试使用当前版本的 GDB 重现此问题(错误可能已经修复),并提交错误报告(如消息告诉您的那样)。

I don't know what a core file of GDB (and what is useful for),

它只对 GDB 开发人员有用。

我使用与您相同的 GDB 版本,并且我一直使用 TUI 功能;但我从来没有遇到过这个问题。但是,当我使用您的代码时,会发生内部 GDB 错误。但是,如果我对您的 write syscall 函数进行了更改,则错误不会出现。

虽然您没有从一个函数中调用另一个函数,但我通常通过在我的 x86 中至少包含 "push rbp"、"mov rbp, rsp" 和 "leave" 指令来创建堆栈帧-64 函数调用。这可能是一种创可贴或针对 "bug" 的变通方法。

_printText:
        push rbp
        mov rbp, rsp
        mov rax, 1
        mov rdi, 1
        mov rsi, text
        mov rdx, len
        syscall
        leave
        ret