<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi,<br><br></div>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.<br><br></div>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 <a href="http://pythonhosted.org/tulip-python/pythonplugins.html" target="_blank">http://pythonhosted.org/tulip-<wbr>python/pythonplugins.html</a>).
For instance to write a general graph algorithm plugin, one has to
write a class that derives from the 'tlp.Algorithm' Tulip Python class.<br></div>The 'tlp.Algorithm' class wraps the 'tlp::Algorithm" C++ class (<a href="https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/Algorithm.sip" target="_blank">https://sourceforge.net/p/<wbr>auber/code/HEAD/tree/tulip/<wbr>library/tulip-python/bindings/<wbr>tulip-core/Algorithm.sip</a>). The "tlp::Algorithm" class derives from the "tlp::Plugin" class (<a href="https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/Plugin.sip" target="_blank">https://sourceforge.net/p/<wbr>auber/code/HEAD/tree/tulip/<wbr>library/tulip-python/bindings/<wbr>tulip-core/Plugin.sip</a>), itself deriving from "tlp::WithParameter" and "tlp::WithDependency" (<a href="https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/WithParameter.sip" target="_blank">https://sourceforge.net/p/<wbr>auber/code/HEAD/tree/tulip/<wbr>library/tulip-python/bindings/<wbr>tulip-core/WithParameter.sip</a>, <a href="https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/WithDependency.sip" target="_blank">https://sourceforge.net/p/<wbr>auber/code/HEAD/tree/tulip/<wbr>library/tulip-python/bindings/<wbr>tulip-core/WithDependency.sip</a>)<wbr>.
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.<br></div>I managed to get back to
the SIP revision that introduces the regression through a session of "hg
bisect" : this is revision 1425 (<a href="https://www.riverbankcomputing.com/hg/sip/rev/14bfbaf7431a" target="_blank">https://www.<wbr>riverbankcomputing.com/hg/sip/<wbr>rev/14bfbaf7431a</a>).
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).<br></div>As a temporary workaround, i
naively patch the SIP source code bundled in the Tulip source tree
forcing the generation of these cast functions (<a href="https://sourceforge.net/p/auber/code/11726/" target="_blank">https://sourceforge.net/p/<wbr>auber/code/11726/</a>).<br><br></div>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", <a href="https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/TlpTools.sip" target="_blank">https://sourceforge.net/p/<wbr>auber/code/HEAD/tree/tulip/<wbr>library/tulip-python/bindings/<wbr>tulip-core/TlpTools.sip</a>).<br></div>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.<br></div><div>I assumed there is some kind of cache for wrapped const global variables but it should not be used for non const ones.<br></div>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 (<a href="https://sourceforge.net/p/auber/code/HEAD/tree/tulip/library/tulip-python/bindings/tulip-core/__init__.py" target="_blank">https://sourceforge.net/p/<wbr>auber/code/HEAD/tree/tulip/<wbr>library/tulip-python/bindings/<wbr>tulip-core/__init__.py</a>). <br><br></div><div>Hope that this report will help to fix those annoying issues for the next SIP version.<br></div><br><div>Best regards,<br><br></div>Antoine Lambert<span id="gmail-:22p" class="gmail-J-J5-Ji"></span></div>