[PyQt] segfault when using Qt.QueuedConnection

Erik Janssens Erik.Janssens at conceptive.be
Thu Aug 25 16:18:13 BST 2011


Hi,

After lots of tries I have been able to get a stacktrace
+ core of a segfault that I believe occurs from time to time.

The attached stacktrace shows the segfault is inside the QT
event loop, without even involving Python.

What I believe that happens is this :

1) A signal is connected to a slot with a queued connection.

2) within PyQtProxy::unislot, the sender() mehtod is
   called on a QObject

3) the documentation of sender() however states that the
   returned pointer is only valid if the sending object has
   not been deleted yet.

I think the segfault occurs because sometimes this object
has been deleted allready, and thus the casting of the 
sender object to its type segfaults the application sometimes.

Best regards and thanks for any view on this.

Erik
-------------- next part --------------
#0  0x00000000 in ?? ()
#1  0x01066baf in QMetaObject::cast (this=0xe22c04, obj=0x9ba5ce8) at kernel/qmetaobject.cpp:266
#2  0x00d929b1 in qobject_cast<PyQtShortcircuitSignalProxy*> (object=0x9ba5ce8) at ../../../install/include/QtCore/qobject.h:366
#3  0x00d91e70 in PyQtProxy::unislot (this=0xa4d5718, qargs=0xb565fb60) at qpycore_pyqtproxy.cpp:406
#4  0x00d91e08 in PyQtProxy::qt_metacall (this=0xa4d5718, _c=QMetaObject::InvokeMetaMethod, _id=1, _a=0xb565fb60) at qpycore_pyqtproxy.cpp:380
#5  0x01066b92 in QMetaObject::metacall (object=0xa4d5718, cl=QMetaObject::InvokeMetaMethod, idx=5, argv=0xb565fb60) at kernel/qmetaobject.cpp:237
#6  0x0107596b in QMetaCallEvent::placeMetaCall (this=0xb565fd30, object=0xa4d5718) at kernel/qobject.cpp:535
#7  0x010773e3 in QObject::event (this=0xa4d5718, e=0xb565fd30) at kernel/qobject.cpp:1217
#8  0x0135c27a in QApplicationPrivate::notify_helper (this=0x8a13790, receiver=0xa4d5718, e=0xb565fd30) at kernel/qapplication.cpp:4462
#9  0x01359c40 in QApplication::notify (this=0x86c5760, receiver=0xa4d5718, e=0xb565fd30) at kernel/qapplication.cpp:3862
#10 0x07735f02 in sipQApplication::notify (this=0x86c5760, a0=0xa4d5718, a1=0xb565fd30) at sipQtGuiQApplication.cpp:317
#11 0x0105f178 in QCoreApplication::notifyInternal (this=0x86c5760, receiver=0xa4d5718, event=0xb565fd30) at kernel/qcoreapplication.cpp:731
#12 0x00d3079f in QCoreApplication::sendEvent (receiver=0xa4d5718, event=0xb565fd30) at /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/include/QtCore/qcoreapplication.h:215
#13 0x0106018c in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x8940ce0) at kernel/qcoreapplication.cpp:1372
#14 0x0105fe83 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=0) at kernel/qcoreapplication.cpp:1265
#15 0x00d307d2 in QCoreApplication::sendPostedEvents () at /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/include/QtCore/qcoreapplication.h:220
#16 0x01096958 in postEventSourceDispatch (s=0x8a15388) at kernel/qeventdispatcher_glib.cpp:277
#17 0x003d8855 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#18 0x003dc668 in ?? () from /lib/libglib-2.0.so.0
#19 0x003dc848 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#20 0x010979d8 in QEventDispatcherGlib::processEvents (this=0x8a13908, flags=...) at kernel/qeventdispatcher_glib.cpp:422
#21 0x0142ee2e in QGuiEventDispatcherGlib::processEvents (this=0x8a13908, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#22 0x0105c557 in QEventLoop::processEvents (this=0xbfbf697c, flags=...) at kernel/qeventloop.cpp:149
#23 0x0105c69c in QEventLoop::exec (this=0xbfbf697c, flags=...) at kernel/qeventloop.cpp:201
#24 0x0105f801 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1008
#25 0x013598fa in QApplication::exec () at kernel/qapplication.cpp:3736
#26 0x0773a871 in meth_QApplication_exec_ (sipArgs=0xb783202c) at sipQtGuiQApplication.cpp:2266
#27 0x00a69ba2 in PyCFunction_Call (func=0x8ef72cc, arg=0xb783202c, kw=0x0) at Objects/methodobject.c:81
#28 0x00ace901 in call_function (f=0x8f4725c, throwflag=0) at Python/ceval.c:4012
#29 PyEval_EvalFrameEx (f=0x8f4725c, throwflag=0) at Python/ceval.c:2665
#30 0x00aced7f in fast_function (f=0x8a135e4, throwflag=0) at Python/ceval.c:4098
#31 call_function (f=0x8a135e4, throwflag=0) at Python/ceval.c:4033
#32 PyEval_EvalFrameEx (f=0x8a135e4, throwflag=0) at Python/ceval.c:2665
#33 0x00aced7f in fast_function (f=0x85be15c, throwflag=0) at Python/ceval.c:4098
#34 call_function (f=0x85be15c, throwflag=0) at Python/ceval.c:4033
#35 PyEval_EvalFrameEx (f=0x85be15c, throwflag=0) at Python/ceval.c:2665
#36 0x00aced7f in fast_function (f=0x859e4bc, throwflag=0) at Python/ceval.c:4098
#37 call_function (f=0x859e4bc, throwflag=0) at Python/ceval.c:4033
#38 PyEval_EvalFrameEx (f=0x859e4bc, throwflag=0) at Python/ceval.c:2665
#39 0x00ad0270 in PyEval_EvalCodeEx (co=0xb7798e78, globals=0xb786135c, locals=0xb786135c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3252
#40 0x00ad03b3 in PyEval_EvalCode (co=0xb7798e78, globals=0xb786135c, locals=0xb786135c) at Python/ceval.c:666
#41 0x00acf7e6 in exec_statement (f=0x859e1a4, throwflag=0) at Python/ceval.c:4709
#42 PyEval_EvalFrameEx (f=0x859e1a4, throwflag=0) at Python/ceval.c:1879
#43 0x00ad0270 in PyEval_EvalCodeEx (co=0xb77c1e78, globals=0xb7799cec, locals=0x0, args=0x8582734, argcount=7, kws=0x8582750, kwcount=0, defs=0xb77a1218, defcount=5, closure=0x0) at Python/ceval.c:3252
#44 0x00ace7f9 in fast_function (f=0x85825d4, throwflag=0) at Python/ceval.c:4108
#45 call_function (f=0x85825d4, throwflag=0) at Python/ceval.c:4033
#46 PyEval_EvalFrameEx (f=0x85825d4, throwflag=0) at Python/ceval.c:2665
#47 0x00ad0270 in PyEval_EvalCodeEx (co=0xb77984a0, globals=0xb7799cec, locals=0x0, args=0xb77ca7f8, argcount=2, kws=0x0, kwcount=0, defs=0xb77a2618, defcount=1, closure=0x0) at Python/ceval.c:3252
#48 0x00a4ff17 in function_call (func=0xb779fe64, arg=0xb77ca7ec, kw=0x0) at Objects/funcobject.c:526
#49 0x00a2059c in PyObject_Call (func=0xb779fe64, arg=0xb77ca7ec, kw=0x0) at Objects/abstract.c:2529
#50 0x00b03a09 in RunModule (module=<value optimized out>, set_argv0=<value optimized out>) at Modules/main.c:182
#51 0x00b0443e in Py_Main (argc=3, argv=0xbfbf7484) at Modules/main.c:546
#52 0x08048657 in main (argc=3, argv=0xbfbf7484) at ./Modules/python.c:23



More information about the PyQt mailing list