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 559479 - GUI freezes when new USB disks plugged in
GUI freezes when new USB disks plugged in
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: general
1.4.1
Other Linux
: Normal major
: 1.x
Assigned To: Banshee Maintainers
Banshee Maintainers
: 560587 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-11-05 17:45 UTC by kakyoism
Modified: 2009-01-23 23:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't use Scheduler from DapSource, run synchronously (519 bytes, patch)
2008-11-15 19:58 UTC, Félix Velasco
none Details | Review
Add USB disks synchronously (3.52 KB, patch)
2008-12-04 20:30 UTC, Félix Velasco
needs-work Details | Review
Remove unnecessary lock (584 bytes, patch)
2009-01-23 21:06 UTC, Félix Velasco
committed Details | Review

Description kakyoism 2008-11-05 17:45:04 UTC
System: Ubuntu Hardy.

I often unplugged my large USB harddrives at night with my banshee working
and the very next morning I would plug them back, 
whenever they are plugged back, the banshee GUI would die and the notification icon on the gnome is gone too.
Comment 1 Michał Sawicz 2008-11-05 19:23:26 UTC
Yep, I'm having the same thing, I can only use my mass storage DAP when plugged in _before_ banshee starts. When plugging in while banshee's running, it hangs.
Comment 2 Gabriel Burt 2008-11-13 02:43:47 UTC
What about in 1.4.1?
Comment 3 kakyoism 2008-11-13 02:57:34 UTC
Hi Gabriel,

It's still there in 1.4.1. I just tested it.
Comment 4 Bertrand Lorentz 2008-11-13 07:02:23 UTC
*** Bug 560587 has been marked as a duplicate of this bug. ***
Comment 5 Bertrand Lorentz 2008-11-13 07:03:34 UTC
The log from the duplicate :

[Info  22:01:52.780] Running Banshee 1.4.0
[Info  22:01:57.123] All services are started 3.734517s
[Info  22:01:58.595] nereid Client Started
Full thread dump:

"" tid=0x0xb29a3b90 this=0x0x714d0:

"" tid=0x0xb6188b90 this=0x0x71d10:
  at (wrapper managed-to-native) System.Net.Sockets.Socket.Accept_internal
(intptr,int&) <0x00004>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal
(intptr,int,bool) <0x00004>
  at (wrapper managed-to-native) System.Net.Sockets.Socket.Accept_internal
(intptr,int&) <0xffffffff>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitOne_internal
(intptr,int,bool) <0xffffffff>
  at System.Net.Sockets.Socket.Accept () <0x00085>
  at System.Threading.WaitHandle.WaitOne () <0x00052>
  at Banshee.Daap.DaapProxyWebServer.ServerLoop () <0x0002d>
  at Hyena.Data.Sqlite.HyenaSqliteConnection.ProcessQueue () <0x000ff>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void ()
<0xffffffff>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void ()
<0xffffffff>
  at (wrapper runtime-invoke)
System.Collections.Generic.GenericEqualityComparer`1.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>
  at (wrapper runtime-invoke)
System.Collections.Generic.GenericEqualityComparer`1.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>

