GNOME Bugzilla – Bug 694862
gtype array leak
Last modified: 2013-10-11 06:28:06 UTC
This code G_SLICE=debug-blocks PYTHONPATH=. valgrind --tool=memcheck --leak-check=full --show-possibly-lost=no python3 -c 'from gi.repository import Gtk, GObject; st = Gtk.ListStore.new([GObject.TYPE_INT])' shows the following leak: ==16974== 24 bytes in 1 blocks are definitely lost in loss record 1,744 of 7,999 ==16974== at 0x4C2CD7B: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==16974== by 0x9376C27: pyg_type_wrapper_new (pygtype.c:342) ==16974== by 0x792E6A5: _pygi_marshal_to_py_gtype (pygi-marshal-to-py.c:284) ==16974== by 0x79208E6: _invoke_marshal_out_args (pygi-invoke.c:553) ==16974== by 0x7920F2A: pygi_callable_info_invoke (pygi-invoke.c:667) ==16974== by 0x7921075: _wrap_g_callable_info_invoke (pygi-invoke.c:685) ==16974== by 0x4814AD: PyEval_EvalFrameEx (ceval.c:4374) ==16974== by 0x47A90D: PyEval_EvalCodeEx (ceval.c:3433) ==16974== by 0x4818A6: PyEval_EvalFrameEx (ceval.c:4160) ==16974== by 0x47A90D: PyEval_EvalCodeEx (ceval.c:3433) ==16974== by 0x47A9BA: PyEval_EvalCode (ceval.c:771) ==16974== by 0x47811C: builtin_exec (bltinmodule.c:850) I tried to reduce this further to a method which just takes a GType, but this doesn't leak: LD_LIBRARY_PATH=tests GI_TYPELIB_PATH=tests G_SLICE=debug-blocks PYTHONPATH=. python3 -c 'from gi.repository import GIMarshallingTests, GObject; GIMarshallingTests.gtype_in(GObject.TYPE_NONE)'
I was eliminating the overrides. This snippet does not leak: python3 -c 'from gi.module import get_introspection_module as gim; Gtk=gim("Gtk"); GObject=gim("GObject"); st = Gtk.ListStore.new([GObject.type_from_name("guint")])' But when I save the GType variable as I, it does leak: python3 -c 'from gi.module import get_introspection_module as gim; Gtk=gim("Gtk"); GObject=gim("GObject"); I = GObject.type_from_name("guint"); st = Gtk.ListStore.new([I]) when not using the I reference, but recreating it again, it does not leak: python -c 'from gi.module import get_introspection_module as gim; Gtk=gim("Gtk"); GObject=gim("GObject"); I = GObject.type_from_name("guint"); st = Gtk.ListStore.new([GObject.type_from_name("guint")])' But if I move the GObject and Gtk overrides away from gi/overrides/, the leak again does not happen.
I was unable to reproduce any of the noted leaks with what is currently in master. These were most likely fixed with stuff that has been going in for bug 693402.