gstelement: fix deadlock in gst_element_add_pad() when >=PAUSED
authorAlicia Boya García <aboya@igalia.com>
Sat, 4 May 2019 01:54:44 +0000 (03:54 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 27 Dec 2022 20:31:10 +0000 (20:31 +0000)
commit15caeb4ac91fd0352ab9efe4cee1e6e343763bd2
tree7946a7914c2fd051970c1f72a9ef01be1f12d902
parent6540c4e89c3a14f482941f7d1b3a8fe22e80f23a
gstelement: fix deadlock in gst_element_add_pad() when >=PAUSED

gst_element_add_pad() is supposed to activate the pad if the element
state is >= PAUSED and the pad is not already active.

Unfortunately, before this patch, the activation was performed while the
element lock was still taken, which ended causing a deadlock in
gst_pad_start_task() as it attempted to post `stream-status` message in
the element, which also requires the element lock.

Elements could work around this bug by activating the pad manually
before adding it to the element.

This patch fixes the problem by performing pad activation only after the
element lock has been released.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3635>
subprojects/gstreamer/gst/gstelement.c
subprojects/gstreamer/tests/check/gst/gstelement.c