From 5b4b827e9940d724580101546c601c2e3c77ff82 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 18 Nov 2016 16:26:58 -0500 Subject: [PATCH] gdbus: Initialize types earlier to break proxy <-> connection deadlock This will help us break generic GType deadlocks between people using GDBus in different threads (which is supported), not just by GType usage in the GDBus thread. This should fix the common cases we're seeing in the wild, although I have some lingering concerns that if someone e.g. referenced e.g. `G_TYPE_DBUS_AUTH_MECHANISM_SHA1` etc. we'd need to add those too. https://bugzilla.gnome.org/show_bug.cgi?id=674885 --- gio/gdbusprivate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index ea05dcd3d..eeb12d90d 100644 --- a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -202,7 +202,8 @@ _g_socket_read_with_control_messages_finish (GSocket *socket, /* ---------------------------------------------------------------------------------------------------- */ -/* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=627724 */ +/* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=674885 + and see also the original https://bugzilla.gnome.org/show_bug.cgi?id=627724 */ static GPtrArray *ensured_classes = NULL; @@ -227,6 +228,8 @@ ensure_required_types (void) ensured_classes = g_ptr_array_new (); ensure_type (G_TYPE_TASK); ensure_type (G_TYPE_MEMORY_INPUT_STREAM); + ensure_type (G_TYPE_DBUS_CONNECTION); + ensure_type (G_TYPE_DBUS_PROXY); } /* ---------------------------------------------------------------------------------------------------- */ @@ -264,9 +267,6 @@ _g_dbus_shared_thread_ref (void) { SharedThreadData *data; - /* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=627724 */ - ensure_required_types (); - data = g_new0 (SharedThreadData, 1); data->refcount = 0; @@ -1921,6 +1921,9 @@ _g_dbus_initialize (void) _gdbus_debug_flags |= G_DBUS_DEBUG_MESSAGE; } + /* Work-around for https://bugzilla.gnome.org/show_bug.cgi?id=627724 */ + ensure_required_types (); + g_once_init_leave (&initialized, 1); } }