[PyQt] sip segfault in disconnectNotify

Erik Janssens Erik.Janssens at conceptive.be
Fri Sep 10 17:55:17 BST 2010


Hello Phil,

I've made a unittest for the segfault, it is ran by
executing the command :

python -m nose.core test_qt_bindings.py

It seems to be a matter of keeping too much references,
rather than keeping not enough references.

I know the code in itself is pointless and simply
removing a line in it ensures that it doesn't segfaults,
but I would like to understand why it segfaults.

Thank you and best regards,

Erik

On Thu, 2010-09-09 at 15:46 +0100, Phil Thompson wrote:
> 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.
> 
> Phil

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_qt_bindings.py
Type: text/x-python
Size: 1438 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100910/0c87376d/attachment.py>


More information about the PyQt mailing list