[PyQt] [SIP] Critical issue since version 4.18

Phil Thompson phil at riverbankcomputing.com
Mon Nov 14 18:57:00 GMT 2016


On 14 Nov 2016, at 6:36 pm, Antoine Lambert <antoine.lambert33 at gmail.com> wrote:
> 
> Hi,
> 
> I am the maintainer of the Python bindings for the Tulip framework : an open source graph visualization tool. I have recently upgraded to SIP 4.18.1 and one critical issue appears in our generated bindings leading to a segfault.
> 
> The bug is the following. We use SIP in order to implement plugins in Python for the Tulip framework. Implementing a plugin consists in writing a Python class that derives from a Tulip wrapped plugin interface (see http://pythonhosted.org/tulip-python/pythonplugins.html).  For instance to write a general graph algorithm plugin, one has to write a class that derives from the 'tlp.Algorithm' Tulip Python class.
> The 'tlp.Algorithm' class wraps the 'tlp::Algorithm" C++ class (https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/Algorithm.sip). The "tlp::Algorithm" class derives from the "tlp::Plugin" class (https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/Plugin.sip), itself deriving from "tlp::WithParameter" and "tlp::WithDependency" (https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/WithParameter.sip, https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/WithDependency.sip). The issue is that now every call to a method from the "tlp.WithParameter" class inside a Tulip plugin source code leads to a segfault during the plugin execution.
> I managed to get back to the SIP revision that introduces the regression through a session of "hg bisect" : this is revision 1425 (https://www.riverbankcomputing.com/hg/sip/rev/14bfbaf7431a). It seems that some needed class cast functions are no more generated since that revision which then leads to segfault due to incorrect pointer cast (just my guess).
> As a temporary workaround, i naively patch the SIP source code bundled in the Tulip source tree forcing the generation of these cast functions (https://sourceforge.net/p/auber/code/11726/).
> 
> I also found another issue that is not critical but still problematic. When wrapping non const global C++ variables, setting their value in Python does not modify the content of the wrapped variables. For instance, in the Tulip Python bindings, we wrapped some global variables holding some file system paths (e.g. "tlp.TulipBitmapDir", https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/TlpTools.sip).
> Even if it seems that when modifying the variable content it is taken into account (in particular when printing it), the content of the wrapped variable is not changed.
> I assumed there is some kind of cache for wrapped const global variables but it should not be used for non const ones.
> That issue was already present in SIP 4.17, I should have report it earlier but its was not critical and I managed to workaround it using a Python meta-class (https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/__init__.py). 
> 
> Hope that this report will help to fix those annoying issues for the next SIP version.

Have you tried the current snapshot?

Phil


More information about the PyQt mailing list