GNOME Bugzilla – Bug 634232
Core Dump / Aborted using g_key_file_to_data
Last modified: 2012-01-25 16:40:46 UTC
Created attachment 173999 [details] [review] Patch to solve g_keyfile_set_value bug g_key_file_to_data() uses the approximate_size from GKeyFile structure to allocate memory, but this value can be incorrectly set to a value < 0 due a bug in g_key_file_set_value(). When you use g_key_file_set_value() to set a key and then use this function again to set a new value, GKeyfile->approximate_size will not be changed to reflect this value. If you remove this key, approximate_size may be set to a negative value. -- test program output: size: 0 size: 27 size: 27 size: -16 size: -16 GLib-ERROR **: gmem.c:176: failed to allocate 4294967295 bytes aborting... Aborted (core dumped) --------------------------- See attached a proposed patch (against git version) and test program.
Created attachment 174001 [details] Test program
Please, someone at GLib dev team take a look to confirm the bug! It was opened more than a year ago. The test program to confirm this bug is attached... and the fix is attached too. Thanks!
Created attachment 206029 [details] [review] GKeyFile: remove approximate_size optimisation This is micro-optimisation of the worst kind and it's causing obscure bugs in edge cases. Better just remove this entirely.
Created attachment 206032 [details] [review] keyfile tests: Add testcase for bug #634232 Add a testcase based on one provided by the original reporter of the bug, Alfredo Dal'Ava Júnior.
Attachment 206029 [details] pushed as fe10b2c - GKeyFile: remove approximate_size optimisation Attachment 206032 [details] pushed as 26d4fea - keyfile tests: Add testcase for bug #634232
This commit broke something wrt to index.theme parsing, I now get missing icons in applications and those lines on the terminal: Gtk-WARNING **: Theme directory 8x8/emblems,16x16/actions,16x16/animations,16x16/apps,16x16/categories,16x16/devices,16x16/emblems,16x16/emotes,16x16/mimetypes,16x16/places,16x16/status,22x22/actions,22x22/animations,22x22/apps,22x22/categories,22x22/devices,22x22/emblems,22x22/emotes,22x22/mimetypes,22x22/places,22x22/status,24x24/actions,24x24/apps,24x24/categories,24x24/devices,24x24/emblems,24x24/emotes,24x24/mimetypes,24x24/places,24x24/status,32x32/actions,32x32/animations,32x32/apps,32x32/categories,32x32/devices,32x32/emblems,32x32/emotes,32x32/mimetypes,32x32/places,32x32/status,48x48/actions,48x48/animations,48x48/apps,48x48/categories,48x48/devices,48x48/emblems,48x48/emotes,48x48/mimetypes,48x48/places,48x48/status,256x256/actions,256x256/apps,256x256/categories,256x256/devices,256x256/emblems,256x256/emotes,256x256/mimetypes,256x256/places,256x256/status,scalable/actions,scalable/apps,scalable/devices,scalable/emblems,scalable/mimetypes,scalable/places,scalable/status,scalable/categories of theme gnome has no size field
This was caused by another bug lurking in the code that managed to avoid being triggered (by accident). Matthias committed a fix for it after mine. Try updating.
(In reply to comment #3) > This is micro-optimisation of the worst kind and it's causing obscure > bugs in edge cases. Better just remove this entirely. yes, agreeded. The attribute name "approximate_size" says everything... Thanks for the fix, Ryan!