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 683519 - Deadlock in g_dbus_connection_get_type()
Deadlock in g_dbus_connection_get_type()
Status: RESOLVED DUPLICATE of bug 674885
Product: glib
Classification: Platform
Component: gdbus
2.33.x
Other Linux
: Normal critical
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-09-06 17:17 UTC by Patrick Ohly
Modified: 2012-09-07 11:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (485 bytes, text/x-csrc)
2012-09-06 17:17 UTC, Patrick Ohly
Details

Description Patrick Ohly 2012-09-06 17:17:34 UTC
Created attachment 223675 [details]
test program

The attached test programs hangs frequently in e_source_registry_new_sync(). Perhaps one out of ten attempts work.

I compiled it with "gcc -g /tmp/source.c -o /tmp/source `pkg-config --cflags --libs glib-2.0 libedataserver-1.2`" and ran it in a jhbuild shell, with a D-Bus session created manually in that environment.

Running it with G_DBUS_DEBUG=message shows that no D-Bus traffic happens when it hangs.

This affects SyncEvolution. I only noticed the problem after building GNOME 3.5 with jhbuild (Debian Testing as base system). On Debian Testing with just evolution-data-server compiled from source it worked fine.

Thread 3 (Thread 0x7f35e4f4c700 (LWP 22385))

  • #0 __lll_lock_wait
    at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S line 136
  • #1 _L_lock_997
    from /lib/x86_64-linux-gnu/libpthread.so.0
  • #2 __pthread_mutex_lock
    at pthread_mutex_lock.c line 82
  • #3 g_type_add_interface_static
    at gtype.c line 2819
  • #4 g_dbus_connection_get_type
    at gdbusconnection.c line 523
  • #5 get_uninitialized_connection
    at gdbusconnection.c line 6803
  • #6 g_bus_get_sync
    at gdbusconnection.c line 6876
  • #7 dconf_gdbus_get_bus_in_worker
    at dconf-gdbus-thread.c line 184
  • #8 dconf_gdbus_method_call
    at dconf-gdbus-thread.c line 242
  • #9 g_main_dispatch
    at gmain.c line 2715
  • #10 g_main_context_dispatch
    at gmain.c line 3219
  • #11 g_main_context_iterate
    at gmain.c line 3290
  • #12 g_main_context_iteration
    at gmain.c line 3351
  • #13 dconf_gdbus_worker_thread
    at dconf-gdbus-thread.c line 81
  • #14 g_thread_proxy
    at gthread.c line 797
  • #15 start_thread
    at pthread_create.c line 304
  • #16 clone
    at ../sysdeps/unix/sysv/linux/x86_64/clone.S line 112
  • #17 ??

Comment 1 Matthew Barnes 2012-09-06 17:31:28 UTC
This looks beyond our reach, it appears to be deadlocked inside g_dbus_connection_get_type().

Forwarding this on to GIO maintainers.
Comment 2 Colin Walters 2012-09-06 17:33:07 UTC
(In reply to comment #1)
> This looks beyond our reach, it appears to be deadlocked inside
> g_dbus_connection_get_type().
> 
> Forwarding this on to GIO maintainers.

You are very likely creating an object *instance* inside _class_init().  Don't do that.

See https://bugzilla.gnome.org/show_bug.cgi?id=674885
Comment 3 Matthew Barnes 2012-09-06 17:58:36 UTC
Not as far as I can tell.

What _is_ happening is g_dbus_object_manager_client_class_init() is registering a "connection" property of type G_TYPE_DBUS_CONNECTION at the same time dconf is trying to connect to its daemon over D-Bus.
Comment 4 David Zeuthen (not reading bugmail) 2012-09-06 18:03:27 UTC
(In reply to comment #3)
> Not as far as I can tell.
> 
> What _is_ happening is g_dbus_object_manager_client_class_init() is registering
> a "connection" property of type G_TYPE_DBUS_CONNECTION at the same time dconf
> is trying to connect to its daemon over D-Bus.

That's probably why then. What a mess - until we fix GType, I guess you can work around it for now by calling g_type_ensure(G_TYPE_DBUS_CONNECTION) somewhere...
Comment 5 Dan Winship 2012-09-06 18:44:10 UTC

*** This bug has been marked as a duplicate of bug 674885 ***
Comment 6 Patrick Ohly 2012-09-07 07:51:34 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Not as far as I can tell.
> > 
> > What _is_ happening is g_dbus_object_manager_client_class_init() is registering
> > a "connection" property of type G_TYPE_DBUS_CONNECTION at the same time dconf
> > is trying to connect to its daemon over D-Bus.
> 
> That's probably why then. What a mess - until we fix GType, I guess you can
> work around it for now by calling g_type_ensure(G_TYPE_DBUS_CONNECTION)
> somewhere...

That workaround, well, works.

The question for e_source_registry_new_sync() now becomes "who works around the problem - the app or libedataserver?". I vote for libedataserver, because then the workaround only needs to be implemented once.

I guess it could be put into e_source_registry_new_sync(). If other functions have similar issues, they probably will only be called after e_source_registry_new_sync(). Here's the patch that worked for me:

diff --git a/libedataserver/e-source-registry.c b/libedataserver/e-source-registry.c
index c9783d6..5685ecd 100644
--- a/libedataserver/e-source-registry.c
+++ b/libedataserver/e-source-registry.c
@@ -1281,6 +1281,8 @@ ESourceRegistry *
 e_source_registry_new_sync (GCancellable *cancellable,
                             GError **error)
 {
+       g_type_ensure(G_TYPE_DBUS_CONNECTION);
+
        return g_initable_new (
                E_TYPE_SOURCE_REGISTRY,
                cancellable, error, NULL);

Matthew, I can commit that if you want.

FWIW, an app using the asynchronous e_source_registry_new() + g_main_context_iteration() (or running the loop) doesn't seem to be affect. I tried that in SyncEvolution and it worked.
Comment 7 Colin Walters 2012-09-07 10:15:15 UTC
(In reply to comment #6)
>
> +       g_type_ensure(G_TYPE_DBUS_CONNECTION);

Add a comment above that links to the bug?
Comment 8 Matthew Barnes 2012-09-07 11:43:58 UTC
Can't use g_type_ensure() yet since we only require GLib 2.32, but I added something equivalent, along with a comment linking to the bug.

http://git.gnome.org/browse/evolution-data-server/commit/?id=6c4c1c6a1f40a6873be954a0b9d770e31726bd50