dbus-glib, GLib and threads

Alberto Mardegan mardy at users.sourceforge.net
Wed Jul 25 22:49:24 PDT 2012

  I've got one library which seems to produce random crashes when used
in a multithreaded application. We are not sure yet that the problem is
in that library, but it is the most likely candidate.

The library is written using dbus-glib, and creates one DBusGProxy
object which is used to make all of its D-Bus calls. This object is a
global singleton, therefore it's shared and used by all threads. You can
see the code here:

Could the crashes be indirectly caused by
https://bugs.freedesktop.org/show_bug.cgi?id=857 ?

Any suggestions on how to solve this? The long term plan is to use
GDBus, but it won't happen overnight. Does the following sound like a

1) Don't use a global singleton: call g_thread_self() in the SignonProxy
constructor to create a singleton object per each thread.
2) Call dbus_g_bus_get_private(), not dbus_g_bus_get()

Or would (2) alone be enough?


http://blog.mardy.it <- geek in un lingua international!

More information about the dbus mailing list