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 538206 - Banshee crashes on Last.FM login
Banshee crashes on Last.FM login
Status: RESOLVED FIXED
Product: banshee
Classification: Other
Component: Last.fm
git master
Other All
: Normal critical
: 1.x
Assigned To: Gabriel Burt
Depends on:
Blocks:
 
 
Reported: 2008-06-13 20:52 UTC by Chow Loong Jin
Modified: 2008-09-04 16:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
--debug output for last.fm crash (8.03 KB, text/plain)
2008-08-25 15:37 UTC, Iain Lane
  Details
Printing out cache_file's contents (4.49 KB, text/plain)
2008-08-25 16:25 UTC, Iain Lane
  Details
Patch to not check for invalid characters (1.11 KB, patch)
2008-08-28 16:59 UTC, Iain Lane
needs-work Details | Review
Patch to not check for invalid characters (1.15 KB, patch)
2008-08-28 22:16 UTC, Iain Lane
committed Details | Review

Description Chow Loong Jin 2008-06-13 20:52:05 UTC
Steps to reproduce:
1. Open Banshee 1.0.0
2. Click on the Last.FM source.
3. Banshee crashes with the below stack trace


Stack trace:
[Info 02:30:12.126] Running Banshee 1.0.0
[Info 02:30:15.267] All services are started 2,602562s
[Info 02:30:19.979] nereid Client Started

