GNOME Bugzilla – Bug 649457
probable leak in icon theme
Last modified: 2011-05-06 02:33:20 UTC
==7070== 247,835 bytes in 14,743 blocks are possibly lost in loss record 16,638 of 16,667 ==7070== at 0x4C2541D: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==7070== by 0x69183D2: g_malloc (in /usr/lib/libglib-2.0.so.0.2800.6) ==7070== by 0x692ED78: g_strndup (in /usr/lib/libglib-2.0.so.0.2800.6) ==7070== by 0x5C6E666: ??? (in /usr/lib/libgtk-3.so.0.0.9) ==7070== by 0x5C6FDE8: ??? (in /usr/lib/libgtk-3.so.0.0.9) ==7070== by 0x5C70165: ??? (in /usr/lib/libgtk-3.so.0.0.9) ==7070== by 0x5C70CA1: gtk_icon_theme_lookup_icon (in /usr/lib/libgtk-3.so.0.0.9) ==7070== by 0x1F664D91: gkbd_indicator_config_get_images_file (in /usr/lib/libgnomekbdui.so.7.0.0) ==7070== by 0x1F664DDC: gkbd_indicator_config_load_image_filenames (in /usr/lib/libgnomekbdui.so.7.0.0) ==7070== by 0x1F6641BE: ??? (in /usr/lib/libgnomekbdui.so.7.0.0) ==7070== by 0x66B298F: g_type_create_instance (in /usr/lib/libgobject-2.0.so.0.2800.6) ==7070== by 0x669112B: ??? (in /usr/lib/libgobject-2.0.so.0.2800.6) ==7070== by 0x66940D1: g_object_newv (in /usr/lib/libgobject-2.0.so.0.2800.6) ==7070== by 0x6694C9B: g_object_new (in /usr/lib/libgobject-2.0.so.0.2800.6) ==7070== by 0x1F6642B8: gkbd_configuration_get (in /usr/lib/libgnomekbdui.so.7.0.0) ==7070== by 0x76063EB: ffi_call_unix64 (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x7605E64: ffi_call (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x1B91225A: ??? (in /usr/lib/libgjs-gi.so.0.0.0) ==7070== by 0x1B9133FF: ??? (in /usr/lib/libgjs-gi.so.0.0.0) ==7070== by 0x74251D4: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x74113DB: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x7424B14: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x7424FB1: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x73F661B: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x741B256: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x7424B14: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x7426654: ??? (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x739E692: JS_EvaluateUCScriptForPrincipals (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x739E791: JS_EvaluateScriptForPrincipals (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x739E831: JS_EvaluateScript (in /usr/lib/xulrunner-2.0/libmozjs.so) ==7070== by 0x713FCD3: gjs_context_eval (in /usr/lib/libgjs.so.0.0.0) ==7070== by 0x4E5454B: ??? (in /usr/lib/gnome-shell/libgnome-shell.so) ==7070== by 0x510731F: meta_plugin_manager_initialize (in /usr/lib/libmutter.so.0.0.0) ==7070== by 0x5104785: meta_compositor_manage_screen (in /usr/lib/libmutter.so.0.0.0) ==7070== by 0x51193C3: meta_display_open (in /usr/lib/libmutter.so.0.0.0) ==7070== by 0x512339C: meta_run (in /usr/lib/libmutter.so.0.0.0) ==7070== by 0x40214E: main (in /usr/bin/gnome-shell)
Note the leak starts with g_strndup(). There is exactly one call to g_strndup() in gtkicontheme.c, in the strip_suffix() function. This function returns allocated memory, and its consumers are very twisted code. Hunting...
Created attachment 187284 [details] [review] gtkicontheme: More explicitly note ownership transfers of duplicated string I was hunting a memory leak and couldn't find it; at least I'm pretty sure all of these are OK. But document things better for the future. Also use g_hash_table_replace in one more case for consistency.
Note valgrind says "possibly lost". This may not actually be a leak, just some memory that we don't clean up on process exit. libgnomekbd has a "static gpointer instance".
Review of attachment 187284 [details] [review]: Looks right to me.
Comment on attachment 187284 [details] [review] gtkicontheme: More explicitly note ownership transfers of duplicated string Attachment 187284 [details] pushed as 703af0f - gtkicontheme: More explicitly note ownership transfers of duplicated string