dmix icon indicating copy to clipboard operation
dmix copied to clipboard

control chars in file path cause crash on every launch getting Album Cache

Open eighthave opened this issue 9 years ago • 12 comments

I set up MPDroid on a stock Moto G running the latest firmware, Android 5.1. It was working fine but recently, it started crashing shortly after starting. It does this every single time. The server is running stock mpd from Debian/jessie.

                            Process com.namelessdev.mpdroid created for activity com.namelessdev.mpdroid/.MainMenuActivity
                            PID: 18463   UID:    GIDs: 

         MPDApplication  D  onCreate Application
            Crashlytics  I  Initializing Crashlytics 1.1.13.29
             AlbumCache  D  Starting ...
                         D  set MPD
                         D  no MPDConnection!
     NowPlayingFragment  I  Initialization succeeded
         OpenGLRenderer  D  Use EGL_SWAP_BEHAVIOR_PRESERVED: true
                  Atlas  D  Validating map...
             Adreno-EGL  I  <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.00.02.042.016_msm8226_LA.BF.1.1.1_RB1__release_AU ()
                         I  OpenGL ES Shader Compiler Version: E031.25.03.00
                         I  Build Date: 02/11/15 Wed
                         I  Local Branch:
                         I  Remote Branch: quic/LA.BF.1.1.1_rb1.10
                         I  Local Patches: NONE
                         I  Reconstruct Branch: AU_LINUX_ANDROID_LA.BF.1.1.1_RB1.05.00.02.042.016 + 62ca4eb + acd831d + 9f8b442 + e027a02 + cba30ba + 53c303a + a649d79 + 23e16f8 + 5e97da7 + cbd2a44 + 33d072a 
                            + 7aacf06 + 72b33e7 + 28f6f60 + b4c13d8 +  NOTHING
         OpenGLRenderer  I  Initialized EGL, version 1.4
                         D  Enabling debug mode 0
              Resources  W  Converting to string: TypedValue{t=0x4/d=0x3f800000 a=2 r=0x7f0c00e9}
                         W  Converting to string: TypedValue{t=0x4/d=0x3f800000 a=2 r=0x7f0c00e9}
                   View  W  requestLayout() improperly called by android.widget.ListView{188dd1d0 IFED.VC. ......ID -480,0-0,1134 #7f0a007a app:id/left_drawer} during layout: running second layout pass
         MPDApplication  D  MPDApplication is bound to the service.
IInputConnectionWrapper  W  showStatusIcon on inactive InputConnection
             AlbumCache  D  server flick.fritz.box port 6600 dir /data/data/com.namelessdev.mpdroid/cache
                         D  Cache is NOT up to date. fetching ...
         AndroidRuntime  E  FATAL EXCEPTION: MPDAsyncWorker
                         E  Process: com.namelessdev.mpdroid, PID: 18463
                         E  org.a0z.mpd.exception.InvalidResponseException: Failed to parse server response key for line: ey
                         E      at org.a0z.mpd.Tools.splitResponse(Tools.java:259)
                         E      at org.a0z.mpd.Tools.splitResponse(Tools.java:241)
                         E      at org.a0z.mpd.item.AbstractMusic.build(AbstractMusic.java:198)
                         E      at org.a0z.mpd.item.AbstractMusic.getMusicFromList(AbstractMusic.java:369)
                         E      at org.a0z.mpd.MPD.listAllInfo(MPD.java:1341)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.refresh(AlbumCache.java:283)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.updateConnection(AlbumCache.java:416)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.refresh(AlbumCache.java:264)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.refresh(AlbumCache.java:254)
                         E      at com.namelessdev.mpdroid.helpers.CachedMPD.isCached(CachedMPD.java:196)
                         E      at com.namelessdev.mpdroid.helpers.CachedMPD.getAllAlbums(CachedMPD.java:159)
                         E      at org.a0z.mpd.MPD.getAlbums(MPD.java:743)
                         E      at org.a0z.mpd.MPD.getAlbums(MPD.java:726)
                         E      at com.namelessdev.mpdroid.fragments.AlbumsFragment.asyncUpdate(AlbumsFragment.java:131)
                         E      at com.namelessdev.mpdroid.fragments.BrowseFragment$5.run(BrowseFragment.java:541)
                         E      at com.namelessdev.mpdroid.helpers.MPDAsyncWorker.handleMessage(MPDAsyncWorker.java:149)
                         E      at android.os.Handler.dispatchMessage(Handler.java:98)
                         E      at android.os.Looper.loop(Looper.java:135)
                         E      at android.os.HandlerThread.run(HandlerThread.java:61)

                            Process com.android.vending (PID: 18141) ended

            Crashlytics  I  Crashlytics report upload complete: 56940D9B0130-0001-481F-471FA92D3AB6.cls
         MPDApplication  W  Disconnecting (15000 ms timeout)

eighthave avatar Jan 11 '16 20:01 eighthave

I have no idea why the Album Cache crashes, but you could switch it off in the meantime. What's the mpd version?

hurzl avatar Jan 11 '16 20:01 hurzl

what's odd is that MPDroid continued to work fine on my tablet running 4.4.4 with the same server.

https://packages.debian.org/jessie/mpd 0.19.1-1.1

eighthave avatar Jan 11 '16 20:01 eighthave

updating mpd to 0.19.12-1~bpo8+1 didn't fix it

eighthave avatar Jan 11 '16 20:01 eighthave

It seems to be a slowly spreading infection. Now my Nexus 7 2013 running CyanogenMod is getting the same thing. I don't have time to get in and change the settings before it crashes, or I'd try to disable the album cache. Here's the stacktrace:

               Timeline  I  Timeline: Activity_launch_request id:com.namelessdev.mpdroid time:7911525

                            Process com.namelessdev.mpdroid created for activity com.namelessdev.mpdroid/.MainMenuActivity
                            PID: 10012   UID:    GIDs: 

         MPDApplication  D  onCreate Application
             AlbumCache  D  Starting ...
                         D  set MPD
                         D  no MPDConnection!
     NowPlayingFragment  I  Initialization succeeded
         OpenGLRenderer  D  Use EGL_SWAP_BEHAVIOR_PRESERVED: true
                  Atlas  D  Validating map...
         MPDroidService  D  Message received: NotificationHandler.START
             Adreno-EGL  I  <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/15/15, ab0075f, Id3510ff6dc
         OpenGLRenderer  I  Initialized EGL, version 1.4
                         D  Enabling debug mode 0
              Resources  W  Converting to string: TypedValue{t=0x4/d=0x3f800000 a=3 r=0x7f0c00e8}
                         W  Converting to string: TypedValue{t=0x4/d=0x3f800000 a=3 r=0x7f0c00e8}
         MPDApplication  D  MPDApplication is bound to the service.
                Sticker  D  Rating doesn't exist for this entry: composer/Warmdesk/Warmdesk-Encaustic.mp3
             AlbumCache  D  server 10.4.0.1 port 6600 dir /data/data/com.namelessdev.mpdroid/cache
                         D  Cache is NOT up to date. fetching ...
         AndroidRuntime  E  FATAL EXCEPTION: MPDAsyncWorker
                         E  Process: com.namelessdev.mpdroid, PID: 10012
                         E  org.a0z.mpd.exception.InvalidResponseException: Failed to parse server response key for line: ey
                         E      at org.a0z.mpd.Tools.splitResponse(Tools.java:259)
                         E      at org.a0z.mpd.Tools.splitResponse(Tools.java:241)
                         E      at org.a0z.mpd.item.AbstractMusic.build(AbstractMusic.java:198)
                         E      at org.a0z.mpd.item.AbstractMusic.getMusicFromList(AbstractMusic.java:369)
                         E      at org.a0z.mpd.MPD.listAllInfo(MPD.java:1341)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.refresh(AlbumCache.java:283)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.updateConnection(AlbumCache.java:416)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.refresh(AlbumCache.java:264)
                         E      at com.namelessdev.mpdroid.helpers.AlbumCache.refresh(AlbumCache.java:254)
                         E      at com.namelessdev.mpdroid.helpers.CachedMPD.isCached(CachedMPD.java:196)
                         E      at com.namelessdev.mpdroid.helpers.CachedMPD.getAllAlbums(CachedMPD.java:159)
                         E      at org.a0z.mpd.MPD.getAlbums(MPD.java:743)
                         E      at org.a0z.mpd.MPD.getAlbums(MPD.java:726)
                         E      at com.namelessdev.mpdroid.fragments.AlbumsFragment.asyncUpdate(AlbumsFragment.java:131)
                         E      at com.namelessdev.mpdroid.fragments.BrowseFragment$5.run(BrowseFragment.java:541)
                         E      at com.namelessdev.mpdroid.helpers.MPDAsyncWorker.handleMessage(MPDAsyncWorker.java:149)
                         E      at android.os.Handler.dispatchMessage(Handler.java:98)
                         E      at android.os.Looper.loop(Looper.java:135)
                         E      at android.os.HandlerThread.run(HandlerThread.java:61)
               Timeline  I  Timeline: Activity_idle id: android.os.BinderProxy@3da1e6b0 time:7917662
         OpenGLRenderer  W  Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
                         W  Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
           ResourceType  W  No package identifier when getting value for resource number 0x00000000
         PackageManager  W  Failure retrieving resources for com.namelessdev.mpdroid: Resource ID #0x0
 DefaultRequestDirector  W  Authentication error: Unable to respond to any of these challenges: {}
                         W  Authentication error: Unable to respond to any of these challenges: {}
         MPDApplication  W  Disconnecting (15000 ms timeout)
    HeadsetStateMachine  D  Disconnected process message: 10, size: 0

eighthave avatar Jan 12 '16 07:01 eighthave

I wonder about the "ey" as a response line, maybe you have some title containing line breaks?

To get into the settings you probably have to stop the server.

hurzl avatar Jan 12 '16 08:01 hurzl

that's possible, I have a bunch of old mp3s that I downloaded ~15 years ago, back in the wild days of napster and all. They can have some pretty messed up ID3 tags. Any tips on how I could find the culprit? It seems to me that newlines should be filtered out.

eighthave avatar Jan 12 '16 15:01 eighthave

Search for "ey"?

hurzl avatar Jan 12 '16 16:01 hurzl

Turns out it is a strange character in a directory name that is triggering the crash:

I\ was\ young\ and\ i\ needed\ the\ mon^Mey

Tools.splitResponse: directory: archive/dan/Clifford Gilberto/I was young and i needed the mon Tools.splitResponse: ey

eighthave avatar Jan 17 '16 21:01 eighthave

^M is a (windows) newline, I knew it ;) Yes it should be filtered, but having it in the tag is also an error ...

