After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688137 - GValue's holding boxed and gobject types leak references
GValue's holding boxed and gobject types leak references
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-11-12 03:03 UTC by Simon Feltman
Modified: 2012-11-12 07:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add expectantly failing unittests for GValue boxed/object leaks (3.56 KB, patch)
2012-11-12 03:48 UTC, Simon Feltman
committed Details | Review
Fix leaks with GValue's holding boxed and object types (2.92 KB, patch)
2012-11-12 06:29 UTC, Simon Feltman
committed Details | Review

Description Simon Feltman 2012-11-12 03:03:21 UTC
It looks as though GObject.Value is an introspected type with gi.Boxed and gobject.GBoxed as bases. The destruction of GValue's created in python and set to hold a boxed or object type will leak that reference after the GValue is collected.

An override could be added implementing __del__ which makes a call to "unset" to fix the leak. However, this might not be desired in the case of a pointer to a GValue passed as a parameter to a python vfunc with the transfer != GI_TRANSFER_EVERYTHING. Or rather we could expose the "free_on_dealloc" static property of gobject.GBoxed and check that within the __del__. For example:

class Value(GObjectModule.Value):
    def __del__(self):
        if self._free_on_dealloc:
            self.unset()

Value = override(Value)
Comment 1 Simon Feltman 2012-11-12 03:48:02 UTC
Created attachment 228747 [details] [review]
Add expectantly failing unittests for GValue boxed/object leaks
Comment 2 Simon Feltman 2012-11-12 06:29:35 UTC
Created attachment 228752 [details] [review]
Fix leaks with GValue's holding boxed and object types

Expose read access to PyGIBoxed.free_on_dealloc.
Add GObject.Value.__del__ override and call unset() to
correctly free reference counts.
Comment 3 Martin Pitt 2012-11-12 06:34:08 UTC
Comment on attachment 228747 [details] [review]
Add expectantly failing unittests for GValue boxed/object leaks

Thanks for these! Please go ahead.

Can you please drop the apostrophe in "Fix leaks with GValue's holding boxed and object types"?