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 709880 - Elements leak with transfer everything marshaling from Python of GArray, GPtrArray, and GHashTable
Elements leak with transfer everything marshaling from Python of GArray, GPtr...
Status: RESOLVED OBSOLETE
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: 693111
 
 
Reported: 2013-10-11 05:52 UTC by Simon Feltman
Modified: 2018-01-10 20:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Simon Feltman 2013-10-11 05:52:00 UTC
The issue is we don't specify cleanup funcs for the construction of these various types when marshaling from Python. This causes leaks when the receiving end unrefs the container because the individual elements won't be free'd. Essentially for the transfer-full case we need to pass simple cleanup functions with:

g_ptr_array_new_with_free_func      (GDestroyNotify element_free_func);

g_hash_table_new_full               (GHashFunc hash_func,
                                     GEqualFunc key_equal_func,
                                     GDestroyNotify key_destroy_func,
                                     GDestroyNotify value_destroy_func);

GArray does not have a cleanup function so perhaps that leak should be fixed in GIMarshallingTests by assuming g_free should be used for it's values.

To support this, I think it would be worthwhile to add an additional "simple cleanup" function pointer to ArgCaches which has the GDestroyNotify signature. Container marshalers could then use this for the per-item cleanup when available (and pass it to container creation as well).

tests/test_gi.py:TestGArray.test_garray_utf8_full_inout

12 bytes, 6 blocks
malloc
g_malloc
g_malloc_n
g_strdup
_pygi_marshal_from_py_utf8
_pygi_marshal_from_py_basic_type
_pygi_marshal_from_py_basic_type_cache_adapter
_pygi_marshal_from_py_array
_invoke_marshal_in_args
pygi_callable_info_invoke
_wrap_g_callable_info_invoke
_callable_info_call


tests/test_gi.py:TestGPtrArray.test_gptrarray_utf8_full_inout
6 bytes, 3 blocks
malloc
g_malloc
g_malloc_n
g_strdup
_pygi_marshal_from_py_utf8
_pygi_marshal_from_py_basic_type
_pygi_marshal_from_py_basic_type_cache_adapter
_pygi_marshal_from_py_array
_invoke_marshal_in_args
pygi_callable_info_invoke
_wrap_g_callable_info_invoke
_callable_info_call


tests/test_gi.py:TestGHashTable.test_ghashtable_utf8_full_inout

19 bytes, 8 blocks
malloc
g_malloc
g_malloc_n
g_strdup
_pygi_marshal_from_py_utf8
_pygi_marshal_from_py_basic_type
_pygi_marshal_from_py_basic_type_cache_adapter
_pygi_marshal_from_py_ghash
_invoke_marshal_in_args
pygi_callable_info_invoke
_wrap_g_callable_info_invoke
_callable_info_call
Comment 1 Philip Withnall 2015-02-23 10:20:20 UTC
This is being discussed on the ML at the moment, and the semantics of (transfer full) container types with free funcs might end up getting finalised:

https://mail.gnome.org/archives/gir-devel-list/2015-February/msg00013.html
Comment 2 GNOME Infrastructure Team 2018-01-10 20:33:47 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/56.