GNOME Bugzilla – Bug 684182
Memory leak with delegate callback parameters in async methods
Last modified: 2013-06-04 20:50:48 UTC
Created attachment 224477 [details] a simple test case. This is a simple test case.
*** Bug 683921 has been marked as a duplicate of this bug. ***
I can produce it, with "export G_MESSAGES_DEBUG=all", I observed the execution of constructor, but no execution of the destructor.
Created attachment 240917 [details] a smaller test case for analysis I think it's the same bug. In this simple test case, which can be run with valac -g -C --pkg gio-2.0 bugtest1.vala gcc `pkg-config --cflags --libs glib-2.0 gio-2.0` -g -o bugtest1 bugtest1.c G_SLICE=always-malloc valgrind --leak-check=full ./bugtest1 2>&1 | less You can see the memory leak at: ==29487== 24 bytes in 1 blocks are definitely lost in loss record 116 of 285 ==29487== at 0x4A0887C: malloc (vg_replace_malloc.c:270) ==29487== by 0x317F44D68E: g_malloc (gmem.c:159) ==29487== by 0x317F4627F1: g_slice_alloc (gslice.c:1003) ==29487== by 0x317F462D45: g_slice_alloc0 (gslice.c:1029) ==29487== by 0x3180030084: g_type_create_instance (gtype.c:1870) ==29487== by 0x3180014A37: g_object_constructor (gobject.c:1854) ==29487== by 0x31800164F0: g_object_newv (gobject.c:1637) ==29487== by 0x400D24: async_function (bugtest1.c:48) ==29487== by 0x400F8D: _vala_main (bugtest1.vala:7) ==29487== by 0x400FD6: main (bugtest1.vala:5) When the GSimpleAsyncResult is created in my async_function (line 48 in the .c), it's given a meaningless source: _data_->_async_result = g_simple_async_result_new (g_object_newv (G_TYPE_OBJECT, 0, NULL), _callback_, _user_data_, async_function); And that source is never unref'd. ;_;
Please tell valac --version .
Vala 0.20.1
G_MESSAGES_DEBUG=all ./async-block ** (process:400): DEBUG: async-block.vala:8: ObjA ** (process:400): DEBUG: async-block.vala:12: ~ObjA (not print)
commit e60d03f2f93bb33652768957c8304c4e3e0f4d85 Author: Luca Bruno <lucabru@src.gnome.org> Date: Tue Jun 4 22:46:23 2013 +0200 Fix memory leak when defining async functions targeting glib < 2.20. Fixes bug 684182 You should be able to workaround the problem until next release by targeting a newer glib with --target-glib 2.20 .