GNOME Bugzilla – Bug 709880
Elements leak with transfer everything marshaling from Python of GArray, GPtrArray, and GHashTable
Last modified: 2018-01-10 20:33:47 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
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
-- 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.