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 557763 - [mpegtsmux] Deadlock @ EOS due to interleaving mechanism
[mpegtsmux] Deadlock @ EOS due to interleaving mechanism
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal major
: 0.10.10
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-10-24 14:16 UTC by vanista
Modified: 2008-10-27 08:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix (1.62 KB, patch)
2008-10-24 14:24 UTC, vanista
committed Details | Review

Description vanista 2008-10-24 14:16:49 UTC
Please describe the problem:
A deadlock occurs in certain conditions in the new mpegtsmux. The problem existed in the original flutsmux also.

There is a flaw in the interleaving mechanism where the collect pads can pass EOS flushing and the mux still keep a queued buffer, resulting in the mux not issuing the EOS event and the pipeline deadlocking.



Steps to reproduce:
gst-launch-0.10 mpegtsmux name=mux ! fakesink audiotestsrc num-buffers=1 ! lame ! queue ! mux.sink_0 videotestsrc num-buffers=1 ! ffenc_mpeg2video ! queue ! mux.sink_1

Actual results:
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[deadlocked]


Expected results:
Muxer issues EOS on its source pad and pipeline terminates properly.

Does this happen every time?
Yes its systematic, I think it occurs when audio and video have their EOS at the same moment in the stream time line. This is not a race condition issue.

Other information:
I've compared the code with the avimux and noticed an obvious difference. The avimux, for its interleaving purpose, only peeks at the collect pads until the oldest (or most suitable) stream is identified. Then when a stream is sure to be handled, a buffer is poped from the pad.

In the mpegtsmux, streams each have a tracking structure with a GstBuffer pointer to keep the reference of all poped data. This is obviously to reduce the overhead of accessing the collect pads, however it screws up the collect mechanism for EOS handling.

I have a patch to propose a fix. Its probably not the best solution but I didn't want to rewrite the whole function.
Comment 1 vanista 2008-10-24 14:24:27 UTC
Created attachment 121273 [details] [review]
Proposed fix

I keep the original function pretty much intact except I do a peek instead of a pop to get the stream buffer, then I unref a poped buffer off the selected pad.
Comment 2 Sebastian Dröge (slomo) 2008-10-27 08:52:40 UTC
2008-10-27  Sebastian Dröge  <sebastian.droege@collabora.co.uk>

	Patch by: vanista <vanista at gmail dot com>

	* gst/mpegtsmux/mpegtsmux.c: (mpegtsmux_choose_best_stream):
	Fix EOS logic by correctly popping the collect pad buffers only
	when we've chosen to use them instead of popping them always and
	storing them in a private queue.

	Before the pipeline would deadlock if all pads go EOS at the same
	time. Fixes bug #557763.