[PyQt] sip segfault in disconnectNotify

Phil Thompson phil at riverbankcomputing.com
Thu Sep 9 15:46:09 BST 2010

On Thu, 09 Sep 2010 16:35:15 +0200, Erik Janssens
<Erik.Janssens at conceptive.be> wrote:
> Hi,
> I understand that it's possible to segfault writing
> python code (although in my naive view this should
> not be the case ;)).  I'm rather convinced the code
> is not doing anything 'illegal', but it would be helpful
> to have some descriptions on what exactly one can
> do wrong using pyqt with regard to these kind of
> segfaults ?

Typically not keeping a reference to an object. Historically (but I'm not
sure how much it is still the case, particularly with the new-style
connections) sip/PyQt would keep pointers to Python objects without taking
a reference. This was to avoid creating circular references in the days
before the cyclic garbage collector.

> I will try to write a test case for this situation,
> as well as for the deadlocks I mentioned earlier.
> Can you maybe comment on the meaning of this line
> in siplib.c
> 7288	    assert(PyTuple_Check(mro));
> It might help me finding the cause at the python
> level.

It's just a sanity check. If Python is working fine then mro will always
be a tuple, and the following call to PyTuple_GET_SIZE() assumes that it
is. If it fails then it is likely that mro has been garbage collected and
the memory reused.


More information about the PyQt mailing list