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 574293 - [decodebin2] deadlock on shutdown
[decodebin2] deadlock on shutdown
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 0.10.23
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-03-05 18:33 UTC by Mark Nauwelaerts
Modified: 2009-03-09 12:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gdb backtrace (5.44 KB, text/plain)
2009-03-05 18:34 UTC, Mark Nauwelaerts
  Details
Possible patch (4.94 KB, patch)
2009-03-06 18:41 UTC, Mark Nauwelaerts
committed Details | Review

Description Mark Nauwelaerts 2009-03-05 18:33:13 UTC
Consider a decodebin2 (e.g. in 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, which may result in a deadlock.

Specifically, consider decodebin2 plugging a typical demuxer that exposes 1 video and 1 audio pad.  Streaming thread(s) plug more elements, set up a decodegroup, decodepads, and pad blocks on (unexposed) ghostpads.  Consider streaming has reached the stage where 1 pad has blocked.

At this point, the mainloop (performing a shutdown to READY) sets the most downstream element whose corresponding src pad has not yet blocked to READY.
Then it sets the other most downstream element to READY, and tries to grab the STREAM_LOCK.  This blocks, as this thread in question is in a pad block.  Since the other downstream element is now flushing, the other ghostpad will never block, so the decodegroup will not be exposed (part of which unblocks the pads).

Since the blocked pads are ghostpads, core will not unblock them either as part of any element's state change.
Comment 1 Mark Nauwelaerts 2009-03-05 18:34:34 UTC
Created attachment 130147 [details]
gdb backtrace

gdb backtrace illustrating the scenario described above
Comment 2 Mark Nauwelaerts 2009-03-06 18:41:44 UTC
Created attachment 130210 [details] [review]
Possible patch

Unblock blocked ghostpads when shutting down.

This provides a fix at "decodebin2 level" although a similar problem might occur elsewhere, since blocked ghostpads are not necessarily unblocked by core during pad deactivation.  An possible (more generic) alternative might be to use GstPad(Un)BlockFunction, and to perform some proxying for proxypads/ghostpads.
Comment 3 Wim Taymans 2009-03-09 12:11:33 UTC
My analisis of the problem was that core does indeed deactivates and flushes blocked the pads when going to READY but there is a race where the pad can be added after the bin iterated the pads, leaving the pad blocked.

I think with the shutdown lock, ie not adding any pads (and setting them inactive) when the bin is shutting down, should do the trick.
Comment 4 Mark Nauwelaerts 2009-03-09 12:37:24 UTC
commit b7ea2a9105107fe9f5130e4d0594196e52fb0e71
Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Date:   Fri Mar 6 19:28:37 2009 +0100

    Unblock blocked ghostpads when shutting down.  Fixes #574293.