← Back to team overview

group.of.nepali.translators team mailing list archive

[Bug 1861601] Re: Memory leak and incorrect behaviour of generated bindings

 

This bug was fixed in the package sip4 - 4.17+dfsg-1ubuntu0.1

---------------
sip4 (4.17+dfsg-1ubuntu0.1) xenial; urgency=medium

  * Fixed issues with C/C++ member variable getters and setters. This
    restores the keeping of a reference to the containing object in the
    instance of a contained class (LP: #1861601).

 -- Dmitry Shachnev <mitya57@xxxxxxxxxx>  Sun, 15 Mar 2020 19:23:54
+0300

** Changed in: sip4 (Ubuntu Xenial)
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of नेपाली
भाषा समायोजकहरुको समूह, which is subscribed to Xenial.
Matching subscriptions: Ubuntu 16.04 Bugs
https://bugs.launchpad.net/bugs/1861601

Title:
  Memory leak and incorrect behaviour of generated bindings

Status in sip4 package in Ubuntu:
  Fix Released
Status in sip4 source package in Xenial:
  Fix Released
Status in sip4 source package in Bionic:
  Fix Released

Bug description:
  Happening on all release of sip from 4.16.8 until 4.19.20, so Xenial
  and newer are all affected.

  I have tested this on both Xenial(sip 4.17) and Bionic(4.19.7).

  My request is to update all affected releases to 4.19.21.

  [Impact]
  Since the release of sip 4.16.8, but especially commit https://www.riverbankcomputing.com/hg/sip/rev/11a92ebd4840, sip contains two bugs. The code being generated doesn't keep the correct references and a memory leak.

  The reference problem:
  (generateVariableGetter in sipgen/gencode.c)
  In the get function of a class member, there isn't a reference kept to the containing class. Therefore if no other references are kept to the containing class, the containing class in cpp is deleted, also if there are still references to the member. This causes also the member in cpp to be deleted, while in python there is still a reference to the member. Which can't be accessed anymore.
  Fixed in:
  https://www.riverbankcomputing.com/hg/sip/rev/137b9be794a1
  https://www.riverbankcomputing.com/hg/sip/rev/6a057b2d8537
  https://www.riverbankcomputing.com/hg/sip/rev/699facc95914

  The memory leak problem:
  (sip_api_get_reference in siplib/siplib.c)
  A new reference to "key_obj" is obtained from PyLong_FromLong/PyInt_FromLong. but the reference count is not decreased. Therefore "key_obj" stays alive and produces a memory leak.
  Fixed in:
  https://www.riverbankcomputing.com/hg/sip/rev/82ec38dc0e63

  Both problems are fixed in 4.19.21. Also the entire changelog between
  4.19.20 and 4.19.21 is related to fixing only these two problems.

  The converstation between me and the develop of sip can be read here:
  http://python.6.x6.nabble.com/sip-Accessing-members-results-in-
  incorrect-missing-data-td5266521.html, which might provide some more
  insight.

  
  [Test Case]
  As sip is a library to generate python bindings. So my test case will be an "applied" test case. My test case is focused on the 'python_orocos_kdl', https://github.com/orocos/orocos_kinematics_dynamics, library.

  For this test case, please use the "test/sip_bug" branch of my fork of
  the library,
  https://github.com/MatthijsBurgh/orocos_kinematics_dynamics.

  To test the reference problem, follow the steps from travis config.
  (Of course skipping the installation of python-sip-dev if testing with
  other sip versions.)

  To test the memory leak, run the following code (After running the steps from the travis config):
  ```
  import PyKDL as kdl

  F = kdl.Frame(
      kdl.Rotation.Quaternion(0, 1, 0, 0),
      kdl.Vector(1, 2, 3))

  while True:
      v = F.p
  ```
  See http://python.6.x6.nabble.com/sip-Accessing-members-results-in-incorrect-missing-data-tp5266521p5267154.html including plot of the memory usage, http://python.6.x6.nabble.com/file/t383425/mem_leak.png.

  
  [Regression Potential]
  Different versions of SIP have been released on multiple distributions. No bugs have been reported of these versions. I have tested multiple versions of SIP in the affected range on both Xenial and Bionic. I didn't experience any bugs other than the two reported here.

  [Other Info]
  Already mentioned, but the conversation between me and the developer, http://python.6.x6.nabble.com/sip-Accessing-members-results-in-incorrect-missing-data-td5266521.html.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/sip4/+bug/1861601/+subscriptions