gstreamer/subprojects/gst-plugins-good/gst/rtpmanager
François Laignel 5ef2ce69ff rtpmanager/rtsession: race conditions leading to critical warnings
While testing the [implementation for insertable streams] in `webrtcsink` &
`webrtcsrc`, I encountered critical warnings, which turned out to result from
two race conditions in `rtpsession`. Both race conditions produce:

> GLib-CRITICAL: g_hash_table_foreach:
>   assertion 'version == hash_table->version' failed

This commit fixes one of the race conditions observed.

In its simplest form, the test consists in 2 pipelines and a Signalling server:

* pipelines_sink: audiotestsrc ! webrtcsink
* pipelines_src: webrtcsrc ! appsrc

1. Set `pipelines_sink` to `Playing`.
2. The Signalling server delivers the `producer_id`.
3. Initialize `pipelines_src` to establish a session with `producer_id`.
4. Set `pipelines_src` to `Playing`.
5. Wait for a buffer to be received by the `appsrc`.
6. Set `pipelines_src` to `Null`.
7. Set `pipelines_sink` to `Null`.

The race condition happens in the following sequence:

* `webrtcsink` runs a task to periodically retrieve statistics from `webrtcbin`.
  This transitively ends up executing `rtp_session_create_stats`.
* `pipelines_sink` is set to `Null`.
* In `Paused` to `Ready`, `gst_rtp_session_change_state()` calls
  `rtp_session_reset()`.
* The assertion failure occurs when `rtp_session_reset` is called while
  `rtp_session_create_stats` is executing.

This is because `rtp_session_create_stats` acquires the lock on `session` prior
to calling `g_hash_table_foreach`, but `rtp_session_reset` doesn't acquire the
lock before calling `g_hash_table_remove_all`.

Acquiring the lock in `rtp_session_reset` fixes the issue.

[implementing insertable streams support]: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1176

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4528>
2023-05-02 21:56:39 +00:00
..
gstrtpbin.c rtpsession: Support disabling late adjustment of ntp-64 header ext 2022-11-24 08:23:03 +00:00
gstrtpbin.h rtpsession: Support disabling late adjustment of ntp-64 header ext 2022-11-24 08:23:03 +00:00
gstrtpdtmfmux.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpdtmfmux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpfunnel.c rtpmanager: Move some duplicated constant and helper function to a single place 2022-04-20 14:40:25 +00:00
gstrtpfunnel.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtphdrext-clientaudiolevel.c rtphdrext-clientaudiolevel: Rename RFC 6464 element 2021-10-20 00:03:09 +00:00
gstrtphdrext-clientaudiolevel.h rtphdrext-clientaudiolevel: Rename RFC 6464 element 2021-10-20 00:03:09 +00:00
gstrtphdrext-mid.c rtpmanager: add support for writing RFC8843 (BUNDLE mid) RTP header extension 2022-03-21 03:18:18 +00:00
gstrtphdrext-mid.h rtpmanager: add support for writing RFC8843 (BUNDLE mid) RTP header extension 2022-03-21 03:18:18 +00:00
gstrtphdrext-ntp.c rtpmanager: Add header extension implementation for the 64-bit RFC6051 NTP header extension 2022-04-20 14:40:25 +00:00
gstrtphdrext-ntp.h rtpmanager: Add header extension implementation for the 64-bit RFC6051 NTP header extension 2022-04-20 14:40:25 +00:00
gstrtphdrext-repairedstreamid.c rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-repairedstreamid.h rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-streamid.c rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-streamid.h rtpmanager: add support for RFC8852 (rid) RTP header extensions 2022-03-21 03:18:18 +00:00
gstrtphdrext-twcc.c rtphdrext: Set caps without attributes as the default 2021-09-28 20:04:55 +00:00
gstrtphdrext-twcc.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpjitterbuffer.c rtpjitterbuffer: Reschedule timers when updating their offset 2022-11-16 08:26:41 +00:00
gstrtpjitterbuffer.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpmanager.c rtpmanager: Add header extension implementation for the 64-bit RFC6051 NTP header extension 2022-04-20 14:40:25 +00:00
gstrtpmux.c docs: mark GstRTPMux as plugin API 2023-04-13 21:46:59 +00:00
gstrtpmux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpptdemux.c rtpptdemux: set different stream-id on each src pad 2023-02-01 09:17:33 +00:00
gstrtpptdemux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtprtxqueue.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtprtxqueue.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtprtxreceive.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstrtprtxreceive.h rtpmanager/rtx: implement initial support for reading/writing rid extensions 2022-03-21 03:18:18 +00:00
gstrtprtxsend.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
gstrtprtxsend.h rtpmanager/rtx: implement initial support for reading/writing rid extensions 2022-03-21 03:18:18 +00:00
gstrtpsession.c rtpsession: fix a race condition during the EOS event in gstrtpsession.c 2023-02-28 17:01:08 +00:00
gstrtpsession.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpssrcdemux.c rtpssrcdemux: set different stream-id on each src pad 2023-02-01 09:17:33 +00:00
gstrtpssrcdemux.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpst2022-1-fecdec.c st2022-1-fecdec: fix packet trimming 2021-11-12 08:15:28 +00:00
gstrtpst2022-1-fecdec.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtpst2022-1-fecenc.c rtpst2022-1-fecenc: Drain column packets on EOS 2022-08-12 12:59:19 +00:00
gstrtpst2022-1-fecenc.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
gstrtputils.c rtpmanager: Move some duplicated constant and helper function to a single place 2022-04-20 14:40:25 +00:00
gstrtputils.h rtpmanager: Move some duplicated constant and helper function to a single place 2022-04-20 14:40:25 +00:00
meson.build meson: Call pkgconfig.generate in the loop where we declare plugins dependencies 2022-09-01 21:17:35 +00:00
rtpjitterbuffer.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtpjitterbuffer.h rtpjitterbuffer: add "add-reference-timestamp-meta" property 2022-03-16 09:52:58 +00:00
rtpsession.c rtpmanager/rtsession: race conditions leading to critical warnings 2023-05-02 21:56:39 +00:00
rtpsession.h rtpsession: Support disabling late adjustment of ntp-64 header ext 2022-11-24 08:23:03 +00:00
rtpsource.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtpsource.h rtpsource: Don't do probation for RTX sources 2022-10-10 14:56:18 +00:00
rtpstats.c Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
rtpstats.h rtpsession: Update 64-bit NTP header extensions with the actual NTP time in senders 2022-04-20 14:40:25 +00:00
rtptimerqueue.c rtpmanager: drop use of GSlice 2023-01-24 15:25:06 +00:00
rtptimerqueue.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00
rtptwcc.c twcc: Better handle duplicate packets 2023-04-10 09:37:51 +00:00
rtptwcc.h Move files from gst-plugins-good into the "subprojects/gst-plugins-good/" subdir 2021-09-24 16:13:50 -03:00