Skip to content

Commit

Permalink
Work around g_key_file_new() thread-safety problems
Browse files Browse the repository at this point in the history
The first call to g_key_file_new() does some thread-unsafe
initialization.  Manually run that initialization from the shared library
constructor to avoid crashes or heap corruption if multiple threads
call openslide_detect_vendor() or openslide_open() in parallel.

Fixes openslide#161.
  • Loading branch information
bgilbert committed Apr 26, 2015
1 parent 173d52c commit ba57bcd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/openslide.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ static void __attribute__((constructor)) _openslide_init(void) {
}
// initialize GObject
g_type_init();
// work around thread-safety problems with first g_key_file_new() call
// https://bugzilla.gnome.org/show_bug.cgi?id=748474
g_get_language_names();
// init libxml2
xmlInitParser();
// parse debug options
Expand Down

0 comments on commit ba57bcd

Please sign in to comment.