[PyQt] Disturbing evidence of garbage collection error

Erik Janssens Erik.Janssens at conceptive.be
Sat Apr 28 12:05:37 BST 2012


which version of PyQt are you using ?

When in older versions (I think something like 2 releases ago),
the garbage collection kicks in in a thread and it deletes
a QObject from another thread, this object was deleted
immediately, while in recent versions those are deleted later
on in the event loop of the thread to which they belong.

You can always turn the GC of to make sure the issue is GC
related

On Fri, 2012-04-27 at 12:53 +0100, Andrew Suffield wrote:
> query = QtSql.QSqlQuery()
>         if not query.prepare('select %s from %s where %s' % (','.join(field_names), table, self.key_expr(table))):
> 
> I get 'RuntimeError: underlying C/C++ object has been deleted' on the
> second line, with low probability. Sometimes it just segfaults instead
> while inside the C++ function QSqlQuery::prepare. Either way, it
> happens about one time in 100,000, and when it segfaults, a different
> thread is in the garbage collector.
> 
> So, we've got one thread deciding that the local python variables of
> another are garbage and freeing them, while the victim thread is still
> in a function call. That implies the local variables are somehow not
> getting registered properly as being referenced.
> 
> I'll keep digging, but some ideas or pointers to relevant code would
> be handy - it's not immediately clear how sip interacts with GC.
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt




More information about the PyQt mailing list