decodebin: fix deadlock between downward state change and pad addition
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 5 Feb 2015 12:07:50 +0000 (12:07 +0000)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Thu, 19 Feb 2015 13:38:35 +0000 (13:38 +0000)
commita2ee84fa80cde8174a2e44258b3b57e94c28216e
tree4ed36e33319d358e3ab77e69f3e9e639cc52801b
parenta848ac7abe0664d6aa0d7b8e6368534ac34be22b
decodebin: fix deadlock between downward state change and pad addition

If caps on a newly added pad are NULL, analyze_new_pad will try to
acquire the chain lock to add a probe to the pad so the chain can
be built later. This comes from the streaming thread, in response
to headers or other buffers causing this pad to be added, so the
stream lock is taken.

Meanwhile, another thread might be destroying the chain from a
downward state change. This will cause the chain to be freed with
the chain lock taken, and some elements are set to NULL here, which
can include the parser. This causes pad deactivation, which tries
to take the element's pad's stream lock, deadlocking.

Fix this by keeping track of which elements need setting to NULL,
and only do this after the chain lock is released. Only the chain
manipulation needs to be locked, not the elements' state changes.

https://bugzilla.gnome.org/show_bug.cgi?id=741355
gst/playback/gstdecodebin2.c