(Nereid:26267): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(Nereid:26267): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.Xml.XmlException: Not allowed character was found. Line 20, position 33.
  at Mono.Xml2.XmlTextReader.ReadText (Boolean notWhitespace) [0x00000]
  at Mono.Xml2.XmlTextReader.ReadContent () [0x00000]
  at Mono.Xml2.XmlTextReader.Read () [0x00000]
  at System.Xml.XmlTextReader.Read () [0x00000]
  at Mono.Xml.EntityResolvingXmlReader.Read () [0x00000]
  at Mono.Xml.Schema.XsdValidatingReader.Read () [0x00000]
  at System.Xml.XmlValidatingReader.Read () [0x00000]
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000]
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000]
  at System.Xml.XmlDocument.ReadNodeCore (System.Xml.XmlReader reader) [0x00000]
  at System.Xml.XmlDocument.ReadNode (System.Xml.XmlReader reader) [0x00000]
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader xmlReader) [0x00000]
  at System.Xml.XmlDocument.Load (System.IO.TextReader txtReader) [0x00000]
  at Lastfm.Data.LastfmData`1[Lastfm.Data.RecentTrack].GetData () [0x0001d] in /build/buildd/banshee-1-1.0.0/src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs:98
  at Lastfm.Data.LastfmData`1[Lastfm.Data.RecentTrack]..ctor (System.String , CacheDuration , System.String ) [0x00040] in /build/buildd/banshee-1-1.0.0/src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs:79
  at Lastfm.Data.LastfmData`1[Lastfm.Data.RecentTrack]..ctor (System.String , System.String ) [0x00000] in /build/buildd/banshee-1-1.0.0/src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs:62
  at Lastfm.Data.LastfmUserData.Get[RecentTrack] (System.String fragment, System.String xpath) [0x00023] in /build/buildd/banshee-1-1.0.0/src/Libraries/Lastfm/Lastfm.Data/LastfmUserData.cs:67
  at Lastfm.Data.LastfmUserData.Get[RecentTrack] (System.String fragment) [0x00000] in /build/buildd/banshee-1-1.0.0/src/Libraries/Lastfm/Lastfm.Data/LastfmUserData.cs:58
  at Lastfm.Data.LastfmUserData.get_RecentTracks () [0x00000] in /build/buildd/banshee-1-1.0.0/src/Libraries/Lastfm/Lastfm.Data/LastfmUserData.cs:131
  at Banshee.Lastfm.Radio.LastfmSourceContents.UpdateForUser (System.String username) [0x0011d] in /build/buildd/banshee-1-1.0.0/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSourceContents.cs:138
  at Banshee.Lastfm.Radio.LastfmSourceContents+<>c__CompilerGenerated4.<HandleConnectionStateChanged>c__23 (System.Object +13, System.EventArgs +14) [0x00025] in /build/buildd/banshee-1-1.0.0/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSourceContents.cs:149
  at Banshee.ServiceStack.Application+<>c__CompilerGenerated29.<Invoke>c__68 () [0x00000] in /build/buildd/banshee-1-1.0.0/src/Core/Banshee.Services/Banshee.ServiceStack/Application.cs:165
  at Banshee.Gui.GtkBaseClient+<>c__CompilerGenerated18.<RunIdle>c__70 () [0x00000] in /build/buildd/banshee-1-1.0.0/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:201
  at GLib.Idle+IdleProxy.Handler () [0x00000]
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at GLib.Idle+IdleProxy.Handler()
   at GLib.Idle+IdleProxy.Handler()
   at Gtk.Application.gtk_main()
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at Banshee.Gui.GtkBaseClient.Run() in /build/buildd/banshee-1-1.0.0/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:line 114
   at Banshee.Gui.GtkBaseClient.Startup() in /build/buildd/banshee-1-1.0.0/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:line 55
   at Hyena.Gui.CleanRoomStartup.Startup(Hyena.Gui.StartupInvocationHandler startup) in /build/buildd/banshee-1-1.0.0/src/Libraries/Hyena.Gui/Hyena.Gui/CleanRoomStartup.cs:line 54
   at Banshee.Gui.GtkBaseClient.Entry() in /build/buildd/banshee-1-1.0.0/src/Core/Banshee.ThickClient/Banshee.Gui/GtkBaseClient.cs:line 50
   at Nereid.Client.Main(System.String[] args) in /build/buildd/banshee-1-1.0.0/src/Clients/Nereid/Nereid/Client.cs:line 77

Other information:
This bug originated from here: https://bugs.launchpad.net/ubuntu/+source/banshee/+bug/239346

Although this user has experienced the bug, there are other Ubuntu Hardy users who do not experience this bug.
Comment 1 Chow Loong Jin 2008-08-24 23:37:53 UTC
Bumping the version up due to confirmation that it still happens in 1.2.1 by Mattias Larsson.
Comment 2 Iain Lane 2008-08-25 14:40:03 UTC
I can confirm this on 1.2.1 also.
Comment 3 Iain Lane 2008-08-25 14:48:03 UTC
and SVN trunk.
Comment 4 Andrew Conkling 2008-08-25 15:01:05 UTC
Does this happen every time? What Last.fm stations do you have configured? Are you a Last.fm subscriber? Can you post the output of 'banshee-1 --debug'? And are there any other details you can add to help narrow down the problem?
Comment 5 Iain Lane 2008-08-25 15:37:23 UTC
Yes, repeatable every time. No stations added, and just to be double sure I purged my configuration and started again (.config/banshee-1 and gconf). No change. Attaching the --debug output now, although it is just the same as the previous one.
Comment 6 Iain Lane 2008-08-25 15:37:56 UTC
Created attachment 117349 [details]
--debug output for last.fm crash
Comment 7 Andrew Conkling 2008-08-25 16:23:56 UTC
(In reply to comment #5)
> Attaching the --debug output now, although it is just the same as the
> previous one.

The stacktrace may be, but I want to look at the preceding debug output from the time when Banshee starts. Thanks for attaching.
Comment 8 Iain Lane 2008-08-25 16:25:33 UTC
Created attachment 117352 [details]
Printing out cache_file's contents

I added a quick loop to print out cache_file's contents with line numbers when GetData is called in LastFmData.cs. Code here (inserted above line 101):

StreamReader sr = new StreamReader (cache_file);
for (int i = 0; !sr.EndOfStream; ++i)
	Console.WriteLine(String.Format("{0} {1}", i+1, sr.ReadLine()));

The attached file shows the output of this. It looks like a specific track that I've played in the past is causing this crash - there are some weird characters in the tags.
Comment 9 Iain Lane 2008-08-26 22:14:09 UTC
Excellent, I've confirmed that what I posted above is indeed the cause - played a load of songs to move the problematic one off my last.fm recent playlist, cleared the cache and tried last.fm again. Hey presto, it works!
Comment 10 Chow Loong Jin 2008-08-26 23:52:26 UTC
In that case, could you post the metadata of the song with the weird tags so it can get fixed or provide a patch?
Comment 11 Iain Lane 2008-08-27 16:47:22 UTC
It's in the cache_file attachment I posted, the line numbered 13. I've been messing with the code a bit, but am unable to fix it thus far. Thought it was an encoding issue but forcing utf-8 didn't make a difference.
Comment 12 Iain Lane 2008-08-28 16:49:04 UTC
The actual XML files that last.fm spits out are malformed, so I guess you could consider this a bug with their API.
Comment 13 Iain Lane 2008-08-28 16:59:17 UTC
Created attachment 117533 [details] [review]
Patch to not check for invalid characters

This patch will not check for invalid characters when reading XML data from Last.fm's API. The API accepts this data from clients and returns it to them - there's nothing we can really do about that (short of filing a bug) except trust that what it returns is right.
Comment 14 Iain Lane 2008-08-28 17:01:16 UTC
Comment on attachment 117533 [details] [review]
Patch to not check for invalid characters

>Index: src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs
>===================================================================
>--- src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs	(revision 4438)
>+++ src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs	(working copy)
>@@ -98,7 +98,11 @@
> 
>             // Load the XML from the new or cached local file
>             doc = new XmlDocument ();
>-            using (StreamReader reader = new StreamReader (cache_file)) {
>+
>+            XmlReaderSettings settings = new XmlReaderSettings();
>+            settings.CheckCharacters = false;
>+            
>+            using (XmlReader reader = XmlReader.Create(cache_file, settings)) {
>                 doc.Load (reader);
>             }
> 
>Index: ChangeLog
>===================================================================
>--- ChangeLog	(revision 4438)
>+++ ChangeLog	(working copy)
>@@ -1,3 +1,9 @@
>+2008-08-28  Iain Lane  <iain@orangesquash.org.uk>
>+
>+	* src/Libraries/Lastfm/Lastfm.Data/LastfmData.cs: Don't validate
>+	characters in XML returned from Last.fm - the API accepts (and returns)
>+	invalid characters sent to it.
>+
> 2008-08-27  Brad Taylor  <brad@getcoded.net>
> 
> 	* configure.ac:
Comment 15 Bertrand Lorentz 2008-08-28 20:32:40 UTC
Iain, 

Thanks for the patch. I think you modified the first version by editing the attachment, but having patches in comment makes them difficult to manage.
There are still some small formatting issues : please add a space before opening parentheses (see the HACKING file for details)

Could you attach a new version of your patch ?
Comment 16 Iain Lane 2008-08-28 22:16:52 UTC
Created attachment 117551 [details] [review]
Patch to not check for invalid characters

Right, sorry about that Bertrand. I hadn't anticipated what editing the patch would actually do, just thought it would *edit* it in place. Hopefully this one is OK - fixed tabbing and that missing space.
Comment 17 Bertrand Lorentz 2008-08-28 22:25:38 UTC
Thanks !

Looks good to me.
Actually, there another space missing in "XmlReader.Create(", but let's not be spacing fanatics ;)
Comment 18 Gabriel Burt 2008-09-04 04:25:24 UTC
Looks good, thanks!  Please commit, Bertrand.
Comment 19 Bertrand Lorentz 2008-09-04 16:55:04 UTC
Committed, thanks !