libmoonshot is not thread-safe
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Moonshot ID Selector |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
The moonshot/ui/tests directory supports two tests, one of which is a test of multithreading in libmoonshot. This test usually fails, with failure modes including SIGSEGV, SIGABRT in the malloc library, or deadlock.
I believe the main problem is that libmoonshot is implemented using DBus-GLib. On this link : https:/
"DBus-GLib pretends to be thread-safe but is not. The object model is rubbish and is implemented much better in GDBus (above). The code is not maintained. Do not use it."
(note that freedesktop.org is the origin of dbus-glib!)
According to a note in libmoonshot/
If thread safety is a concern, we should make this a priority. (No pun intended :-)
----
I'm saving this additional note in case we continue with the current design of libmoonshot. It's probably not relevant if we do port to GDBus:
I first thought this function in libmoonshot/
static DBusGProxy *get_dbus_proxy (MoonshotError **error)
{
static DBusGProxy *dbus_proxy = NULL;
static GStaticMutex init_lock = G_STATIC_
g_static_
if (dbus_proxy == NULL) {
/* Make sure GObject is initialised, in case we are the only user
* of GObject in the process
*/
g_type_init ();
dbus_proxy = dbus_connect (error);
}
if (dbus_proxy != NULL)
g_static_
return dbus_proxy;
}
Note that when the caller is done with the proxy, it calls g_object_
Fix will probably involve porting to GDBus