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 772115 - tee: adding inactive pad to running element
tee: adding inactive pad to running element
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
1.8.3
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-09-28 11:58 UTC by Miguel París Díaz
Modified: 2018-11-03 12:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test that reproduces the problem (2.01 KB, text/x-csrc)
2016-09-28 11:58 UTC, Miguel París Díaz
  Details
tee: activate src pad before adding it (832 bytes, patch)
2016-09-28 11:59 UTC, Miguel París Díaz
none Details | Review
element: do not consider a warning adding an inactive pad (1.03 KB, patch)
2016-09-28 12:32 UTC, Miguel París Díaz
rejected Details | Review
tee: activate src pads if element is running (1.03 KB, patch)
2016-09-28 15:19 UTC, Miguel París Díaz
none Details | Review

Description Miguel París Díaz 2016-09-28 11:58:29 UTC
Created attachment 336431 [details]
Test that reproduces the problem

I have found the next problem in the tee running the attached program:

GStreamer-WARNING **: adding inactive pad 'src_46' to running element 'tee0', you need to use gst_pad_set_active(pad,TRUE) before adding it.
Comment 1 Miguel París Díaz 2016-09-28 11:59:19 UTC
Created attachment 336432 [details] [review]
tee: activate src pad before adding it
Comment 2 Sebastian Dröge (slomo) 2016-09-28 12:07:13 UTC
Comment on attachment 336432 [details] [review]
tee: activate src pad before adding it

It should only be activated if the tee is running
Comment 3 Miguel París Díaz 2016-09-28 12:10:01 UTC
@slomo, what happens if it is activated and the tee is not running?

Anyway, this is done by gstelement [1] but with a previous warning.

Refs
[1] https://github.com/Kurento/gstreamer/blob/0fb3a083ce04551fbdba7a94f0ac5612515bda67/gst/gstelement.c#L680
Comment 4 Sebastian Dröge (slomo) 2016-09-28 12:19:17 UTC
Then you have activated the pad while the tee is not running :) That's not good. The pads should only be active in >= PAUSED
Comment 5 Miguel París Díaz 2016-09-28 12:32:56 UTC
Created attachment 336436 [details] [review]
element: do not consider a warning adding an inactive pad

If I am not wrong, this should be the solution because the state of the element and if the pad is active or not must be checked in the same critical section to avoid race condition problems.
Comment 6 Sebastian Dröge (slomo) 2016-09-28 12:34:40 UTC
Comment on attachment 336436 [details] [review]
element: do not consider a warning adding an inactive pad

No, it's wrong to do that and the element that is adding inactive pads while in >= PAUSED is just wrong
Comment 7 Miguel París Díaz 2016-09-28 12:39:08 UTC
I do not know another solution without having race condition problems.
@slomo, could you please propose a solution?
Comment 8 Sebastian Dröge (slomo) 2016-09-28 13:56:41 UTC
I don't have time to think about that right now, but basically tee should know what state it is in and act accordingly.
Comment 9 Miguel París Díaz 2016-09-28 15:19:10 UTC
@slomo,
don't worry I understand it ;)

I suppose what you mean but there are problems.
Anyway, I uploading a patch to discuss over it.
Comment 10 Miguel París Díaz 2016-09-28 15:19:37 UTC
Created attachment 336455 [details] [review]
tee: activate src pads if element is running
Comment 11 Miguel París Díaz 2016-09-28 15:23:02 UTC
Review of attachment 336455 [details] [review]:

::: plugins/elements/gsttee.c
@@ -414,0 +414,7 @@
+  GST_OBJECT_LOCK (tee);
+  if ((GST_STATE (tee) > GST_STATE_READY ||
+          GST_STATE_NEXT (tee) == GST_STATE_PAUSED)) {
... 4 more ...

Here there is a race condition problem when the lock is unlocked:
If the element changes of state between
 - setting the proper active flag to the src pad
 - and adding the pad to the element.
we will have the same problem that doing nothing about the active flag.

This cannot be fixed here because the gst_element_add_pad also locks the element and we will have a deadlock.
Comment 12 Nicolas Dufresne (ndufresne) 2016-09-28 17:10:56 UTC
I believe there is a reason why we have a recursive state lock in GstElement::state_lock.
Comment 13 Sebastian Dröge (slomo) 2016-09-28 17:15:18 UTC
(In reply to Nicolas Dufresne (stormer) from comment #12)
> I believe there is a reason why we have a recursive state lock in
> GstElement::state_lock.

Just that it isn't used consistently (or even according to the comments in the code) right now. In theory using the state lock here would solve it, but in practice it doesn't (and making the state lock used like that causes deadlocks all over the place due to other issues).
Comment 14 Nicolas Dufresne (ndufresne) 2016-09-28 17:20:13 UTC
We might have made it worst lately indeed.
Comment 15 Sebastian Dröge (slomo) 2016-09-28 18:10:35 UTC
(In reply to Nicolas Dufresne (stormer) from comment #14)
> We might have made it worst lately indeed.

How do you mean? It's like this at least since all of 1.0, should've been like this for quite a while in 0.10 too
Comment 16 Miguel París Díaz 2016-09-29 08:24:35 UTC
From my point of view in this specific case we are dealing with an encapsulation problem.
I mean that the state (active/not active) of the pad (in relation with the state of the element) must be handled by GstElement class as it already does but without consider a warning if the element is ready and the pad is not active. That is don done in attachment 336436 [details] [review].
I think that this is the best and the easy solution and matches with the idea that the state management is properly encapsulated in GstElement.
Comment 17 GStreamer system administrator 2018-11-03 12:36:31 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/190.