By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.

Bug 1675

Summary: [Regression] amarok : very frequent crashes
Product: TDE Reporter: Slávek Banko <slavek.banko>
Component: non-core programsAssignee: Timothy Pearson <kb9vqf>
Status: RESOLVED FIXED    
Severity: critical CC: bugwatch, darrella, kb9vqf, slavek.banko
Priority: P5    
Version: R14.0.0 [Trinity]   
Hardware: Other   
OS: Debian Wheezy   
Compiler Version: TDE Version String:
Application Version: Application Name:
Attachments: amarok crach backtrace
Fix availibility scrobbler services settings
Disable cross-thread event posting in scrobbler class
amarok crash with disabled cross-thread event posting
amarok crash with disabled cross-thread event posting (1)
Disable cross-thread event posting in all EngineObserver classes
amarok crash with disabled cross-thread event posting in all EngineObserver classes
Disble cross-thread event posting in tdeio DataSlave class
Crash with disbled cross-thread event posting in tdeio DataSlave class
amarok crash valgrind
amarok-valgrind1
amarok-valgrind2

Description Slávek Banko 2013-10-10 14:11:01 CDT
Created attachment 1540 [details]
amarok crach backtrace

I've upgraded on Debian Wheezy from TDE v3.5.13.2 to R14 nightly-builds. Before updating were no problems with Amarok. After updating occur very frequent crashes.

I use Amarok with SQLite. The dynamic playlist - random mix. At the beginning of any track (maybe it is related to the updates 'context' tab) after a few seconds often occurs crash.

