我正在Python 3.5
编写一个程序,并使用PyQt4
来执行所有GUI功能。当我运行程序时,有时会出现分段错误。我在网上查找了解决方案,找到了使用gdb
的{{3}}。
我尝试以这种方式运行我的程序,但不知道如何读取输出。有人可以给我一个提示吗?
输出:
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)
答案 0 :(得分:1)
嗯,提示:您所看到的是调用堆栈。
你肯定知道自己是程序员,调用函数(或方法)需要将调用的上下文(参数,局部变量,返回地址)添加到内存中称为堆栈的区域。
因此,当您发生细分错误时,您会看到您的代码(以及不属于您的代码)所做的调用以及尚未返回的调用。由于您的流程遇到了段错误,它没有继续执行或“放松”#34;堆栈 - 它只是倾倒了所有的帧。 (并注意框架从最深到最浅列出。)
幸运的是,大多数堆栈帧都具有正在运行的函数的名称,因此您可以更好地确定在有问题的段中您访问内存的确切位置。不幸的是,堆栈跟踪似乎没有行号(这些都是??
s的所有对),因此除了对函数的调用之外,你无法精确定位它。构成下一个堆栈框架。也不幸的是 - 看起来大多数/所有这些名称都是PyQT或QT或Python的内置函数,而不是你自己的函数(尽管我可能在这里错了,尤其是如果你已经超负荷了 - 这也使得你更难以弄清楚你导致这些段错误的位置 - 因为你可能设置了一些值,以后的情况下会出现这样的代码:&#39;不是你的无效访问。
答案 1 :(得分:1)
有人可以给我一个提示吗?
当你在第三方代码中看到像libQtGui.so崩溃时,在这种情况下,有必要谷歌堆栈跟踪的顶部部分,希望找到相关的已报告错误,你可以找到更新的变通方法或版本号到。
在这种情况下,Google搜索QWidgetPrivate::syncBackingStore
导致此错误https://bugreports.qt.io/browse/QTBUG-41428与另一个错误https://bugreports.qt.io/browse/QTBUG-41108重复。虽然它是针对Mac OS报告的,但它也可能与x86_64-linux-gnu
相关。