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 662309 - banshee crashes silently, periodically in ZeroConf / Avahi code.
banshee crashes silently, periodically in ZeroConf / Avahi code.
Status: RESOLVED NOTGNOME
Product: banshee
Classification: Other
Component: DAAP
2.2.0
Other Linux
: Normal major
: ---
Assigned To: Banshee Maintainers
Banshee Maintainers
: 652161 662632 663388 664089 664686 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-10-20 16:46 UTC by Stephen A. Goss
Modified: 2011-11-28 15:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Rough patch porting mono-zeroconf to dbus# (9.07 KB, patch)
2011-10-25 10:58 UTC, Chow Loong Jin
none Details | Review
New Mono.Zeroconf trace (6.74 KB, text/plain)
2011-11-06 18:11 UTC, Chow Loong Jin
  Details
Mono.Zeroconf trace with DBus# (6.27 KB, text/plain)
2011-11-07 01:30 UTC, Chow Loong Jin
  Details

Description Stephen A. Goss 2011-10-20 16:46:12 UTC
Running banshee 2.2.0 that ships with 64 bit Ubuntu 11.10, it crashes every few hours. I ran it from the console (banshee --debug) and when it crashed, it spat this message:

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.Zeroconf.Providers.AvahiDBus.BrowseService.DisposeResolver () [0x00000] in <filename unknown>:0 
  at Mono.Zeroconf.Providers.AvahiDBus.BrowseService.Dispose () [0x00000] in <filename unknown>:0 
  at Mono.Zeroconf.Providers.AvahiDBus.ServiceBrowser.OnItemRemove (Int32 interface, Protocol protocol, System.String name, System.String type, System.String domain, LookupResultFlags flags) [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00000] in <filename unknown>:0 
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <filename unknown>:0 
  at NDesk.DBus.Connection.HandleSignal (NDesk.DBus.Message msg) [0x00000] in <filename unknown>:0 
  at NDesk.DBus.Connection.DispatchSignals () [0x00000] in <filename unknown>:0 
  at NDesk.DBus.Connection.Iterate () [0x00000] in <filename unknown>:0 
  at Mono.Zeroconf.Providers.AvahiDBus.DBusManager.IterateThread (System.Object o) [0x00000] in <filename unknown>:0 


It was paused at the time, but it also crashes sometimes in the middle of playing a track.
Comment 1 Bertrand Lorentz 2011-10-24 18:46:49 UTC
*** Bug 662632 has been marked as a duplicate of this bug. ***
Comment 2 Andrés G. Aragoneses (IRC: knocte) 2011-10-25 10:41:13 UTC
I guess best thing to do is migrate MonoZeroconf to dbus-sharp. Wasn't someone
working on this already? (IIRC from what I read on IRC)
Comment 3 Chow Loong Jin 2011-10-25 10:55:57 UTC
I did try. But the resultant mono-zeroconf didn't resolve anything at all. =\
Comment 4 Chow Loong Jin 2011-10-25 10:58:29 UTC
Created attachment 199918 [details] [review]
Rough patch porting mono-zeroconf to dbus#

Here's what I came up with. It compiles, but apparently doesn't work, based on what I've heard on IRC.
Comment 5 Andrés G. Aragoneses (IRC: knocte) 2011-10-25 11:02:27 UTC
Ah, well, good work. I guess it's still better to have this bug in dbus-sharp than in NDeskDbus. Is there a maintainer that can approve that patch to Mono.Zeroconf? Did you do a pull request?
Comment 6 Chow Loong Jin 2011-10-25 11:04:28 UTC
Nope, I couldn't find an upstream to push the patch to. Same goes for notify-sharp which I just made a patch for earlier today.
Comment 7 Bertrand Lorentz 2011-11-01 15:07:47 UTC
Could anyone who is experiencing the bug confirm that disabling the DAAP extension fixes the issue ?

FYI, hyperair's pull request is at https://github.com/mono/Mono.Zeroconf/pull/5

Does it help with this issue ?
Comment 8 Chow Loong Jin 2011-11-01 16:02:24 UTC
Someone confirmed that disabling DAAP fixes the issue on IRC. The same person confirmed that my patch caused the DAAP extension to not detect any servers.
Comment 9 Stephen A. Goss 2011-11-02 21:11:08 UTC
I haven't seen this crash anymore after disabling DAAP.
Comment 10 Chow Loong Jin 2011-11-06 02:09:04 UTC
Braindump:
A certain someone bundled NDesk.DBus *and modified* it in Mono.Zeroconf. TrapSignals and UntrapSignals which I removed from Mono.Zeroconf code was *never* there in NDesk.DBus in the first place.

