如何閱讀gdb輸出

2024-05-15 04:30:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用Python 3.5编写一个程序,并对所有GUI函数使用PyQt4。当我运行这个程序时,我有时会遇到分割错误。我在网上寻找解决方案,找到了this,它使用gdb。在

我试着用这种方式运行程序,但不知道如何读取输出。谁能给我个提示吗?在

输出:

gdb python3
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 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"...
Reading symbols from python3...(no debugging symbols found)...done.
(gdb) run GUI3.py 
Starting program: /usr/bin/python3 GUI3.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff3ad0700 (LWP 26031)]
[New Thread 0x7ffff12cf700 (LWP 26032)]
[New Thread 0x7fffeeace700 (LWP 26033)]
[New Thread 0x7fffd3da2700 (LWP 26034)]
[New Thread 0x7fffd2042700 (LWP 26035)]
[New Thread 0x7fffd1841700 (LWP 26036)]
[New Thread 0x7fffd1040700 (LWP 26037)]
[New Thread 0x7fffbb952700 (LWP 26038)]
Run function needs to be implemented

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
QWidgetBackingStore::sync (this=0x1ec5d30) at painting/qbackingstore.cpp:1239
1239    painting/qbackingstore.cpp: No such file or directory.
(gdb) backtrace 
#0  QWidgetBackingStore::sync (this=0x1ec5d30) at painting/qbackingstore.cpp:1239
#1  0x00007fffe0e11c50 in QWidgetPrivate::syncBackingStore (this=0x1907c20)
at kernel/qwidget.cpp:1894
#2  0x00007fffe0e249b8 in QWidget::event (this=this@entry=0x1b3b380, event=event@entry=0x20bab70)
at kernel/qwidget.cpp:8693
#3  0x00007fffe12089b3 in QMainWindow::event (this=0x1b3b380, event=0x20bab70)
at widgets/qmainwindow.cpp:1478
#4  0x00007fffe1cfc28b in ?? ()
   from /usr/lib/python3/dist-packages/PyQt4/QtGui.cpython-35m-x86_64-linux-gnu.so
#5  0x00007fffe0dcdfdc in QApplicationPrivate::notify_helper (this=this@entry=0x18f9d70, 
receiver=receiver@entry=0x1b3b380, e=e@entry=0x20bab70) at kernel/qapplication.cpp:4570
#6  0x00007fffe0dd4f16 in QApplication::notify (this=0x17de970, receiver=0x1b3b380, e=0x20bab70)
at kernel/qapplication.cpp:4356
#7  0x00007fffe1ebc0c6 in ?? ()
   from /usr/lib/python3/dist-packages/PyQt4/QtGui.cpython-35m-x86_64-linux-gnu.so
#8  0x00007fffe2eb390d in QCoreApplication::notifyInternal (this=0x17de970, 
receiver=receiver@entry=0x1b3b380, event=event@entry=0x20bab70)
at kernel/qcoreapplication.cpp:955
#9  0x00007fffe2eb73c6 in QCoreApplication::sendEvent (event=0x20bab70, receiver=0x1b3b380)
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#10 QCoreApplicationPrivate::sendPostedEvents (receiver=receiver@entry=0x0, 
event_type=event_type@entry=0, data=0x18fc490) at kernel/qcoreapplication.cpp:1579
#11 0x00007fffe2eb76a3 in QCoreApplication::sendPostedEvents (receiver=receiver@entry=0x0, 
event_type=event_type@entry=0) at kernel/qcoreapplication.cpp:1472
#12 0x00007fffe2ee413e in QCoreApplication::sendPostedEvents ()
at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#13 postEventSourceDispatch (s=0x1900aa0) at kernel/qeventdispatcher_glib.cpp:300
#14 0x00007fffe2a62197 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#15 0x00007fffe2a623f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007fffe2a6249c in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007fffe2ee42ae in QEventDispatcherGlib::processEvents (this=0x17be390, flags=...)
at kernel/qeventdispatcher_glib.cpp:450
#18 0x00007fffe0e7b616 in QGuiEventDispatcherGlib::processEvents (this=<optimised out>, flags=...)
at kernel/qguieventdispatcher_glib.cpp:204
#19 0x00007fffe2eb218f in QEventLoop::processEvents (this=this@entry=0x7fffffffd7d0, flags=...)
at kernel/qeventloop.cpp:149
#20 0x00007fffe2eb24f5 in QEventLoop::exec (this=this@entry=0x7fffffffd7d0, flags=...)
at kernel/qeventloop.cpp:204
#21 0x00007fffe2eb84b9 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1227
#22 0x00007fffe1e6aa2b in ?? ()
    from /usr/lib/python3/dist-packages/PyQt4/QtGui.cpython-35m-x86_64-linux-gnu.so
#23 0x00000000004e9b7f in PyCFunction_Call ()
#24 0x00000000005372f4 in PyEval_EvalFrameEx ()
#25 0x0000000000540199 in ?? ()
#26 0x0000000000540e4f in PyEval_EvalCode ()
#27 0x000000000060c272 in ?? ()
#28 0x000000000060e71a in PyRun_FileExFlags ()
#29 0x000000000060ef0c in PyRun_SimpleFileExFlags ()
#30 0x000000000063fb26 in Py_Main ()
#31 0x00000000004cfeb1 in main ()
(gdb) 

Tags: ingnueventnewlinuxthiskernelthread
2条回答

Could anyone please give me a hint?

当你看到第三方代码崩溃时libQtGui.so在这种情况下,google栈跟踪的顶部是值得的,希望能找到相关的已经报告的bug,在那里您可以找到解决方法或更新到的版本号。在

在本例中,google QWidgetPrivate::syncBackingStore导致了这个bug https://bugreports.qt.io/browse/QTBUG-41428,它是另一个bug https://bugreports.qt.io/browse/QTBUG-41108的重复。尽管有报道称它是针对Mac操作系统的,但它也可能与x86_64-linux-gnu有关。在

好吧,一个提示:您看到的是调用堆栈。在

作为一个程序员,调用函数(或方法)涉及到将调用的上下文(参数、局部变量、返回地址)添加到内存中称为堆栈的区域。在

因此,您看到的是当分段错误发生时,您的代码(以及不是您的代码)所做的调用(以及尚未返回的调用)。当您的进程得到segfault时,它不会继续执行或“展开”堆栈-它只是转储所有帧。(请注意,框架是从最深到最浅列出的。)

幸运的是,大多数堆栈帧都有运行的函数的名称,因此您可以更好地确定在有问题的段中访问内存的确切位置。不幸的是,堆栈跟踪似乎没有行号(这些行号都是??)的对,因此除了对中构成下一个堆栈帧的函数的调用之外,您无法真正确定它。对您来说也很不幸-看起来大多数/所有这些名称都是PyQT、QT或Python的内置函数,而不是您自己的函数(尽管我在这里可能错了,尤其是如果你超载了)-这也使你更难找出是什么原因导致了这些段错误-因为你可能已经设置了一些值,这些值后来会使不属于你的代码进行无效访问。在

相关问题 更多 >

    热门问题