我的一个程序 [1] 102255 segmentation fault (core dumped) ./nethack
之后我用 gdb
调试,之后是这个样子的
➜ games gdb -exec=/home/xue/nh/install/games/lib/nethackdir/nethack -core=/var/crash/core-nethack-102255-1647621470
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
[New LWP 102255]
[New LWP 102260]
[New LWP 102259]
[New LWP 102264]
[New LWP 102261]
[New LWP 102262]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/home/xue/nh/install/games/lib/nethackdir/nethack'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fd49e5f348d in QDialog::setVisible(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
[Current thread is 1 (Thread 0x7fd49a067800 (LWP 102255))]
(gdb) where
#0 0x00007fd49e5f348d in QDialog::setVisible(bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#1 0x00007fd49e5f1445 in QDialog::~QDialog() () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#2 0x000055695e3b3fa0 in ()
#3 0x000055695f094a10 in ()
#4 0x000055695f094a10 in ()
#5 0x000055695f74cd40 in ()
#6 0x00007fff46bef5f0 in ()
#7 0x00007fd49e9046a8 in vtable for QDialog () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#8 0x000055695fcbe490 in ()
#9 0x00007fd49e904880 in vtable for QDialog () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#10 0x0000000000000000 in ()
在这里我输入where之后返回如上,但是我复制下来之后谷歌没有结果
所以似乎出问题的是我的 libQt5Widgets.so.5
这个文件,但是我接下来应该怎么做呢?
没有定位对应的代码片段的话也没有办法下断点
gdb 只是告诉你程序最后的崩点在 QDialog::setVisible,可能是 QDialog 的句柄已经被释放了,你又拿来调用了 setVisible。具体位置你应该用 bt 命令查看一下调用堆栈,看看到底是哪里调用了这个 setVisible,然后看看是否使用了已释放的 QDialog 句柄。