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 790431 - gstpad: Make calls to GstPadActivateFunction MT-safe
gstpad: Make calls to GstPadActivateFunction MT-safe
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-11-16 07:29 UTC by Edward Hervey
Modified: 2018-01-08 20:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstpad: Make calls to GstPadActivateFunction MT-safe (3.12 KB, patch)
2017-11-16 07:29 UTC, Edward Hervey
committed Details | Review
gstpad: Make pad (de)activation atomic (4.17 KB, patch)
2017-11-16 09:55 UTC, Edward Hervey
committed Details | Review

Description Edward Hervey 2017-11-16 07:29:20 UTC
See patch
Comment 1 Edward Hervey 2017-11-16 07:29:26 UTC
Created attachment 363788 [details] [review]
gstpad: Make calls to GstPadActivateFunction MT-safe

checking whether we already were in the target GstPadMode was being
done too early and there was the risk that we *would* end up
(de)activating a pad more than once.

Instead, re-do the check for pad mode when entering the final pad
(de)activation block.
Comment 2 Edward Hervey 2017-11-16 09:07:23 UTC
Note that this commit does not solve the following problem:
* Thread 1 calls gst_pad_activate()
* Thread 2 was currently doing the (de)activation
* Thread 1 assumes pad (de)activation has happened and does something with it while the (de)actvation hasn't *actually* completed.
Comment 3 Edward Hervey 2017-11-16 09:55:41 UTC
Created attachment 363816 [details] [review]
gstpad: Make pad (de)activation atomic

The following could happen previously:
* T1: calls gst_pad_set_active()
* T2: currently (de)activating it
* T1: gst_pad_set_active() returns, caller assumes that the pad has
  completed the requested (de)activation ... whereas it is not
  the case since the actual (de)activation in T2 might still be
  going on.

To ensure atomicity of pad (de)activation, we use a internal
variable (and cond) to ensure only one thread at a time goes through
the actual (de)activation block
Comment 4 Edward Hervey 2017-11-16 10:50:29 UTC
commit d915dd4b20ffdcb417ea4b46a8dd9010c7ce7bf9 (HEAD -> master, origin/master, origin/HEAD)
Author: Edward Hervey <edward@centricular.com>
Date:   Thu Nov 16 10:47:46 2017 +0100

    gstpad: Make pad (de)activation atomic
    
    The following could happen previously:
    * T1: calls gst_pad_set_active()
    * T2: currently (de)activating it
    * T1: gst_pad_set_active() returns, caller assumes that the pad has
      completed the requested (de)activation ... whereas it is not
      the case since the actual (de)activation in T2 might still be
      going on.
    
    To ensure atomicity of pad (de)activation, we use a internal
    variable (and cond) to ensure only one thread at a time goes through
    the actual (de)activation block
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790431

commit 80262013ca553fa5b35e5c638893d3512a3dd7dc
Author: Edward Hervey <edward@centricular.com>
Date:   Thu Nov 16 08:26:12 2017 +0100

    gstpad: Make calls to GstPadActivateFunction MT-safe
    
    checking whether we already were in the target GstPadMode was being
    done too early and there was the risk that we *would* end up
    (de)activating a pad more than once.
    
    Instead, re-do the check for pad mode when entering the final pad
    (de)activation block.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790431
Comment 5 Carlos Alberto Lopez Perez 2018-01-08 20:50:10 UTC
I have reported a deadlock on platform IMX that started to happen with WPE (WebKit) after this two commits in bug 792341