[PyQt] Segmentation fault
hao yin
hao.yin.1986 at gmail.com
Sun Jan 17 11:35:34 GMT 2010
Hello,
I've wrote a program in pyqt4, that should redirect the output of another
program to a QTextEdit. Sometime the program crashes as soon as I start a
thread executing the second program with subprocess.Popen().
I used gdb:
(gdb) run TestThread.py
Starting program: /usr/bin/python TestThread.py
[Thread debugging using libthread_db enabled]
[New Thread 0xb7f036c0 (LWP 5001)]
[New Thread 0xb5a69b90 (LWP 5003)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7f036c0 (LWP 5001)]
0xb6be8802 in ?? () from /usr/lib/libQtGui.so.4
(gdb) bt
#0 0xb6be8802 in ?? () from /usr/lib/libQtGui.so.4
#1 0xb6be12a5 in ?? () from /usr/lib/libQtGui.so.4
#2 0xb6be1b32 in QTextEngine::itemize () from /usr/lib/libQtGui.so.4
#3 0xb6be93c8 in QTextLayout::beginLayout () from /usr/lib/libQtGui.so.4
#4 0xb6c296eb in ?? () from /usr/lib/libQtGui.so.4
#5 0xb6c3039f in ?? () from /usr/lib/libQtGui.so.4
#6 0xb6c2ec7a in ?? () from /usr/lib/libQtGui.so.4
#7 0xb6c2f186 in ?? () from /usr/lib/libQtGui.so.4
#8 0xb6c3166c in ?? () from /usr/lib/libQtGui.so.4
#9 0xb6c31710 in ?? () from /usr/lib/libQtGui.so.4
#10 0xb6c31902 in ?? () from /usr/lib/libQtGui.so.4
#11 0xb6c31d41 in ?? () from /usr/lib/libQtGui.so.4
#12 0xb6bfede5 in QTextDocument::setPageSize () from /usr/lib/libQtGui.so.4
#13 0xb6e39523 in ?? () from /usr/lib/libQtGui.so.4
#14 0xb6e39d92 in QTextEdit::resizeEvent () from /usr/lib/libQtGui.so.4
#15 0xb73dfe3b in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#16 0xb69d8956 in QWidget::event () from /usr/lib/libQtGui.so.4
#17 0xb6db2993 in QFrame::event () from /usr/lib/libQtGui.so.4
#18 0xb6e5294f in QAbstractScrollArea::viewportEvent ()
from /usr/lib/libQtGui.so.4
#19 0xb73dd2fc in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#20 0xb6e54f55 in ?? () from /usr/lib/libQtGui.so.4
#21 0xb7bcdc5a in QCoreApplicationPrivate::sendThroughObjectEventFilters ()
---Type <return> to continue, or q <return> to quit---
from /usr/lib/libQtCore.so.4
#22 0xb6981e7a in QApplicationPrivate::notify_helper ()
from /usr/lib/libQtGui.so.4
#23 0xb698a282 in QApplication::notify () from /usr/lib/libQtGui.so.4
#24 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#25 0xb7bcea3b in QCoreApplication::notifyInternal ()
from /usr/lib/libQtCore.so.4
#26 0xb6a181b6 in QWidgetPrivate::setGeometry_sys ()
from /usr/lib/libQtGui.so.4
#27 0xb69d7788 in QWidget::setGeometry () from /usr/lib/libQtGui.so.4
#28 0xb6e52f08 in QAbstractScrollAreaPrivate::layoutChildren ()
from /usr/lib/libQtGui.so.4
#29 0xb6e5363e in QAbstractScrollArea::event () from /usr/lib/libQtGui.so.4
#30 0xb6e3cd0e in QTextEdit::event () from /usr/lib/libQtGui.so.4
#31 0xb73def2d in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#32 0xb6981e9c in QApplicationPrivate::notify_helper ()
from /usr/lib/libQtGui.so.4
#33 0xb698a282 in QApplication::notify () from /usr/lib/libQtGui.so.4
#34 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#35 0xb7bcea3b in QCoreApplication::notifyInternal ()
from /usr/lib/libQtCore.so.4
#36 0xb69d7540 in QWidget::setContentsMargins () from /usr/lib/libQtGui.so.4
#37 0xb6db268c in QFrame::setFrameRect () from /usr/lib/libQtGui.so.4
---Type <return> to continue, or q <return> to quit---
#38 0xb6e532ee in QAbstractScrollAreaPrivate::layoutChildren ()
from /usr/lib/libQtGui.so.4
#39 0xb6e533bd in QAbstractScrollAreaPrivate::_q_showOrHideScrollBars ()
from /usr/lib/libQtGui.so.4
#40 0xb6e399d5 in ?? () from /usr/lib/libQtGui.so.4
#41 0xb6e3b61f in QTextEdit::qt_metacall () from /usr/lib/libQtGui.so.4
#42 0xb73e0020 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#43 0xb7be4ca8 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#44 0xb7be5932 in QMetaObject::activate () from /usr/lib/libQtCore.so.4
#45 0xb6bce7a3 in QTextControl::documentSizeChanged ()
from /usr/lib/libQtGui.so.4
#46 0xb6bd5547 in QTextControl::qt_metacall () from /usr/lib/libQtGui.so.4
#47 0xb7bdd8fb in QMetaCallEvent::placeMetaCall () from
/usr/lib/libQtCore.so.4
#48 0xb7bdf3a0 in QObject::event () from /usr/lib/libQtCore.so.4
#49 0xb6bce514 in QTextControl::event () from /usr/lib/libQtGui.so.4
#50 0xb6981e9c in QApplicationPrivate::notify_helper ()
from /usr/lib/libQtGui.so.4
#51 0xb698a19e in QApplication::notify () from /usr/lib/libQtGui.so.4
#52 0xb76593f3 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#53 0xb7bcea3b in QCoreApplication::notifyInternal ()
from /usr/lib/libQtCore.so.4
#54 0xb7bcf695 in QCoreApplicationPrivate::sendPostedEvents ()
from /usr/lib/libQtCore.so.4
---Type <return> to continue, or q <return> to quit---
#55 0xb7bcf88d in QCoreApplication::sendPostedEvents ()
from /usr/lib/libQtCore.so.4
#56 0xb7bfa7ef in ?? () from /usr/lib/libQtCore.so.4
#57 0xb78f8b88 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#58 0xb78fc0eb in ?? () from /usr/lib/libglib-2.0.so.0
#59 0xb78fc268 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#60 0xb7bfa438 in QEventDispatcherGlib::processEvents ()
from /usr/lib/libQtCore.so.4
#61 0xb6a23365 in ?? () from /usr/lib/libQtGui.so.4
#62 0xb7bcd06a in QEventLoop::processEvents () from /usr/lib/libQtCore.so.4
#63 0xb7bcd4aa in QEventLoop::exec () from /usr/lib/libQtCore.so.4
#64 0xb7bcf959 in QCoreApplication::exec () from /usr/lib/libQtCore.so.4
#65 0xb6981d17 in QApplication::exec () from /usr/lib/libQtGui.so.4
#66 0xb7659ef6 in ?? () from /usr/lib/python2.6/dist-packages/PyQt4/QtGui.so
#67 0x080de562 in PyEval_EvalFrameEx (f=0x9ff689c, throwflag=0)
at ../Python/ceval.c:3706
#68 0x080e00b8 in PyEval_EvalCodeEx (co=0xb7ea9260, globals=0xb7ee70b4,
locals=0xb7ee70b4, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0,
defcount=0, closure=0x0) at ../Python/ceval.c:2968
#69 0x080e0217 in PyEval_EvalCode (co=0xb7ea9260, globals=0xb7ee70b4,
locals=0xb7ee70b4) at ../Python/ceval.c:522
#70 0x080fe0e1 in PyRun_FileExFlags (fp=0x9ffbfa8,
filename=0xbf8f4a3a "TestThread.py", start=257, globals=0xb7ee70b4,
---Type <return> to continue, or q <return> to quit---
locals=0xb7ee70b4, closeit=1, flags=0xbf8f2938)
at ../Python/pythonrun.c:1335
#71 0x080fe43a in PyRun_SimpleFileExFlags (fp=0x9ffbfa8,
filename=0xbf8f4a3a "TestThread.py", closeit=1, flags=0xbf8f2938)
at ../Python/pythonrun.c:931
#72 0x0805c882 in Py_Main (argc=1, argv=0xbf8f2a04) at ../Modules/main.c:599
#73 0x0805b972 in main (argc=127, argv=0x0) at ../Modules/python.c:23
here is the code, that reproduce the error:
import time, sys, os, subprocess, select, threading
from PyQt4 import QtCore, QtGui
class TestGUI(QtGui.QWidget):
def __init__(self, parent = None):
QtGui.QWidget.__init__(self, parent)
self.Widgets()
self.Connections()
def Widgets(self):
self.txtBox = QtGui.QTextEdit()
self.btnStart = QtGui.QPushButton("Start Thread")
self.txtBox.setReadOnly(True)
hb = QtGui.QHBoxLayout()
hb.addWidget(self.txtBox)
hb.addWidget(self.btnStart)
self.setLayout(hb)
def Connections(self):
self.connect(self.btnStart, QtCore.SIGNAL("clicked()"),
self.startThread)
def startThread(self):
self.thread = TestThread(self, cmd = ["ls", "/home/hao"], box =
self.txtBox)
self.thread.start()
self.btnStart.setDisabled(True)
class TestThread(threading.Thread):
def __init__(self, parent, cmd = None, box = None):
threading.Thread.__init__(self)
self.cmd = cmd
self.box = box
def run(self):
self.prog = subprocess.Popen(self.cmd, bufsize = 1, stdout =
subprocess.PIPE, stderr = subprocess.STDOUT)
self.rFile = select.select([self.prog.stdout], [], [], 3600)
line = ""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100117/95bcf202/attachment-0001.html>
More information about the PyQt
mailing list