I'll see if I can come up with a minimal test to reproduce it. Right now it's happening in the context of a fairly large system.<br><br><div class="gmail_quote">On Sun, Jul 10, 2011 at 12:25 PM, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">On Thu, 7 Jul 2011 14:27:25 -0500, Paul Bonser <<a href="mailto:misterpib@gmail.com">misterpib@gmail.com</a>><br>


wrote:<br>
<div><div></div><div class="h5">> I'm running into an issue with SIP/PyQt where sip_api_is_py_method is<br>
> getting called and it is segfaulting when it gets to this section:<br>
><br>
>>     cls = (PyObject *)Py_TYPE(sipSelf);<br>
>>     mro = ((PyTypeObject *)cls)->tp_mro;<br>
>>     assert(PyTuple_Check(mro));<br>
><br>
> Because mro ends up being NULL.<br>
><br>
> This is the backtrace:<br>
><br>
> #0  0x00007f880d00d8ef in sip_api_is_py_method (gil=0x7fff6a7b6d6c,<br>
> pymc=0x587e7e9 "", sipSelf=0x4e21b90, cname=0x0, mname=0x7f880c81cf92<br>
> "eventFilter") at siplib.c:7586<br>
> #1  0x00007f880c7e3cb0 in sipQObject::eventFilter (this=0x587e7d0,<br>
> a0=0x57e6660, a1=0x5cde260) at sipQtCoreQObject.cpp:360<br>
> #2  0x00007f880c276627 in<br>
> QCoreApplicationPrivate::sendThroughObjectEventFilters (this=<value<br>
> optimized out>, receiver=0x57e6660, event=0x5cde260) at<br>
> kernel/qcoreapplication.cpp:846<br>
> #3  0x00007f8809f549b1 in QApplicationPrivate::notify_helper<br>
> (this=0x19e6820, receiver=0x57e6660, e=0x5cde260) at<br>
> kernel/qapplication.cpp:4453<br>
> #4  0x00007f8809f593aa in QApplication::notify (this=0x1f8c960,<br>
> receiver=0x57e6660, e=0x5cde260) at kernel/qapplication.cpp:3861<br>
> #5  0x00007f880b146d28 in sipQApplication::notify (this=0x1f8c960,<br>
> a0=0x57e6660, a1=0x5cde260) at sipQtGuiQApplication.cpp:297<br>
> #6  0x00007f880c27649c in QCoreApplication::notifyInternal<br>
> (this=0x1f8c960, receiver=0x57e6660, event=0x5cde260) at<br>
> kernel/qcoreapplication.cpp:731<br>
> #7  0x00007f880c279c25 in sendEvent (receiver=0x0, event_type=0,<br>
> data=0x1f8b4c0) at<br>
> ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215<br>
> #8  QCoreApplicationPrivate::sendPostedEvents (receiver=0x0,<br>
> event_type=0, data=0x1f8b4c0) at kernel/qcoreapplication.cpp:1372<br>
> #9  0x00007f880c2a1253 in sendPostedEvents (s=0x1fa4560) at<br>
> ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:220<br>
> #10 postEventSourceDispatch (s=0x1fa4560) at<br>
> kernel/qeventdispatcher_glib.cpp:277<br>
> #11 0x00007f880ba61bcd in g_main_context_dispatch () from<br>
> /lib/x86_64-linux-gnu/libglib-2.0.so.0<br>
> #12 0x00007f880ba623a8 in ?? () from<br>
/lib/x86_64-linux-gnu/libglib-2.0.so.0<br>
> #13 0x00007f880ba62639 in g_main_context_iteration () from<br>
> /lib/x86_64-linux-gnu/libglib-2.0.so.0<br>
> #14 0x00007f880c2a13ef in QEventDispatcherGlib::processEvents<br>
> (this=0x1fa1be0, flags=<value optimized out>) at<br>
> kernel/qeventdispatcher_glib.cpp:422<br>
> #15 0x00007f8809ffbdfe in QKeyMapperPrivate::possibleKeysCore<br>
> (this=0x7f880c279f9f, event=<value optimized out>) at<br>
> kernel/qkeymapper_x11.cpp:386<br>
> #16 0x0000000003a16030 in ?? ()<br>
> #17 0x7fffffff05384200 in ?? ()<br>
> #18 0x0000002200000013 in ?? ()<br>
> #19 0x000000000398ec34 in ?? ()<br>
> #20 0x0000000003979b40 in ?? ()<br>
> #21 0x000000000398cd40 in ?? ()<br>
> #22 0x0000000003927f50 in ?? ()<br>
> #23 0x0000000000000000 in ?? ()<br>
><br>
> Can anyone tell me in what situations tp_mro might end up being NULL?<br>
> It seems like that should really only be the case during object<br>
> initialization, right?<br>
><br>
> Adding the following before the assert line seems to alleviate the<br>
issue:<br>
><br>
>>     if (mro == NULL)<br>
>>     {<br>
>> #ifdef WITH_THREAD<br>
>>         PyGILState_Release(*gil);<br>
>> #endif<br>
>>         return NULL;<br>
>>     }<br>
><br>
> Is this a valid solution, or should the problem be tracked down to the<br>
> source of tp_mro being NULL?<br>
<br>
</div></div>If the mro is NULL then something is wrong.<br>
<br>
Do you have a test that reproduces the problem?<br>
<font color="#888888"><br>
Phil<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Paul Bonser | <a href="http://probablyprogramming.com" target="_blank">http://probablyprogramming.com</a> | @pib<br>