Version: 1.4.4 (using KDE KDE 3.5.5) Installed from: Gentoo Packages Compiler: gcc (GCC) 4.1.1 (Gentoo 4.1.1-r1) OS: Linux I tried to connect to my SanDisk Sansa e200, by adding a new MTP device. Amarok crashed. The last part of the output: amarok: BEGIN: void MediumPluginManager::newDevice() amarok: BEGIN: Medium* DeviceManager::getDevice(QString) amarok: DeviceManager: getDevice called with name argument = Sansa amarok: BEGIN: QStringList DeviceManager::getDeviceStringList() amarok: END__: QStringList DeviceManager::getDeviceStringList() - Took 0.0017s amarok: END__: Medium* DeviceManager::getDevice(QString) - Took 0.0021s amarok: [MediaBrowser] mediumAdded: (false,manual|Sansa|,Sansa,Sansa,,false,,,manual,false,,,) amarok: BEGIN: MediaDevice* MediaBrowser::loadDevicePlugin(const QString&) amarok: BEGIN: static Amarok::Plugin* PluginManager::createFromQuery(const QString&) amarok: [PluginManager] Plugin trader constraint: [X-KDE-Amarok-framework-version] == 27 and [X-KDE-Amarok-plugintype] == 'mediadevice' and [X-KDE-Amarok-name] == 'mtp-mediadevice' and [X-KDE-Amarok-rank] > 0 amarok: [PluginManager] Trying to load: libamarok_mtp-mediadevice amarok: amarok: PluginManager Service Info: amarok: --------------------------- amarok: name : MTP Media Device amarok: library : libamarok_mtp-mediadevice amarok: desktopEntryPath : amarok_mtp-mediadevice.desktop amarok: X-KDE-Amarok-plugintype : mediadevice amarok: X-KDE-Amarok-name : mtp-mediadevice amarok: X-KDE-Amarok-authors : (Andy Kelk) amarok: X-KDE-Amarok-rank : 100 amarok: X-KDE-Amarok-version : 1 amarok: X-KDE-Amarok-framework-version: 27 amarok: amarok: END__: static Amarok::Plugin* PluginManager::createFromQuery(const QString&) - Took 0.57s amarok: [MediaBrowser] Returning plugin! amarok: END__: MediaDevice* MediaBrowser::loadDevicePlugin(const QString&) - Took 0.57s amarok: BEGIN: virtual bool MtpMediaDevice::openDevice(bool) Autodetected device "SanDisk Sansa e200" (VID=0781,PID=7420) is known. PTP: Opening session Could not open session! (Return code 767) Try to reset the device. Connected to MTP device. amarok: [MtpMediaDevice] setting default parent : 0 amarok: BEGIN: int MtpMediaDevice::readMtpMusic() amarok: [MtpMediaDevice] Got tracks from device LIBMTP_Get_Playlist: Could not get object references LIBMTP_Get_Playlist: Could not get object references LIBMTP_Get_Playlist: Could not get object references Backtrace: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1243859248 (LWP 5473)] 0xb698e825 in QString::operator= () from /usr/qt/3/lib/libqt-mt.so.3 (gdb) bt #0 0xb698e825 in QString::operator= () from /usr/qt/3/lib/libqt-mt.so.3 #1 0xb6c82056 in KURL::operator= () from /usr/kde/3.5/lib/libkdecore.so.4 #2 0xb7ca886c in MetaBundle::operator= (this=0x89934f8, bundle=@0x4) at metabundle.cpp:301 #3 0xb7ca8bd0 in MetaBundle (this=0x89934f8, bundle=@0x4) at metabundle.cpp:286 #4 0xacf4ae77 in MtpTrack::bundle (this=0x0) at mtpmediadevice.h:47 #5 0xacf42bd2 in MtpMediaDevice::readPlaylists (this=0x89752f8) at mtpmediadevice.cpp:1331 #6 0xacf445bb in MtpMediaDevice::readMtpMusic (this=0x89752f8) at mtpmediadevice.cpp:1302 #7 0xacf449ae in MtpMediaDevice::openDevice (this=0x89752f8, silent=true) at mtpmediadevice.cpp:902 #8 0xb7c89adc in MediaDevice::connectDevice (this=0x89752f8, silent=true) at mediabrowser.cpp:2600 #9 0xb7c8b4a8 in MediaBrowser::addDevice (this=0x8457f20, device=0x89752f8) at mediabrowser.cpp:557 #10 0xb7c8b601 in MediaBrowser::mediumAdded (this=0x8457f20, medium=0x8921b28, constructing=false) at mediabrowser.cpp:1514 #11 0xb7c8bcfe in MediaBrowser::qt_invoke (this=0x8457f20, _id=48, _o=0xbfa79110) at mediabrowser.moc:286 #12 0xb66c2cc9 in QObject::activate_signal () from /usr/qt/3/lib/libqt-mt.so.3 #13 0xb7c94ddb in MediaDeviceManager::mediumAdded (this=0xb7ef7ba0, t0=0x8921b28, t1=@0xbfa79178) at mediadevicemanager.moc:131 #14 0xb7c95a79 in MediaDeviceManager::addManualDevice (this=0xb7ef7ba0, added=0x8921b28) at mediadevicemanager.cpp:99 #15 0xb7c9e975 in MediumPluginManager::newDevice (this=0x8921a58) at mediumpluginmanager.cpp:244 #16 0xb7c9eacf in MediumPluginManager::qt_invoke (this=0x8921a58, _id=3, _o=0xbfa792a8) at mediumpluginmanager.moc:244 #17 0xb66c2cc9 in QObject::activate_signal () from /usr/qt/3/lib/libqt-mt.so.3 #18 0xb66c391d in QObject::activate_signal () from /usr/qt/3/lib/libqt-mt.so.3 #19 0xb69fbf0c in QButton::clicked () from /usr/qt/3/lib/libqt-mt.so.3 #20 0xb675541d in QButton::mouseReleaseEvent () from /usr/qt/3/lib/libqt-mt.so.3 #21 0xb66faffa in QWidget::event () from /usr/qt/3/lib/libqt-mt.so.3 #22 0xb6664207 in QApplication::internalNotify () from /usr/qt/3/lib/libqt-mt.so.3 #23 0xb6664f59 in QApplication::notify () from /usr/qt/3/lib/libqt-mt.so.3 #24 0xb6d7ebee in KApplication::notify () from /usr/kde/3.5/lib/libkdecore.so.4 #25 0xb6605022 in QETWidget::translateMouseEvent () from /usr/qt/3/lib/libqt-mt.so.3 #26 0xb66048ef in QApplication::x11ProcessEvent () from /usr/qt/3/lib/libqt-mt.so.3 #27 0xb661493a in QEventLoop::processEvents () from /usr/qt/3/lib/libqt-mt.so.3 #28 0xb667a900 in QEventLoop::enterLoop () from /usr/qt/3/lib/libqt-mt.so.3 #29 0xb667a786 in QEventLoop::exec () from /usr/qt/3/lib/libqt-mt.so.3 #30 0xb6663c9f in QApplication::exec () from /usr/qt/3/lib/libqt-mt.so.3 #31 0x0804cfcf in main (argc=-1242459792, argv=0xb5f19170) at main.cpp:109
Can you try using the "mtp-playlists" utility from libmtp and post the results? Looks like there might be some invalid playlist entries in there.
Oh, you're right. Earlier, I tried to create a playlist, and failed miserably. The output of mtp-playlists: Autodetected device "SanDisk Sansa e200" (VID=0781,PID=7420) is known. PTP: Opening session Connected to MTP device. LIBMTP_Get_Playlist: Could not get object references LIBMTP_Get_Playlist: Could not get object references LIBMTP_Get_Playlist: Could not get object references Playlist ID: 393217 Tracks: 3866643: INVALID TRACK REFERENCE! Playlist ID: 393219 Tracks: Playlist ID: 393220 Tracks: Playlist ID: 393221 Tracks: PTP: Closing session OK.
Created attachment 18332 [details] Avoid crashing Amarok if a playlist has an invalid track ID in it OK. It looks like the player keeps a playlist with invalid track IDs in it. (I think my test device keeps consistency and so this situation would never occur). A quick solution is to delete those playlists (either on the device or using mtp-delfile). Before you do that, I have a small patch which should prevent the crash. Are you able to test it for me? If it's OK, I'll check it into SVN.
I didn't apply the patch yet (since I used "emerge", I can't compile Amarok incrementally - only recompile the whole thing, which takes a while). But, I put a breakpoint at that line and skipped everything if track == 0 - and, it worked. No more crash. (No songs, either, but that's probably a different problem... Or I screwed up with gdb.) I'll recompile everything tomorrow.
SVN commit 600636 by kelk: Fix crash if an MTP media device returns a playlist with an invalid track ID. BUG: 136552 M +2 -0 ChangeLog M +2 -0 src/mediadevice/mtp/mtpmediadevice.cpp --- trunk/extragear/multimedia/amarok/ChangeLog #600635:600636 @@ -13,6 +13,8 @@ * Amarok now saves playlists with relative paths by default. BUGFIXES: + * Fix crash when an MTP media device returned a playlist with an + invalid track ID. (BR 136552) * The Install MP3 support script would be run regardless of what the user answered to the shown dialog. (BR 136294) * OSD wouldn't always show up-to-date ratings. Patch by Tuomas Nurmi --- trunk/extragear/multimedia/amarok/src/mediadevice/mtp/mtpmediadevice.cpp #600635:600636 @@ -1327,6 +1327,8 @@ for( i = 0; i < playlists->no_tracks; i++ ) { MtpTrack *track = m_idToTrack[ playlists->tracks[i] ]; + if( track == 0 ) // skip invalid playlist entries + continue; MtpMediaItem *item = new MtpMediaItem( playlist ); item->setText( 0, track->bundle()->artist() + " - " + track->bundle()->title() ); item->setType( MediaItem::PLAYLISTITEM );