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 780924 - Memory leak in gdbusmethodinvocation.c
Memory leak in gdbusmethodinvocation.c
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
2.52.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-04-05 11:47 UTC by Alexandros Frantzis
Modified: 2017-04-05 12:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
simplistic gdbus-based server exhibiting the leak (3.08 KB, text/x-csrc)
2017-04-05 11:47 UTC, Alexandros Frantzis
  Details
Proposed memory leak fix (924 bytes, patch)
2017-04-05 11:58 UTC, Alexandros Frantzis
committed Details | Review

Description Alexandros Frantzis 2017-04-05 11:47:25 UTC
Created attachment 349289 [details]
simplistic gdbus-based server exhibiting the leak

gdbus-based servers leak GDBusPropertyInfo instances when handling calls.

How to reproduce:

1. Build attached gdbus-based server

gcc -g $(pkg-config --cflags gio-2.0 gio-unix-2.0) -o g_dbus_property_info_memory_leak g_dbus_property_info_memory_leak.c $(pkg-config --libs gio-2.0 gio-unix-2.0)

2. Run under valgrind

valgrind --show-leak-kinds=definite --leak-check=full ./g_dbus_property_info_memory_leak

3. Invoke a method call

 gdbus call --session --dest org.myorg.MyObject --object-path /org/myorg/MyObject --method org.freedesktop.DBus.Properties.Get org.myorg.MyObject MyProperty

(This will fail since the server is simplistic and just returns Not Supported for all calls, but it doesn't affect the experiment)

4. Stop the server with Ctrl-C and note leak:

==15754== 181 (40 direct, 141 indirect) bytes in 1 blocks are definitely lost in loss record 1,026 of 1,079
==15754==    at 0x4C2EB45: calloc (vg_replace_malloc.c:711)
==15754==    by 0x522BF90: g_malloc0 (gmem.c:124)
==15754==    by 0x4F0FF3F: parse_data_get_property (gdbusintrospection.c:1158)
==15754==    by 0x4F0FF3F: parser_start_element (gdbusintrospection.c:1444)
==15754==    by 0x5229DA2: emit_start_element (gmarkup.c:1041)
==15754==    by 0x522AE8A: g_markup_parse_context_parse (gmarkup.c:1388)
==15754==    by 0x4F10CC6: g_dbus_node_info_new_for_xml (gdbusintrospection.c:1802)
==15754==    by 0x108D49: main (example.c:72)
Comment 1 Alexandros Frantzis 2017-04-05 11:58:25 UTC
Created attachment 349290 [details] [review]
Proposed memory leak fix
Comment 2 Philip Withnall 2017-04-05 12:11:38 UTC
Review of attachment 349290 [details] [review]:

Looks good, thanks.