When instead of my collection I play internet radio - context tab is not renewed (only stream metadata history), related artists are not displayed, new songs are not added to the playlist - Amarok several hours playing without crash.
Comment 1 Darrell 2013-10-11 18:30:05 CDT
I use amarok with sqlite. I haven't seen any crashes here. I don't use dynamic playlist but I play all of my music from m3u playlists. I will try to test with dynamic random playlist.
Comment 2 Darrell 2013-10-11 18:55:51 CDT
For the past half-hour I have been playing a dynamic random playlist with no crashing. The playlist is auto-updating as well. Slackware 14, packages from git of Sept. 27.
Comment 3 Slávek Banko 2013-10-11 19:47:54 CDT
(Odpověď na komentář #2)
> For the past half-hour I have been playing a dynamic random playlist with no
> crashing. The playlist is auto-updating as well. Slackware 14, packages from
> git of Sept. 27.

Do you have enabled setting Retrieve similar artists?
In ~/.trinity/share/config/amarokrc:

[Scrobbler]
RetrieveSimilarArtists=true

It is interesting that sometimes Amarok plays a long time without a crash. But with some songs crash immediately and repeatedly after the track starts.
Comment 4 Darrell 2013-10-11 20:09:14 CDT
I don't use scrobbling. My test was with all locally installed music files.

Perhaps then the crash is related to scrobbling?
Comment 5 Slávek Banko 2013-10-11 20:16:57 CDT
(Odpověď na komentář #4)
> I don't use scrobbling. My test was with all locally installed music files.
> 
> Perhaps then the crash is related to scrobbling?

So far I have not examined the problem - similar artists is one of things that appear on the 'context tab'. Therefore, it may be related.

Note: Similar artists may be allowed even if the user not have a profile on last.fm. Checkbox in settings should be available, even if not specified last.fm profile informations.
Comment 6 Slávek Banko 2013-10-11 21:29:55 CDT
Created attachment 1544 [details]
Fix availibility scrobbler services settings

The patch does not have a direct connection with this reported crash. Only again makes available settings that should be available always ... and which may be related to this reported crash.
Comment 7 Slávek Banko 2013-10-12 09:43:19 CDT
In testing I'm in the console during the crash saw the following:

tdeio_http_debug: WARNING: (8298) closeCacheEntry: error renaming cache entry. (/var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Luca Turilli_similar.xml_2ece4af5.new -> /var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Luca Turilli_similar.xml_2ece4af5)
tdeio_http_debug: WARNING: (8298) closeCacheEntry: error closing cache entry. (/var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Luca Turilli_similar.xml_2ece4af5.new)
tdeio_http_debug: WARNING: (8303) closeCacheEntry: error renaming cache entry. (/var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Freedom Call_similar.xml_25642a12.new -> /var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Freedom Call_similar.xml_25642a12)
tdeio_http_debug: WARNING: (8303) closeCacheEntry: error closing cache entry. (/var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Freedom Call_similar.xml_25642a12.new)
[kcrash] TDECrash: Application 'amarokapp' crashing...
_artist_Freedom\ Call_similar.xml_25642a12 /ws.audioscrobbler.com_1.0_

It looks that it really can be associated with finding similar artists.
Comment 8 Slávek Banko 2013-10-13 12:31:11 CDT
Comment on attachment 1544 [details]
Fix availibility scrobbler services settings

Pushed to GIT in hash 90583bb.
Comment 9 Timothy Pearson 2013-10-13 15:19:03 CDT
Created attachment 1548 [details]
Disable cross-thread event posting in scrobbler class

This looks like it is related to the threading changes in TQt3.  Try the attached patch and see if it fixes the problem.

Thanks!

Tim
Comment 10 Slávek Banko 2013-10-13 19:02:58 CDT
Created attachment 1549 [details]
amarok crash with disabled cross-thread event posting

$ tdeio_http_debug: WARNING: (2528) closeCacheEntry: error renaming cache entry. (/var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Nick Cave & Die Haut_similar.xml_0e2c8574.new -> /var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Nick Cave & Die Haut_similar.xml_0e2c8574)
tdeio_http_debug: WARNING: (2528) closeCacheEntry: error closing cache entry. (/var/tmp/tdecache-slavek.banko/http/s/ws.audioscrobbler.com_1.0_artist_Nick Cave & Die Haut_similar.xml_0e2c8574.new)
[kcrash] TDECrash: Application 'amarokapp' crashing...

Interestingly, that report about cache was not related to the immediately preceding or following track.
Comment 11 Slávek Banko 2013-10-13 19:21:50 CDT
Created attachment 1550 [details]
amarok crash with disabled cross-thread event posting (1)

further testing, further crash

$ [kcrash] TDECrash: Application 'amarokapp' crashing...
tdeio (TDEIOConnection): ERROR: Header read failed, errno=104
tdeio (TDEIOConnection): ERROR: Header has invalid size (-1)
tdeio (TDEIOConnection): ERROR: Could not write data
Comment 12 Timothy Pearson 2013-10-13 21:53:46 CDT
(In reply to comment #11)
> Created attachment 1550 [details]
> amarok crash with disabled cross-thread event posting (1)
> 
> further testing, further crash
> 
> $ [kcrash] TDECrash: Application 'amarokapp' crashing...
> tdeio (TDEIOConnection): ERROR: Header read failed, errno=104
> tdeio (TDEIOConnection): ERROR: Header has invalid size (-1)
> tdeio (TDEIOConnection): ERROR: Could not write data

OK, so in other words my patch did nothing. :-)

I still suspect cross-thread event posting to be the culprit, the only problem I have is narrowing down which class(es) are the culprit.
Comment 13 Darrell 2013-10-13 22:01:01 CDT
> tdeio (TDEIOConnection): ERROR: Header read failed, errno=104
> tdeio (TDEIOConnection): ERROR: Header has invalid size (-1)
> tdeio (TDEIOConnection): ERROR: Could not write data

Those messages were also reported in bug report 1655. Hopefully we kill two birds with one stone?
Comment 14 Timothy Pearson 2013-10-17 20:42:41 CDT
Created attachment 1558 [details]
Disable cross-thread event posting in all EngineObserver classes

I have not yet been able to replicate this crash on my development system.  The attached patch disables cross-thread event posting in all EngineObserver classes; can you see if it helps at all with the crashing?

Thanks!
Comment 15 Slávek Banko 2013-10-17 22:08:13 CDT
Created attachment 1559 [details]
amarok crash with disabled cross-thread event posting in all EngineObserver classes

I'm sorry, but after some time of playing again occured the same crash.
Comment 16 Timothy Pearson 2013-10-20 20:50:50 CDT
Created attachment 1565 [details]
Disble cross-thread event posting in tdeio DataSlave class

Can you try the attached patch for tdelibs in addition to the earlier patch disabling cross-thread event posting in Amarok?  I am able to sporadically replicate two distinct crashes in Amarok, but need to know if this patch solves one of them on your system or not.

Thanks!
Comment 17 Slávek Banko 2013-10-21 10:03:43 CDT
Created attachment 1566 [details]
Crash with disbled cross-thread event posting in tdeio DataSlave class

At first look, the crash is still the same.
Tested with patched Amarok and tdelibs.
Comment 18 Timothy Pearson 2013-10-21 14:38:43 CDT
OK, I will need a more reliable method of triggering the crash to resolve this issue.  Basically I need it to crash while running under Valgrind to know what is happening.

Can you try running amarokapp with valgrind to see if it will crash?  If it does, please post the valgrind output to this report.
Comment 19 Slávek Banko 2013-10-21 14:50:51 CDT
(Odpověď na komentář #18)
> OK, I will need a more reliable method of triggering the crash to resolve this
> issue.  Basically I need it to crash while running under Valgrind to know what
> is happening.
> 
> Can you try running amarokapp with valgrind to see if it will crash?  If it
> does, please post the valgrind output to this report.

Valgrind with some extra parameters?
Comment 20 Slávek Banko 2013-10-21 17:07:46 CDT
Created attachment 1567 [details]
amarok crash valgrind
Comment 21 Timothy Pearson 2013-10-21 18:34:56 CDT
(In reply to comment #20)
> Created attachment 1567 [details]
> amarok crash valgrind

Great!  Unfortunately this didn't reveal much about the origin of the threading failure, so I need the output of two other valgrind runs:
valgrind --track-origins=yes amarokapp &> valgrind1.log
valgrind --tool=drd amarokapp &> valgrind2.log

Fundamentally this crash is caused by the TDEIO job being deleted before all of the metadata has been retrieved; I just don't know *what* is deleting the object early.  Hopefully DRD will shed some light on this.

Thanks!

Tim
Comment 22 Slávek Banko 2013-10-22 11:47:56 CDT
Created attachment 1568 [details]
amarok-valgrind1

It was difficult. Along with the already proposed patches crashes are less frequent. Combined with the memory consumption during run through valgrind and low power of testing machine ... but I succeeded - crash occurred :)
Comment 23 Slávek Banko 2013-10-22 11:51:02 CDT
Created attachment 1569 [details]
amarok-valgrind2

Running with --tool=drd amarok only consumed cpu and memory, but did not open the GUI. After a while I stopped it.
Comment 24 Timothy Pearson 2013-10-23 01:25:49 CDT
I have traced this into the Amarok threading system; it appears that Amarok calls TDEIO:get() from the scrobbler, which executes in a secondary thread.  As the TDEIO slave objects execute in the main GUI thread, cross-thread event posting is triggered, setting up a deletion race condition and causing the crash.

I am working on a way to fix this.
Comment 25 Timothy Pearson 2013-10-23 20:13:46 CDT
This should (finally!) be fixed in GIT hash 69eb063.  The problem boiled down to a secondary thread (CollectionDB-related) directly calling the Scrobbler::similarArtists() method after the Scrobbler class instance had been created in the main GUI thread.  This violated the TQt/TDE threading rules and led to a situation where the Scrobbler class created TDEIO objects in the secondary thread, even though the Scrobbler class was part of the main thread.

This was hard to track down as the bug would only show up (sporadically!) on the first load of artist information from last.fm, therefore I ended up using a track for testing that had no artists match on last.fm, forcing a Scrobbler reload attempt each time it was played.

Incidentally, Amarok still uses its own thread manager, which might be the source of some of these unusual threading problems.  The TQt3 thread manager is more robust overall, and I would eventually like to see Amarok use it instead.  In this particular case, however, the crash would have occurred regardless of the thread manager in use.  The TQt3 cross-thread signal/slot mechanism allowed the easy fix mentioned above in GIT hash 69eb063. :-)

Let me know if this fixes the bug on your end for good...

Thanks!
Comment 26 Timothy Pearson 2013-10-23 20:14:13 CDT
Comment on attachment 1558 [details]
Disable cross-thread event posting in all EngineObserver classes

Not needed
Comment 27 Timothy Pearson 2013-10-23 20:14:29 CDT
Comment on attachment 1565 [details]
Disble cross-thread event posting in tdeio DataSlave class

Not needed
Comment 28 Darrell 2013-10-24 10:53:51 CDT
> Incidentally, Amarok still uses its own thread manager, which might be the
> source of some of these unusual threading problems.  The TQt3 thread manager
> is more robust overall, and I would eventually like to see Amarok use it
> instead.

Should we open a bug report to track that desire? Perhaps a generic report for other apps that might also have their own thread manager?
Comment 29 Slávek Banko 2013-10-24 13:25:31 CDT
I am thoroughly tested Amarok all day (without music I just can not work :) ) and without any crash! A great result. Thank you Tim.

Since bug from this report is fixed, this bug report can be now closed. Task to replace thread management, should be as separate bug report.
Comment 30 Timothy Pearson 2013-10-29 16:38:03 CDT
(In reply to comment #28)
> > Incidentally, Amarok still uses its own thread manager, which might be the
> > source of some of these unusual threading problems.  The TQt3 thread manager
> > is more robust overall, and I would eventually like to see Amarok use it
> > instead.
> 
> Should we open a bug report to track that desire? Perhaps a generic report for
> other apps that might also have their own thread manager?

Yes, an enhancement request might be a good idea in case someone wants to hack on it. :-)
Comment 31 Darrell 2013-10-30 16:13:48 CDT
Done: bug report 1691.
Comment 32 Slávek Banko 2013-10-30 16:17:23 CDT
(Odpověď na komentář #31)
> Done: bug report 1691.

By the way, if you skip the word "report",
bugzilla automatically converts bug 1691 into link.
Comment 33 Darrell 2013-10-30 17:06:45 CDT
Yeah, I know. :-) I'm a technical writer. Not my fault the bugzilla developers are grammatically incorrect. :-)