[PyQt] QMutex deadlock during QObject destructor

Luke Campagnola lcampagn at email.unc.edu
Sat Apr 16 04:45:15 BST 2011


I have a multi-threaded application that locks up periodically while drawing
graphics. The application is quite large and due to the randomness of the
lockup (usually takes between 10 minutes and 10 hours), I have not been able
to work out the exact cause. I do believe that all GUI calls are being
correctly restricted to the main thread. Below is a partial stack trace
collected while locked. Notably, the lockup occurs in the destructor for
some QObject following a QTimer single-shot signal.

The application displays live video from a camera, and as far as I can tell,
the only objects being deleted would be related to 1) signals being sent as
new camera frames arrive, 2) QTimer signals that drive the video display,
and 3) QImage/QPixmap pairs that are used to update a QGraphicsPixmapItem.

If anyone can offer clues as to what might cause this, I would be most


(gdb) backtr

#0  0x0012d422 in __kernel_vsyscall ()

#1  0x00138015 in pthread_cond_wait@@GLIBC_2.3.2 () from

#2  0x015038c2 in QMutexPrivate::wait (this=0x8f70bc0, timeout=-1) at

#3  0x014ff072 in QMutex::lock (this=0x8f70bb0) at thread/qmutex.cpp:205

#4  0x0161d150 in QOrderedMutexLocker::relock (this=0x940a890,
__in_chrg=<value optimized out>)


#5  ~QObject (this=0x940a890, __in_chrg=<value optimized out>) at

#6  0x01d96eaf in PyQtProxy::~PyQtProxy() () from

#7  0x01d957f9 in PyQtProxy::unislot(void**) () from

#8  0x01d958a5 in PyQtProxy::qt_metacall(QMetaObject::Call, int, void**) ()
from /usr/lib/pymodules/python2.6/PyQt4/QtCore.so

#9  0x0160bc9a in QMetaObject::metacall (object=0x940a890, cl=128, idx=5,
argv=0xbfffe75c) at kernel/qmetaobject.cpp:237

#10 0x0161a3d5 in QMetaObject::activate (sender=0x914aff8, m=0x1719188,
local_signal_index=0, argv=0x0) at kernel/qobject.cpp:3293

#11 0x01621fe7 in QSingleShotTimer::timeout (this=0x914aff8) at

#12 0x016220fc in QSingleShotTimer::timerEvent (this=0x914aff8) at

#13 0x01617254 in QObject::event (this=0x914aff8, e=0xd) at

#14 0x00b574dc in QApplicationPrivate::notify_helper (this=0x8a49dd0,
receiver=0x914aff8, e=0xbfffec80) at kernel/qapplication.cpp:4300

#15 0x00b5e05e in QApplication::notify (this=0x8a3b860, receiver=0x914aff8,
e=0xbfffec80) at kernel/qapplication.cpp:3704

#16 0x008381d7 in sipQApplication::notify (this=0x8a3b860, a0=0x914aff8,
a1=0xbfffec80) at sipQtGuipart9.cpp:18539

#17 0x01606a3b in QCoreApplication::notifyInternal (this=0x8a3b860,
receiver=0x914aff8, event=0xbfffec80) at kernel/qcoreapplication.cpp:704

#18 0x01635d66 in QCoreApplication::sendEvent (this=0x8b2c784) at

#19 QTimerInfoList::activateTimers (this=0x8b2c784) at

#20 0x01632917 in timerSourceDispatch (source=0x8b2c7b8) at

#21 idleTimerSourceDispatch (source=0x8b2c7b8) at

#22 0x018b35e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0

#23 0x018b72d8 in ?? () from /lib/libglib-2.0.so.0

#24 0x018b74b8 in g_main_context_iteration () from /lib/libglib-2.0.so.0

#25 0x016325d5 in QEventDispatcherGlib::processEvents (this=0x8b29948,
flags=...) at kernel/qeventdispatcher_glib.cpp:412

#26 0x00c17135 in QGuiEventDispatcherGlib::processEvents (this=0x8b29948,
flags=...) at kernel/qguieventdispatcher_glib.cpp:204

#27 0x01605059 in QEventLoop::processEvents (this=0xbfffef44, flags=DWARF-2
expression error: DW_OP_reg operations must be used either alone or in
conjuction with DW_OP_piece.

) at kernel/qeventloop.cpp:149

#28 0x016054aa in QEventLoop::exec (this=0xbfffef44, flags=...) at

#29 0x0160969f in QCoreApplication::exec () at

#30 0x00b57577 in QApplication::exec () at kernel/qapplication.cpp:3579
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110415/e60352fb/attachment-0001.html>

More information about the PyQt mailing list