https://github.com/mono/Mono.Zeroconf/commit/3e2358e67a398b65fe1385446d889c75f5525392 for more details.

Does anyone know what I should do from here on out? Bundle another DBus# and patch TrapSignals in again?
Comment 11 Chow Loong Jin 2011-11-06 03:48:52 UTC
Okay, it looks like the signals are coming in between the ServiceBrowserNew call and adding event handlers in ServiceBrowser.cs, which is why TrapSignals is needed.

avahi-client on the other hand uses a filter on DBus messages to get these signals and pass them to the respective objects. It looks like a pretty ugly solution. I would try duplicating this in Mono.Zeroconf but it looks like DBus# is incapable of filtering just yet.
Comment 12 Bertrand Lorentz 2011-11-06 16:56:57 UTC
After several attempts at killing a DAAP server (Tangerine) while Banshee is running, I was not able to reproduce the crash.

Could someone able to reproduce this issue provide a stack trace with line numbers ?

Another idea to investigate this: add logs in the 2 event handlers that end up calling BrowseService.DisposeResolver (BrowseService.OnResolveFailure and ServiceBrowser.OnItemRemove). Maybe they are triggered at the same time ?
Although there are locks in place, so it shouldn't be a problem, but you never know...
Comment 13 Chow Loong Jin 2011-11-06 18:11:16 UTC
Created attachment 200842 [details]
New Mono.Zeroconf trace

Looks like there's a reentrant Dispose() here, which is why the locking isn't working as it should.
Comment 14 Chow Loong Jin 2011-11-06 18:26:37 UTC
A workaround would be to take a local reference to resolver in the DisposeResolver() function, and nullify the class's resolver reference before doing the cleanup.

This could very well be a NDesk.DBus bug though. I'm not sure if NDesk.DBus is supposed to be able to dispatch signals while removing signal handlers.
Comment 15 Bertrand Lorentz 2011-11-06 19:14:45 UTC
Hmm, this reminded me of another weird dbus-related bug, which was caused by two races in NDesk.DBus : bug #627441.

The two patches for dbus-sharp are :
http://github.com/mono/dbus-sharp/commit/84f2126
http://github.com/garuma/dbus-sharp/commit/055982

Could try to apply them to the in-tree copy of NDesk.DBus inside Mono.ZeroConf, to see if it helps ?
Comment 16 Chow Loong Jin 2011-11-06 23:29:18 UTC
I can't find https://github.com/garuma/dbus-sharp/commit/055982 in my dbus-sharp tree even after fetching from that tree. Is that commit possibly unreachable/rebased out?
Comment 17 Chow Loong Jin 2011-11-07 00:38:53 UTC
Hmm, the patches don't apply on NDesk.DBus. I'm going to try isolating the TrapSignals change (hopefully that's all abock did) to DBus# and seeing if that works.
Comment 18 Chow Loong Jin 2011-11-07 01:30:00 UTC
Created attachment 200860 [details]
Mono.Zeroconf trace with DBus#

Here's a trace after porting to a patched DBus# (from garuma's improved branch). It looks more or less the same as NDesk.DBus, so either DBus# is meant to behave like that, or the bug is still present.
Comment 19 Chow Loong Jin 2011-11-07 03:28:09 UTC
Well I think we've more or less figured out that this bug doesn't belong to Banshee, so could a maintainer close this as NOTGNOME, please?

Thanks for all the help in debugging this issue!

For those interested:-
- https://github.com/mono/Mono.Zeroconf/pull/6 has a fix/workaround for this crasher.
- The DBus# port can wait until DBus# gains TrapSignals/UntrapSignals, as shown in https://github.com/mono/dbus-sharp/pull/23, because continuing to bundle  DBus# is not nice.
- I'm assuming that NDesk.DBus/DBus# is not wrong in dispatching more signals while attempting to remove the signal handler.
Comment 20 Bertrand Lorentz 2011-11-07 06:53:07 UTC
Closing as NOTGNOME, as the problem is with Mono.Zeroconf (see previous comment).
Comment 21 Bertrand Lorentz 2011-11-13 10:34:18 UTC
*** Bug 663388 has been marked as a duplicate of this bug. ***
Comment 22 Bertrand Lorentz 2011-11-14 19:06:15 UTC
*** Bug 652161 has been marked as a duplicate of this bug. ***
Comment 23 Bertrand Lorentz 2011-11-15 19:44:08 UTC
*** Bug 664089 has been marked as a duplicate of this bug. ***
Comment 24 Bertrand Lorentz 2011-11-28 15:17:03 UTC
*** Bug 664686 has been marked as a duplicate of this bug. ***