I can confirm the issue in pyqt 4.8.3 / qt 4.7.2 it segfaults, but with the following assert statement :
.QObject::killTimers: timers cannot be stopped from another thread ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread b6b08490. Receiver 'qt_scrollarea_hcontainer' (of type 'QWidget') was created in thread 94eeee8", file kernel/qcoreapplication.cpp, line 349 Phil, does this mean that a QGraphicsScene is only garbage collected when the QApplication has been garbage collected, thus creating a memory leak ? The PySide equivalent however crashes as well for me, but only on exit of the app : #0 0x00273c81 in Shiboken::Object::destroy(SbkObject*, void*) () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/libshiboken-python2.7.so.1.0 #1 0x03ebbac7 in QGraphicsViewWrapper::~QGraphicsViewWrapper() () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/python2.7/site-packages/PySide/QtGui.so #2 0x005e98dc in PySide::destructionVisitor(SbkObject*, void*) () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/libpyside-python2.7.so.1.0 #3 0x002788f8 in Shiboken::BindingManager::visitAllPyObjects(void (*)(SbkObject*, void*), void*) () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/libshiboken-python2.7.so.1.0 #4 0x005e9833 in PySide::destroyQCoreApplication() () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/libpyside-python2.7.so.1.0 #5 0x005e9c77 in PySide::runCleanupFunctions() () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/libpyside-python2.7.so.1.0 #6 0x00ac4cb5 in SbkQtCoreModule___moduleShutdown(_object*) () from /home/tw55413/workspaces/cpd/trunk/linux2-debug/install/lib/python2.7/site-packages/PySide/QtCore.so #7 0x00708bf1 in PyCFunction_Call (func=0xb775ccac, arg=0xb780402c, kw=0x9bca0b4) at Objects/methodobject.c:90 #8 0x0076d504 in ext_do_call (f=0x9b4f744, throwflag=0) at Python/ceval.c:4322 #9 PyEval_EvalFrameEx (f=0x9b4f744, throwflag=0) at Python/ceval.c:2704 #10 0x0076f270 in PyEval_EvalCodeEx (co=0xb7751728, globals=0xb7752f0c, locals=0x0, args=0xb7804038, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3252 #11 0x006eef17 in function_call (func=0xb7755d84, arg=0xb780402c, kw=0x0) at Objects/funcobject.c:526 #12 0x006bf59c in PyObject_Call (func=0xb7755d84, arg=0xb780402c, kw=0x0) at Objects/abstract.c:2529 #13 0x00767b94 in PyEval_CallObjectWithKeywords (func=0xb7755d84, arg=0xb780402c, kw=0x0) at Python/ceval.c:3881 #14 0x0078dc5e in call_sys_exitfunc () at Python/pythonrun.c:1726 #15 Py_Finalize () at Python/pythonrun.c:412 #16 0x007a30e1 in Py_Main (argc=2, argv=0xbfbf6e84) at Modules/main.c:624 #17 0x08048657 in main (argc=2, argv=0xbfbf6e84) at ./Modules/python.c:23 On Mon, 2011-03-28 at 12:57 +0100, Phil Thompson wrote: > On Sun, 27 Mar 2011 22:29:38 -0400, Luke Campagnola > <lcamp...@email.unc.edu> wrote: > > Greetings All-Knowing PyQters, > > I have a strange bug that's causing segmentation faults in my program. I > > have identified some of the key contributors to the bug and a > workaround, > > but I would love for someone to explain what causes the crash so I can > > avoid > > similar problems in the future. > > > > Here are the things required to cause the crash: > > 1) Repeatedly creating and deleting a GraphicsView and GraphicsItem > > 2) The each GraphicsItem has a reference to the GraphicsView it is shown > in > > 3) Having a second thread running and actively working > > > > Usually a segmentation fault will occur after roughly 10-1000 > create/delete > > cycles. Taking away any of these components prevents the crash. The > second > > thread does not have to be doing anything specific and does not even > have > > to > > be a QThread; it just has to be doing _something_. If the Item has a > > weakref > > to its View, there is no crash (and this is a perfectly acceptable > > workaround). > > > > I have attached a GDB backtrace and a short script demonstrating the > bug. > > When I run the script on my system (Ubuntu 10.04, PyQt 4.7.2), about > half > > of > > the time it causes a segfault, and the rest of the time it just freezes. > > I've also tested the script on WinXp with PyQt 4.8.3 and 4.5.4, with > > similar > > results. PySide does not have the bug, so I suspect it is not a Qt > issue. > > > > Any advice would be greatly appreciated! > > > > Luke > > PyQt keeps track of certain types of object that are known to cause > problems if they are garbage collected before the QApplication - > QGraphicsScene is one of these. It seems that QObjectCleanupHandler has > problems in a threaded application. > > Fixed (or at least worked around) in tonight's PyQt snapshot. > > Phil > _______________________________________________ > PyQt mailing list PyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt