Skip to content

rtpbin: fix shutdown crash in rtpbin

This bug has been happening in production for us for a long time now, but this is the first time I have been able to capture it in a test reliably.

The basic analysis is that when shutting down rtpbin, there could be a buffer in-flight from the jitterbuffer-thread, hitting the proxypad of rtpbin that at that point already have been stripped of its sticky-events, making it crash with Got data flow before segment event Like so:

Unexpected critical/warning: ../../../../../pexip/external/gstreamer/gstreamer/gst/gstpad.c:4307:gst_pad_chain_data_unchecked:<recv_rtp_src_0_1234_100:proxypad35> Got data flow before segment event

Stack trace:
gst_debug_get_stack_trace (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20b062a)
gst_check_log_critical_func (/build/linux-x86_64/debug/lib/libgstcheck-1.0.so.0.1700.0:0x7f7cc1e304ff)
g_logv (/build/linux-x86_64/debug/lib/libglib-2.0.so.0.5900.0:0x7f7cc192d88b)
g_log (/build/linux-x86_64/debug/lib/libglib-2.0.so.0.5900.0:0x7f7cc192d96b)
gst_pad_push_data (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20b9f82)
gst_pad_push (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20c186b)
gst_rtp_pt_demux_chain (gstrtpptdemux.c:545)
gst_pad_push_data (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20b992b)
gst_pad_push (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20c186b)
pop_and_push_next (gstrtpjitterbuffer.c:3546)
handle_next_buffer (gstrtpjitterbuffer.c:3645)
gst_rtp_jitter_buffer_loop (gstrtpjitterbuffer.c:4204)
gst_task_func (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20e5e12)
default_func (/build/linux-x86_64/debug/lib/libgstreamer-1.0.so.0.1700.0:0x7f7cc20e6a31)
g_thread_pool_thread_proxy (/build/linux-x86_64/debug/lib/libglib-2.0.so.0.5900.0:0x7f7cc19486ba)
g_thread_proxy (/build/linux-x86_64/debug/lib/libglib-2.0.so.0.5900.0:0x7f7cc1948046)
start_thread (pthread_create.c:456)
__clone (clone.S:95)
?? (??:0xfffffffffffffffc)

However, I am unsure how best to fix this, so I was hoping for some input. @slomo @ndufresne @ocrete ?

It is a fairly critical bug, since it can happen for anyone using rtpbin.

Edited by Håvard Graff

Merge request reports