[PyQt] SIGSEGV when calling the ( virtual ) python subclass method

Alessandro Pasotti apasotti at gmail.com
Wed Oct 8 08:18:08 BST 2014


2014-10-07 19:18 GMT+02:00 Alessandro Pasotti <apasotti at gmail.com>:
> Hi,
>
> stuck again on my QGIS server bindings, now getting hard-to-debug segfaults.
>
>
> I've rewritten the base QgsServerFilter class with virtual methods:
> https://github.com/elpaso/QGIS/blob/serverplugins-iface/src/mapserver/qgsserverfilter.h
>
>  and updated the sip file:
> https://github.com/elpaso/QGIS/blob/serverplugins-iface/python/server/qgsserverfilter.sip
>
> The QgsServerFilter filters are added to a QMultiMap
> https://github.com/elpaso/QGIS/blob/serverplugins-iface/src/mapserver/qgsserverinterfaceimpl.cpp#L42
>
> and then the methods are called in the main application loop (segfault
> is here!):
> https://github.com/elpaso/QGIS/blob/serverplugins-iface/src/mapserver/qgis_map_serv.cpp#L374
>
> The simple python code I'm using for testing is here:
> https://dpaste.de/MjQ0
>
> I noticed that when I add the QgsServerFilter object the vtable is ok
> (points to <vtable for sipQgsServerFilter+16>) but when the method is
> called in the loop, the vtable is corrupted (the debugger only shows
> addresses and no text descriptions for the functions) and immediately
> segfaults.
>
> Any hint about how to debug this?
>
> PS: running on ubuntu 14.04
>
> -- Found Qt version: 4.8.6
> -- Pedantic compiler settings enabled
> -- Debug output enabled
> -- Found Python executable: /usr/bin/python
> -- Found Python version: 2.7.6
> -- Found Python library: /usr/lib/x86_64-linux-gnu/libpython2.7.so
> -- Found SIP version: 4.15.5
>
>


Found the problem. For the records: to avoid garbage collection I had
to annotate the registerFilter QgsServerFilter with /Transfer/ :

virtual void registerFilter( QgsServerFilter* filter /Transfer/, int
priority = 0 ) = 0;



-- 
Alessandro Pasotti
w3:   www.itopen.it


More information about the PyQt mailing list