hurzl avatar Jan 17 '16 22:01 hurzl

Its not in the tag, its in the filename. So while its annoying, it is a valid character in a filename. I've used this same music collection in many music players (iTunes, rhythmbox, songbird, etc) so it is something that is handled by them. Of course, the network socket aspect of MPD makes handling weird characters in filenames harder.

I dug around in MPDroid/dmix code a bit, as far as I could tell, this bug might need to be fixed in MPD itself, as in making MPD escape troublesome characters somehow.

eighthave avatar Jan 18 '16 09:01 eighthave

AFAIK the response is split by lines so if you have a newline you will get both incomplete and unparseable lines. Which should at least be ignored.

hurzl avatar Jan 19 '16 22:01 hurzl

yeah, so the first step would be to make MPDroid not crash when it encounters such things, and then the second would be to make MPD escape any characters that are part of the protocol. If MPD is sending file paths, then it needs to support all the characters that common file systems do:

  • OSX's HFS+ "Unicode, any character, including NUL" https://en.wikipedia.org/wiki/HFS_Plus
  • ext2/3/4 "All bytes except NUL ('\0') and '/'" https://en.wikipedia.org/wiki/Ext2
  • FAT/ExFAT "Unicode UTF-16 except U+0000 (NUL) through U+001F (US) / (slash) \ (backslash) : (colon) * (asterisk) ? (Question mark) " (quote) < (less than) > (greater than) and | (pipe)" https://en.wikipedia.org/wiki/ExFAT
  • NTFS "In POSIX namespace, any UTF-16 code unit (case-sensitive) except U+0000 (NUL) and / (slash). In Win32 namespace, any UTF-16 code unit (case-insensitive) except U+0000 (NUL) / (slash) \ (backslash) : (colon) * (asterisk) ? (Question mark) " (quote) < (less than) > (greater than) and | (pipe)[5]" https://en.wikipedia.org/wiki/NTFS

So all of the major filesystems allow newline characters in file names.

eighthave avatar Jan 20 '16 11:01 eighthave