[PyQt] assertion failure in sip

Phil Thompson phil at riverbankcomputing.com
Sat Sep 17 13:46:45 BST 2011


On Sat, 17 Sep 2011 04:51:42 +0100, Phil Thompson
<phil at riverbankcomputing.com> wrote:
> On Fri, 16 Sep 2011 22:28:24 +0200, Erik Janssens
> <Erik.Janssens at conceptive.be> wrote:
>> Hi,
>> 
>> I'm seeing an assertion failure in sip, stacktrace
>> attached.
>> 
>> It happens consistently, but only after long stress
>> tests of a large application.
>> 
>> Any suggestions on what might be causing this
>> failure, so I can try to isolate the case ?
> 
> It looks like there might be a race condition when the Python object
> wrapping the QWidget is being garbage collected and the QWidget itself
is
> still calling it's virtual methods.
> 
> This is supposed to be taken care of by the "if (sipSelf == NULL)" test
> earlier in the function. This test is done without the GIL. The pointer
> being tested is set in dealloc_QWidget() (with the GIL).
> 
> Therefore if the Python object is in the process of being garbage
> collected but before dealloc_QWidget() gets a chance to reset the
pointer,
> and then QWidget::changeEvent() gets called then there might be a
problem.
> 
> The fix would be to do the test with the GIL but that requires a change
to
> the signature of sip_api_is_py_method() to pass a pointer to the pointer
> being tested rather than the pointer itself.
> 
> Watch this space...

I've implemented the change in tonight's SIP snapshot (and current Hg).

Let me know if it makes a difference.

Phil


More information about the PyQt mailing list