rtspsrc: deadlock on set_state(NULL)
I've found a deadlock when setting the state of rtspsrc
to NULL
. I think this bug is in rtspsrc's side, not our pipeline, but I might be wrong.
-
change_state
waits for the RTSP task to finish. - It can't finish because it's in the middle of sending EOS to the stream's
udpsrc[0]
, and it's waiting on itsSTATE_LOCK
. -
STATE_LOCK
is held by the RTCP task, which is (due to timeout) also sending EOS to the stream'sudpsrc[0]
. It can't finish because it's waiting for udpsrc's task to finish. - udpsrc's task can't finish because it's blocked by rtpjitterbuffer's chain function. I suppose the 'flushing' is expected to unblock it, but I still have to investigate further.
Note: (I don't know if it's relevant) I didn't call gst_element_set_state
on rtspsrc
directly, but on its immediate parent bin (which is not the pipeline).
Below are the relevant stack traces. This caught me off guard, I'm not 100% sure the stack traces are correct... once I'm able to reproduce again I'll give more info.
Main thread:
- gst_element_set_state(bin, NULL)
- https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/41677a526b83bb2493087af1d93b50c297cf97cd/gst/gstbin.c#L2615
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L9233
RTSP task:
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L6189
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L5049
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L5003
- https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/b16e96dd878e0c5e7baeb8fad62ca43de1f66982/gst/gstelement.c#L1973
RTCP task:
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L3600
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L3581
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L3543
- https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/blob/aad9c8a2165b0bbee957c54262391006e81907af/gst/rtsp/gstrtspsrc.c#L5003
- https://gitlab.freedesktop.org/gstreamer/gstreamer/blob/5230cab38d22b861fec54174c9285fb4c2f10cef/libs/gst/base/gstbasesrc.c#L1934
udpsrc task:
#1 0x0000007f884f4b84 in g_cond_wait () at /usr/lib/aarch64-linux-gnu/libglib-2.0.so.0
#2 0x0000007f4aef9a40 in gst_rtp_jitter_buffer_chain () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#3 0x0000007f78167de4 in gst_pad_push_data () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#4 0x0000007f781710bc in gst_pad_push () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#5 0x0000007f4af0784c in gst_rtp_ssrc_demux_chain () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#6 0x0000007f78167de4 in gst_pad_push_data () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#7 0x0000007f781710bc in gst_pad_push () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#8 0x0000007f78167de4 in gst_pad_push_data () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#9 0x0000007f781710bc in gst_pad_push () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#10 0x0000007f4af27a5c in gst_rtp_session_process_rtp () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#11 0x0000007f4af0cb90 in source_push_rtp () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#12 0x0000007f4af1e704 in rtp_source_process_rtp () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#13 0x0000007f4af19a84 in rtp_session_process_rtp () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#14 0x0000007f4af2b460 in gst_rtp_session_chain_recv_rtp () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrtpmanager.so
#15 0x0000007f78167de4 in gst_pad_push_data () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#16 0x0000007f781710bc in gst_pad_push () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#17 0x0000007f7814f0f4 in gst_proxy_pad_chain_default () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#18 0x0000007f78167de4 in gst_pad_push_data () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#19 0x0000007f781710bc in gst_pad_push () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0
#20 0x0000007f6b79a734 in gst_base_src_loop () at /usr/lib/aarch64-linux-gnu/libgstbase-1.0.so.0
#21 0x0000007f781aa94c in gst_task_func () at /usr/lib/aarch64-linux-gnu/libgstreamer-1.0.so.0