Skip to content

dbus-related memory leakings #397

@bebehei

Description

@bebehei

Running valgrind --leak-check=full --show-leak-kinds=definite --track-origins=yes ~/code/dunst/dunst shows that the GDBus*-Types are not freed correctly. There are multiple issues with this.

This may be either a glib-related bug in the g_*_unref() functions or it might be a problem in our handling of dbus-related stuff:

(0) This is output for a single message with a raw icon (generated from spotify):

==23036== 270,677 (40 direct, 270,637 indirect) bytes in 1 blocks are definitely lost in loss record 1,882 of 1,883
==23036==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23036==    by 0x6E01E38: g_malloc (gmem.c:94)
==23036==    by 0x6E199B5: g_slice_alloc (gslice.c:1025)
==23036==    by 0x6E385BD: g_variant_alloc (gvariant-core.c:476)
==23036==    by 0x6E385BD: g_variant_new_from_children (gvariant-core.c:565)
==23036==    by 0x6E35293: g_variant_builder_end (gvariant.c:3703)
==23036==    by 0x59DFF15: parse_value_from_blob (gdbusmessage.c:1823)
==23036==    by 0x59E00BE: parse_value_from_blob (gdbusmessage.c:1854)
==23036==    by 0x59DFD28: parse_value_from_blob (gdbusmessage.c:1774)
==23036==    by 0x59DFFFC: parse_value_from_blob (gdbusmessage.c:1727)
==23036==    by 0x59DFEDE: parse_value_from_blob (gdbusmessage.c:1808)
==23036==    by 0x59E2143: g_dbus_message_new_from_blob (gdbusmessage.c:2148)
==23036==    by 0x59EC79D: _g_dbus_worker_do_read_cb (gdbusprivate.c:744)

270kB per notification. That saying: If you listen to spotify for 10 hours (3min/track), you've got about 50MBs leaked just for listening to spotify.

(1) Some other (smaller) stuff from the same notification:

==23036== 81 (40 direct, 41 indirect) bytes in 1 blocks are definitely lost in loss record 1,254 of 1,883
==23036==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23036==    by 0x6E01E38: g_malloc (gmem.c:94)
==23036==    by 0x6E199B5: g_slice_alloc (gslice.c:1025)
==23036==    by 0x6E384EC: g_variant_alloc (gvariant-core.c:476)
==23036==    by 0x6E384EC: g_variant_new_from_bytes (gvariant-core.c:512)
==23036==    by 0x6E316F6: g_variant_new_from_trusted (gvariant.c:321)
==23036==    by 0x6E317CE: g_variant_new_byte (gvariant.c:410)
==23036==    by 0x59DF92D: parse_value_from_blob (gdbusmessage.c:1486)
==23036==    by 0x59E00BE: parse_value_from_blob (gdbusmessage.c:1854)
==23036==    by 0x59DFD28: parse_value_from_blob (gdbusmessage.c:1774)
==23036==    by 0x59DFFFC: parse_value_from_blob (gdbusmessage.c:1727)
==23036==    by 0x59DFEDE: parse_value_from_blob (gdbusmessage.c:1808)
==23036==    by 0x59E2143: g_dbus_message_new_from_blob (gdbusmessage.c:2148)

(2) sending a notification with a hint produces this (and additonally 1):

==23428== 168 (80 direct, 88 indirect) bytes in 2 blocks are definitely lost in loss record 1,645 of 1,910
==23428==    at 0x4C2CE5F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23428==    by 0x6E01E38: g_malloc (gmem.c:94)
==23428==    by 0x6E199B5: g_slice_alloc (gslice.c:1025)
==23428==    by 0x6E384EC: g_variant_alloc (gvariant-core.c:476)
==23428==    by 0x6E384EC: g_variant_new_from_bytes (gvariant-core.c:512)
==23428==    by 0x6E316F6: g_variant_new_from_trusted (gvariant.c:321)
==23428==    by 0x6E3185D: g_variant_new_int32 (gvariant.c:485)
==23428==    by 0x59DFAB7: parse_value_from_blob (gdbusmessage.c:1516)
==23428==    by 0x59E00BE: parse_value_from_blob (gdbusmessage.c:1854)
==23428==    by 0x59DFD28: parse_value_from_blob (gdbusmessage.c:1774)
==23428==    by 0x59DFFFC: parse_value_from_blob (gdbusmessage.c:1727)
==23428==    by 0x59DFEDE: parse_value_from_blob (gdbusmessage.c:1808)
==23428==    by 0x59E2143: g_dbus_message_new_from_blob (gdbusmessage.c:2148)

There's still more.


@tsipinakis Do you know, how to debug this? I don't see, where this pointer from g_dbus_message_new_from_blob get's passed to. I don't see any possibility to examine this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions