From 28f368d64f079bec2c5de8f36e342273bb4dc517 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 3 Jun 2013 14:20:49 +0100 Subject: [PATCH] Initialize libdbus for thread-safety libdbus is not thread-safe by default. This is a long-standing design flaw (). We call into GIO, which calls into glib-networking, which can (at least in recent versions) invoke libproxy in a thread. libproxy apparently has a Network-Manager plugin, which uses libdbus in that thread; meanwhile, we use libdbus in the main thread and everything goes badly for us. (It's possible that this crash is only reproducible with broken connectivity: I wrote this patch on a train, with intermittent mobile broadband coverage.) In libdbus < 1.7.4, libraries cannot safely initialize libdbus for multi-threading, because that initialization is not itself thread-safe (!); in particular, glib-networking cannot safely initialize libdbus. So, we have to do it. I have written patches to make libdbus thread-safe-by-default, but they haven't all been reviewed and merged yet, and in any case they won't be in a stable libdbus until 1.8. Until then, each application has to discover and fix this bug individually. --- src/gabble.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gabble.c b/src/gabble.c index 1cb2b8f..e7e4da4 100644 --- a/src/gabble.c +++ b/src/gabble.c @@ -25,6 +25,8 @@ # include #endif +#include + #include #include @@ -106,6 +108,9 @@ log_handler (const gchar *log_domain, void gabble_init (void) { + if (!dbus_threads_init_default ()) + g_error ("Unable to initialize libdbus thread-safety (out of memory?)"); + g_type_init (); wocky_init (); } -- 1.7.10.4