"" tid=0x0xb4367b90 this=0x0x218b00:
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitAny_internal
(System.Threading.WaitHandle[],int,bool) <0x00004>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitAny_internal
(System.Threading.WaitHandle[],int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitAny
(System.Threading.WaitHandle[],System.TimeSpan,bool) <0x000c6>
  at System.Threading.RegisteredWaitHandle.Wait (object) <0x000a6>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void_object
(object) <0xffffffff>
  at (wrapper runtime-invoke)
System.Threading.WaitCallback.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0xffffffff>

"" tid=0x0xb4571b90 this=0x0x218f20:
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitAny_internal
(System.Threading.WaitHandle[],int,bool) <0x00004>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitAny_internal
(System.Threading.WaitHandle[],int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitAny
(System.Threading.WaitHandle[],System.TimeSpan,bool) <0x000c6>
  at System.Threading.RegisteredWaitHandle.Wait (object) <0x000a6>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void_object
(object) <0xffffffff>
  at (wrapper runtime-invoke)
System.Threading.WaitCallback.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0xffffffff>

"" tid=0x0xb446cb90 this=0x0x218e70:
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitAny_internal
(System.Threading.WaitHandle[],int,bool) <0x00004>
  at (wrapper managed-to-native) System.Threading.WaitHandle.WaitAny_internal
(System.Threading.WaitHandle[],int,bool) <0xffffffff>
  at System.Threading.WaitHandle.WaitAny
(System.Threading.WaitHandle[],System.TimeSpan,bool) <0x000c6>
  at System.Threading.RegisteredWaitHandle.Wait (object) <0x000a6>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void_object
(object) <0xffffffff>
  at (wrapper runtime-invoke)
System.Threading.WaitCallback.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0xffffffff>

"" tid=0x0xb2bf4b90 this=0x0x716e0:
  at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait
(object,int) <0x00004>
  at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait
(object,int) <0xffffffff>
  at System.Threading.Monitor.Wait (object) <0x0002d>
  at NDesk.DBus.PendingCall.get_Reply () <0x00087>
  at NDesk.DBus.Connection.SendWithReplyAndBlock (NDesk.DBus.Message) <0x0001d>
  at NDesk.DBus.BusObject.SendMethodCall
(string,string,string,NDesk.DBus.MessageWriter,System.Type,System.Exception&)
<0x00134>
  at IDeviceProxy.GetPropertyBoolean (string) <0x0008b>
  at Hal.Device.GetPropertyBoolean (string) <0x00016>
  at Banshee.HalBackend.Volume.get_ShouldIgnore () <0x0001f>
  at MapDeviceJob.Run () <0x002fb>
  at Banshee.Kernel.Scheduler.ProcessJobThread () <0x000fe>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void ()
<0xffffffff>
  at (wrapper runtime-invoke)
System.Collections.Generic.GenericEqualityComparer`1.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>

"" tid=0x0xb2ab8b90 this=0x0x71840:
  at (wrapper managed-to-native) Mono.Unix.Native.Syscall.read
(int,intptr,ulong) <0x00004>
  at (wrapper managed-to-native) Mono.Unix.Native.Syscall.read
(int,intptr,ulong) <0xffffffff>
  at Mono.Unix.Native.Syscall.read (int,void*,ulong) <0x00043>
  at Mono.Unix.UnixStream.Read (byte[],int,int) <0x00082>
  at NDesk.DBus.Connection.ReadMessage () <0x00051>
  at NDesk.DBus.Connection.Iterate () <0x00019>
  at Mono.Zeroconf.Providers.AvahiDBus.DBusManager.IterateThread (object)
<0x00055>
  at (wrapper delegate-invoke) System.MulticastDelegate.invoke_void_object
(object) <0xffffffff>
  at (wrapper runtime-invoke)
System.Threading.WaitCallback.runtime_invoke_void_object
(object,intptr,intptr,intptr) <0xffffffff>

"" tid=0x0xb7cea6d0 this=0x0x30e10:
  at (wrapper managed-to-native) System.Threading.Monitor.Monitor_try_enter
(object,int) <0x00004>
  at (wrapper managed-to-native) System.Threading.Monitor.Monitor_try_enter
(object,int) <0xffffffff>
  at System.Threading.Monitor.Enter (object) <0x00013>
  at Banshee.Dap.DapService.UnmapDevice (string) <0x00053>
  at Banshee.Dap.DapService.OnHardwareDeviceRemoved
(object,Banshee.Hardware.DeviceRemovedArgs) <0x00024>
  at (wrapper delegate-invoke)
System.MulticastDelegate.invoke_void_object_DeviceRemovedArgs
(object,Banshee.Hardware.DeviceRemovedArgs) <0xffffffff>
  at Banshee.Hardware.HardwareManager.OnDeviceRemoved
(object,Banshee.Hardware.DeviceRemovedArgs) <0x0002a>
  at Banshee.HalBackend.HardwareManager.OnDeviceRemoved (string) <0x00038>
  at Banshee.HalBackend.HardwareManager.OnHalDeviceRemoved
(object,Hal.DeviceRemovedArgs) <0x00024>
  at Hal.Manager.OnDeviceRemoved (string) <0x00038>
  at (wrapper runtime-invoke) Hal.Manager.runtime_invoke_void_string
(object,intptr,intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke
(object,object[]) <0x00004>
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke
(object,object[]) <0xffffffff>
  at System.Reflection.MonoMethod.Invoke
(object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo)
<0x0009a>
  at System.Reflection.MethodBase.Invoke (object,object[]) <0x0001a>
  at System.Delegate.DynamicInvokeImpl (object[]) <0x00183>
  at System.MulticastDelegate.DynamicInvokeImpl (object[]) <0x0002a>
  at System.Delegate.DynamicInvoke (object[]) <0x0000e>
  at NDesk.DBus.Connection.HandleSignal (NDesk.DBus.Message) <0x000ee>
  at NDesk.DBus.Connection.DispatchSignals () <0x0003c>
  at NDesk.DBus.Connection.Iterate () <0x0002c>
  at <>c__CompilerGenerated0.<>c__AnonymousMethod1
(intptr,NDesk.GLib.IOCondition,intptr) <0x00027>
  at (wrapper native-to-managed) <>c__CompilerGenerated0.<>c__AnonymousMethod1
(intptr,NDesk.GLib.IOCondition,intptr) <0xffffffff>
  at (wrapper managed-to-native) Gtk.Application.gtk_main () <0x00004>
  at (wrapper managed-to-native) Gtk.Application.gtk_main () <0xffffffff>
  at Gtk.Application.Run () <0x00007>
  at Banshee.Gui.GtkBaseClient.Run () <0x00064>
  at Banshee.Gui.GtkBaseClient.Startup () <0x00034>
  at Hyena.Gui.CleanRoomStartup.Startup
(Hyena.Gui.CleanRoomStartup/StartupInvocationHandler) <0x000a2>
  at Banshee.Gui.GtkBaseClient.Startup () <0x0004d>
  at Banshee.Gui.GtkBaseClient.Startup (string[]) <0x000a6>
  at Nereid.Client.Main (string[]) <0x0000a>
  at (wrapper runtime-invoke) Nereid.Client.runtime_invoke_void_string[]
(object,intptr,intptr,intptr) <0xffffffff>
  at (wrapper managed-to-native) System.AppDomain.ExecuteAssembly
(string,System.Security.Policy.Evidence,string[]) <0x00004>
  at (wrapper managed-to-native) System.AppDomain.ExecuteAssembly
(string,System.Security.Policy.Evidence,string[]) <0xffffffff>
  at (wrapper remoting-invoke-with-check) System.AppDomain.ExecuteAssembly
(string,System.Security.Policy.Evidence,string[]) <0xffffffff>
  at System.AppDomain.ExecuteAssembly (string) <0x00014>
  at (wrapper remoting-invoke-with-check) System.AppDomain.ExecuteAssembly
(string) <0xffffffff>
  at Booter.Booter.BootClient (string) <0x00055>
  at Booter.Booter.Main () <0x00188>
  at (wrapper runtime-invoke) Booter.Booter.runtime_invoke_void
(object,intptr,intptr,intptr) <0xffffffff>
Comment 6 Félix Velasco 2008-11-13 08:14:18 UTC
I ran into a similar problem some time ago, but it was related to a weird usb pendrive. It reported two independent logical drives, which provoked a deadlock with banshee. I'm not talking about two partitions (i.e., /dev/sdb1 and /dev/sdb2) but two different drives (/dev/sdb & /dev/sdc).

Do your drives have the same configuration?
Comment 7 kakyoism 2008-11-13 08:36:26 UTC
/dev/sde1            
/dev/sdb1             
/dev/sdc1             
/dev/sdd1

These are my mounted USB-drives.
Can you explain to me? I don't quite understand.
Thanks.
Comment 8 Félix Velasco 2008-11-13 08:39:51 UTC
Do all of these drives belong to the same physical usb pendrive, or do you have four different usb pendrives plugged into your pc?
Comment 9 Michał Sawicz 2008-11-13 08:53:52 UTC
Mine don't, I do have three partitions on it, although they all show up as one /dev/sdx device.
Comment 10 kakyoism 2008-11-13 17:35:28 UTC
To Felix,

They are 4 physical drives.
Comment 11 Félix Velasco 2008-11-15 18:23:11 UTC
Seems related to this bug: https://bugzilla.novell.com/show_bug.cgi?id=430491
Banshee always freezes banshee when I plug in my usb stick, and then unfreezes with two kill -3 signals.
I get the same behavior both with DAAP activated and deactivated, as suggested in the other bug.
It's a rather disturbing behavior...
Comment 12 Félix Velasco 2008-11-15 19:56:49 UTC
I've been looking into the code of dbus-sharp, and it seems not to like questions made from threads different of his "main thread", unless you're using "iterate", that cheats.

All in all, it seems we shouldn't use the scheduler with dbus-sharp. I'm adding a fast patch for testing. Michał, kakyoism, could you apply the patch and test if it solves your problem?

If it works, I'll post a better (not so hackish) patch.
Comment 13 Félix Velasco 2008-11-15 19:58:36 UTC
Created attachment 122745 [details] [review]
Don't use Scheduler from DapSource, run synchronously
Comment 14 Félix Velasco 2008-12-04 20:30:25 UTC
Created attachment 123962 [details] [review]
Add USB disks synchronously

Remove unnecessary code if we're running this synchronously
Comment 15 Gabriel Burt 2008-12-16 23:55:26 UTC
Does this actually fix the problem for you?  The mapping was put not on the main thread on purpose in this commit:

2008-05-06  Gabriel Burt  <gabriel.burt@gmail.com>

    * src/Dap/Banshee.Dap/Banshee.Dap/DapService.cs: Make sure the device
    mapping doesn't happen on the main thread.  Aaron will love this.  MTP's
    DeviceInitialize method can be very slow (10+ seconds) and we definitely
    shouldn't block the ui for it.
Comment 16 Félix Velasco 2008-12-17 10:06:02 UTC
When I insert the usb disk with banshee running, the UI hangs if the code runs in a separate thread, but the patch does fix my problem. I don't see any freezing or blocking with it.
Comment 17 Gabriel Burt 2009-01-13 17:38:12 UTC
Ok, well we can't run all that on the main thread b/c it could (and does, specifically w/ MTP devices) take quite a while - which will make the UI appear to freeze.
Comment 18 Félix Velasco 2009-01-23 21:05:54 UTC
I've found the original problem. It's, after all, a deadlock.

In NDesk.DBus, when a thread different than the "main" one (the one that called DBusG.init first) asks for any information, what really happens is that a question is asked to DBus, and the thread is made to wait until it's answered. The problem is that the answer is only read in the "main" thread, that happens to be the glib main loop.

But since I'm inserting a USB stick with two volumes on it, two different events are fired, almost simultaneously. What happens is that the glib thread waits in the lock at the MapDevice method for a lock that never gets freed, since DBus is waiting for that thread to process the answer to its last question.

Anyway, there's no need for the lock at the MapDevice method, so simply removing it solves the problem, and allows for the DAP code to run in background.
Comment 19 Félix Velasco 2009-01-23 21:06:32 UTC
Created attachment 127126 [details] [review]
Remove unnecessary lock
Comment 20 Gabriel Burt 2009-01-23 21:17:14 UTC
Félix, you've tested w/ and w/o this patch and it fixes the problem?  (Or is it just a guess/logic that it would fix it?)

Sounds like we should fix NDesk.DBus too - I bet we have quite a few other possible freezes like this (one in DAAP, among other places).
Comment 21 Félix Velasco 2009-01-23 22:54:11 UTC
I've tested the patch, and it works with it, hangs without it.

You can test it very easily if you just add a 20 seconds sleep at the beginning or the Run method in MapDeviceJob, and insert two USB devices, within the interval. It should be enough to freeze the UI. But this experiment is just a logical guess, I can't make it right now.
Comment 22 Gabriel Burt 2009-01-23 23:01:40 UTC
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.