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 770766 - rtpssrcdemux: Fix race condition in clear-ssrc signal handler
rtpssrcdemux: Fix race condition in clear-ssrc signal handler
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 667821 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2016-09-02 17:30 UTC by GstBlub
Modified: 2018-11-03 15:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
rtpssrcdemux: Fix race condition in clear-ssrc signal handler (2.00 KB, patch)
2016-09-02 17:30 UTC, GstBlub
reviewed Details | Review
rtpssrcdemux: Fix race condition in clear-ssrc signal handler (with a separate lock for pads) (19.08 KB, patch)
2016-09-26 16:35 UTC, GstBlub
needs-work Details | Review

Description GstBlub 2016-09-02 17:30:38 UTC
Created attachment 334666 [details] [review]
rtpssrcdemux: Fix race condition in clear-ssrc signal handler

I sometimes run into a critical error like this:

GStreamer-CRITICAL **: Padname src_1119852695 is not unique in element rtpssrcdemux2, not adding

This is because of a race condition with clear-ssrc and another rtp/rtcp packet with the same ssrc coming in, which could cause a new pad with the same name to be added before the one being cleared was actually removed.
Comment 1 Tim-Philipp Müller 2016-09-22 12:17:52 UTC
*** Bug 667821 has been marked as a duplicate of this bug. ***
Comment 2 Ben 2016-09-25 19:51:21 UTC
I had the same error in some of my rtp sessions with gstreamer 1.8.2

I can confirm that the patch fix the issue.
I've been using this patch with more than 100 rtp sessions and I don't see the error any more. In each rtp session streams are added and removed dynamically during the session.
Comment 3 Sebastian Dröge (slomo) 2016-09-26 06:40:51 UTC
Review of attachment 334666 [details] [review]:

::: gst/rtpmanager/gstrtpssrcdemux.c
@@ +530,3 @@
+  gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpad->rtp_pad);
+  gst_element_remove_pad (GST_ELEMENT_CAST (demux), dpad->rtcp_pad);
+  GST_PAD_UNLOCK (demux);

The problem here is that remove_pad() will emit the pad-removed signal... which might cause the application (or other code) from the signal handler to do something else on ssrcdemux that will take the same mutex again, possibly from another thread.

Do you see a way of doing this different without keeping this mutex locked? It's a recursive mutex, so problems are unlikely, it's still problematic though.


Apart from that, the patch makes sense.
Comment 4 GstBlub 2016-09-26 16:34:20 UTC
(In reply to Sebastian Dröge (slomo) from comment #3)
> Do you see a way of doing this different without keeping this mutex locked?
> It's a recursive mutex, so problems are unlikely, it's still problematic
> though.

The only way to do this would be to add a separate mutex around the pad adding/removing.  I have a patch, but haven't had a chance to actually test it.
Comment 5 GstBlub 2016-09-26 16:35:10 UTC
Created attachment 336281 [details] [review]
rtpssrcdemux: Fix race condition in clear-ssrc signal handler (with a separate lock for pads)

Untested patch that adds a new lock around adding/removing pads
Comment 6 GstBlub 2016-10-06 14:40:39 UTC
(In reply to GstBlub from comment #5)
> Untested patch that adds a new lock around adding/removing pads

I've been running with this patch and haven't seen any issues so far.  However, haven't tested it quite as much as the other patch.
Comment 7 Sebastian Dröge (slomo) 2016-10-20 10:04:35 UTC
Comment on attachment 336281 [details] [review]
rtpssrcdemux: Fix race condition in clear-ssrc signal handler (with a separate lock for pads)

Looks generally good, but please explain in the commit message also why you add a new lock and what the different uses of the two locks is (and their locking order).
Comment 8 Ben 2016-11-25 12:30:24 UTC
GstBlub, any chance you could update your commit message? I have the same issue and will love to see this resolved.
Comment 9 GStreamer system administrator 2018-11-03 15:11:24 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/gst-plugins-good/issues/296.