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 595757 - gio does not handle "late" g_thread_init()
gio does not handle "late" g_thread_init()
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-09-20 15:53 UTC by Dan Winship
Modified: 2010-02-17 22:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Winship 2009-09-20 15:53:44 UTC
While libglib goes to great lengths to retcon its threadsafety if g_thread_init() is called while the program is already running, libgio does not. This means, at the moment:

    - If you call g_cancellable_get_type() and then later initialize
      threads, then later calls to certain GCancellable methods will
      crash because cancellable_cond is NULL.

    - If you call g_resolver_get_default() and then later initialize
      threads, then later calls to resolver methods will potentially
      crash/block/fail randomly.

Fixing these is slightly more awkward than in the glib cases, since gio has no equivalent of g_thread_init_glib(). One way would be to add something like "g_thread_add_init_callback()" that you can use to add more methods to the list that gets called from g_thread_init_glib(). Failing that, GCancellable already has a static mutex it could use to protect the fixup, and we could do various tricks with atomic pointers and static mutexes and stuff in the resolver code too.

Or we could just say "ha ha, we told you you had to call g_thread_init first".
Comment 1 A. Walton 2010-02-17 21:18:55 UTC
Since GIO doesn't work without calling g_type_init(), and g_type_init() calls g_thread_init(NULL) now as of http://git.gnome.org/browse/glib/commit/?id=fa2bced1f30f93443ef43ce8b5b1e437cd07168c, isn't this effectively fixed?
Comment 2 Dan Winship 2010-02-17 22:03:58 UTC
yup