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 748474 - g_get_language_names() is not thread-safe
g_get_language_names() is not thread-safe
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-04-26 04:52 UTC by Benjamin Gilbert
Modified: 2016-03-26 12:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test program (789 bytes, text/plain)
2015-04-26 04:52 UTC, Benjamin Gilbert
  Details
Fix (1.45 KB, patch)
2015-04-26 04:55 UTC, Benjamin Gilbert
accepted-commit_now Details | Review

Description Benjamin Gilbert 2015-04-26 04:52:01 UTC
Created attachment 302357 [details]
Test program

The alias_table static variable in glib/gcharset.c is initialized by unalias_lang()/read_aliases() without proper synchronization.  As shown by the attached test program, this can cause segfaults and glibc heap corruption traps if g_get_language_names() is called in parallel from multiple threads, either directly or via g_key_file_new().  The attached patch fixes the issue.
Comment 1 Benjamin Gilbert 2015-04-26 04:55:40 UTC
Created attachment 302358 [details] [review]
Fix
Comment 2 Benjamin Gilbert 2016-03-26 00:28:58 UTC
Two open-source libraries, VIPS and OpenSlide, are now calling g_get_language_names() from their shared library constructors to work around this bug.  Any chance the patch could get a review?
Comment 3 Colin Walters 2016-03-26 12:56:28 UTC
Review of attachment 302358 [details] [review]:

LGTM, sorry about the delay.
Comment 4 Colin Walters 2016-03-26 12:57:45 UTC
Thanks for the patch, committed!

https://git.gnome.org/browse/glib/commit/?id=41888493f04bfcc42d5287267708edcc49d7b4ea

Pings are OK.  Another thing you can do to help is also jump in and look for *other* easy patches to review.