GNOME Bugzilla – Bug 572577
[playbin2] deadlock on shutdown
Last modified: 2009-02-24 12:32:46 UTC
Consider a playbin2 pipeline that is set to PAUSED, and (about) immediately upon return from set_state set to READY, then a race occurs between the (mainloop) thread trying to shutdown to READY, and streaming thread callbacks building the bin and prerolling to PAUSED. In particular, with an internal decodebin2 not yet linked to downstream elements, mainloop may choose to move decodebin2 elements to READY first, and then tries to acquire STREAM_LOCK as part of pad deactivation. In the meantime, streaming thread may then link decodebin2 to downstream elements, resume streaming and waiting prerolled for a state change. A state change will not come as the mainloop is occupied trying to get the STREAM_LOCK, which it will not get as streaming is stuck PAUSED.
Created attachment 129168 [details] [review] Patch for using stress-playbin also with playbin2 Add some arguments to stress-playbin so playbin2 can be stressed as well, and allow for varying pipeline runtime. In particular, run the patched test as follows: ./stress-playbin --bin playbin2 --runtime 10 <dir with some e.g. mp3(s)> and the above deadlock is very likely to occur.
Created attachment 129169 [details] [review] playbin2 patch to prevent deadlock * Use additional flag and lock to serialize and/or discourage further dynamic building when shutting down.
Looks good, I don't know if adding the fakesinks does not cause further havoc but if the test case works I guess that should suffice.
commit d24e75f9fab7b6fa3a729bddfa53e84592f72baf Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> Date: Thu Feb 19 17:16:51 2009 +0100 playbin2: fix deadlock when shutting down. Fixes #572577.