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 634232 - Core Dump / Aborted using g_key_file_to_data
Core Dump / Aborted using g_key_file_to_data
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-11-07 18:04 UTC by Alfredo Dal'Ava Júnior
Modified: 2012-01-25 16:40 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to solve g_keyfile_set_value bug (861 bytes, patch)
2010-11-07 18:04 UTC, Alfredo Dal'Ava Júnior
none Details | Review
Test program (1.84 KB, text/plain)
2010-11-07 18:05 UTC, Alfredo Dal'Ava Júnior
  Details
GKeyFile: remove approximate_size optimisation (4.51 KB, patch)
2012-01-24 21:46 UTC, Allison Karlitskaya (desrt)
committed Details | Review
keyfile tests: Add testcase for bug #634232 (1.54 KB, patch)
2012-01-24 22:05 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Alfredo Dal'Ava Júnior 2010-11-07 18:04:01 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.
Comment 1 Alfredo Dal'Ava Júnior 2010-11-07 18:05:25 UTC
Created attachment 174001 [details]
Test program
Comment 2 Alfredo Dal'Ava Júnior 2012-01-24 21:35:29 UTC
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!
Comment 3 Allison Karlitskaya (desrt) 2012-01-24 21:46:59 UTC
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.
Comment 4 Allison Karlitskaya (desrt) 2012-01-24 22:05:39 UTC
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.
Comment 5 Allison Karlitskaya (desrt) 2012-01-24 22:17:52 UTC
Attachment 206029 [details] pushed as fe10b2c - GKeyFile: remove approximate_size optimisation
Attachment 206032 [details] pushed as 26d4fea - keyfile tests: Add testcase for bug #634232
Comment 6 Frederic Peters 2012-01-25 16:07:10 UTC
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
Comment 7 Allison Karlitskaya (desrt) 2012-01-25 16:09:13 UTC
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.
Comment 8 Alfredo Dal'Ava Júnior 2012-01-25 16:40:46 UTC
(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!