GNOME Bugzilla – Bug 627441
Race condition in ndesk-dbus causes hang
Last modified: 2010-12-18 17:04:31 UTC
The banshee GUI (1.7.4) freezes for me in certain situations: - if I enable the podcast extension - if I start with podcast extension enabled - when banshee tries to fetch cover art for newly imported albums Running kill -QUIT `pidof banshee` unfreezes the GUI. I will attach the logs of this below. They hint a problem with NetworkManager, but that is running and working fine. This problem did not happen with the last stable release I used (1.6.x). Distribution is Fedora 13.
Created attachment 168337 [details] Log 1: at startup
Created attachment 168338 [details] Log 2: enable podcast during run
Can you try with master? I think there was some change in the ServiceManager that might have regressed for 1.7.4 and already been fixed.
*** Bug 628682 has been marked as a duplicate of this bug. ***
*** Bug 628827 has been marked as a duplicate of this bug. ***
Duplicate had the same problem with 1.7.5 Here's the general scenario, from what I could gather from the logs : Something (podcast, cover art download or something else) makes the first call to NetworkManager. This takes the lock in ServiceManager, initializes the service and makes a d-bus call to "org.freedesktop.NetworkManager". In the meantime, all other services registration are waiting on the lock. This d-bus call seems to take a long time, or maybe there a deadlock I don't see ?
I was able to reproduce the problem by disabling all extensions except Podcasts. From the thread dump below, I don't see how we could have a race in Banshee. So I think we're hitting this race condition in ndesk-dbus : http://git.ndesk.org/?p=dbus-sharp;a=blob;f=src/PendingCall.cs;hb=HEAD#l44 The minimal thread dump I got is the following (threads doing nothing omitted) : "Main Thread" tid=0x0x2b56812b9620 this=0x0x2aaaaacdbe60 thread handle 0x404 state : waiting on 0x512 : Sem owns () at Banshee.ServiceStack.ServiceManager.Get (string) [0x0003b] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs:348 at Banshee.ServiceStack.ServiceManager.Get (string) [0x0000c] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs:342 at Banshee.ServiceStack.ServiceManager.get_PlayerEngine () [0x00000] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs:433 at Banshee.Gui.Widgets.TrackInfoDisplay.LoadCurrentTrack (bool) <0x0001f> at Banshee.Gui.Widgets.TrackInfoDisplay.LoadCurrentTrack () [0x00000] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs:417 at Banshee.Gui.Widgets.TrackInfoDisplay.OnSizeAllocated (Gdk.Rectangle) [0x00018] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs:192 at Banshee.Gui.Widgets.ClassicTrackInfoDisplay.OnSizeAllocated (Gdk.Rectangle) [0x00000] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/ClassicTrackInfoDisplay.cs:129 at Gtk.Widget.sizeallocated_cb (intptr,intptr) <IL 0x00014, 0x0007b> at (wrapper native-to-managed) Gtk.Widget.sizeallocated_cb (intptr,intptr) <IL 0x00018, 0x00053> at (wrapper managed-to-native) Gtk.Application.gtk_main () <IL 0x0000e, 0x00055> at (wrapper managed-to-native) Gtk.Application.gtk_main () <IL 0x0000e, 0x00055> at Gtk.Application.Run () <IL 0x00000, 0x0000b> at Banshee.Gui.GtkBaseClient.Run () [0x00000] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:205 at Banshee.Gui.GtkBaseClient.Startup () [0x00000] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:82 at Hyena.Gui.CleanRoomStartup.Startup (Hyena.Gui.CleanRoomStartup/StartupInvocationHandler) [0x00044] in /home/lorentz/Projets/banshee/src/Hyena/Hyena.Gui/Hyena.Gui/CleanRoomStartup.cs:54 at Banshee.Gui.GtkBaseClient.Startup<object> () [0x00024] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:77 at Banshee.Gui.GtkBaseClient.Startup<object> (string[]) [0x0004d] in /home/lorentz/Projets/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:67 at Nereid.Client.Main (string[]) [0x00000] in /home/lorentz/Projets/banshee/src/Clients/Nereid/Nereid/Client.cs:54 at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x0001d, 0x00054> "Spawned: System.Threading.ThreadStart" tid=0x0x2aaac00cb710 this=0x0x2aaabdac7170 thread handle 0x510 state : interrupted state owns () at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait (object,int) <IL 0x00008, 0x00050> at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait (object,int) <IL 0x00008, 0x00050> at System.Threading.Monitor.Wait (object,int) <IL 0x00040, 0x00043> at System.Threading.Monitor.Wait (object) <IL 0x00002, 0x00017> at NDesk.DBus.PendingCall.get_Reply () <IL 0x0006a, 0x000b3> at NDesk.DBus.Connection.SendWithReplyAndBlock (NDesk.DBus.Message) <IL 0x00009, 0x00023> at NDesk.DBus.BusObject.SendMethodCall (string,string,string,NDesk.DBus.MessageWriter,System.Type,System.Exception&) <IL 0x0007e, 0x0018b> at org.freedesktop.DBus.IBusProxy.NameHasOwner (string) <IL 0x00042, 0x000af> at NDesk.DBus.Bus.NameHasOwner (string) <IL 0x00007, 0x0002d> at Banshee.Networking.NetworkManager.get_ManagerPresent () [0x00000] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.Networking/NetworkManager.cs:77 at Banshee.Networking.NetworkManager..ctor () [0x00006] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.Networking/NetworkManager.cs:55 at Banshee.Networking.Network.ConnectToManager () [0x0000a] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.Networking/Network.cs:92 at Banshee.Networking.Network..ctor () [0x0000c] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.Networking/Network.cs:74 at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0001c, 0x00051> at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (object,object[],System.Exception&) <IL 0x0001c, 0x00068> at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (object,object[],System.Exception&) <IL 0x0001c, 0x00068> at System.Reflection.MonoCMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x0011f, 0x001c3> at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x00007, 0x00040> at System.Reflection.ConstructorInfo.Invoke (object[]) <IL 0x00017, 0x00042> at System.Activator.CreateInstance (System.Type,bool) <IL 0x000b7, 0x0019b> at System.Activator.CreateInstance (System.Type) <IL 0x00002, 0x0000f> at Banshee.ServiceStack.ServiceManager.RegisterService (System.Type) [0x00002] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs:162 at Banshee.ServiceStack.ServiceManager.Get<object> () [0x0004d] in /home/lorentz/Projets/banshee/src/Core/Banshee.Services/Banshee.ServiceStack/ServiceManager.cs:356 at Banshee.Podcasting.PodcastService.RefreshFeeds () [0x00000] in /home/lorentz/Projets/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:332 at Banshee.Podcasting.PodcastService.<DelayedInitialize>m__9 () [0x001e0] in /home/lorentz/Projets/banshee/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs:273 at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0001c, 0x00051>
Should be fixed in dbus-sharp now: http://github.com/mono/dbus-sharp/commit/84f2126d148b78a5310378a243fd3bc822f467b2#diff-0
Garuma was trying to address my question, but I still get the same problem with the latest dbus-sharp from git master.
Created attachment 170783 [details] [review] Workaround for races in NDesk.DBus Apparently, we were hitting not one, but two race conditions in NDesk.DBus. This patch is brings 2 quick and dirty workarounds for those. This is not intended to be committed, but just to have an outside confirmation of the fix. Please test this patch against git master and check if it also fixes the freeze for you. If yes, I will try to come up with a nicer patch. FYI, those are the fixes for the races, in dbus-sharp : http://github.com/mono/dbus-sharp/commit/84f2126 http://github.com/garuma/dbus-sharp/commit/055982
*** Bug 630233 has been marked as a duplicate of this bug. ***
Review of attachment 170783 [details] [review]: ::: src/Core/Banshee.Services/Banshee.Networking/Network.cs @@ +73,2 @@ try { + Hyena.ThreadAssist.ProxyToMain ( delegate { Should probably use BlockingProxyToMain
Created attachment 170965 [details] [review] Better two-in-one workaround Using BlockingProxyToMain would create a deadlock : the main thread is waiting on a lock that is held by the thread doing the call... I believe this patch avoid the two races by initializing the Network service in the main thread and early in the startup phase, before any thread doing dbus stuff are started. Thankfully this adds less than 1ms to the startup time on my system, with NetworkManager. This might be higher if we have to try other network-thingies (wicd, etc.). Please check for sanity and confirm it also fixes the problem for you
*** Bug 630249 has been marked as a duplicate of this bug. ***
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report. I committed that last patch, after Sebastian confirmed it fixes the freeze for him.
*** Bug 630815 has been marked as a duplicate of this bug. ***
*** Bug 630579 has been marked as a duplicate of this bug. ***