decodebin3: dead lock when removing pad
To reproduce:
- grab branch
uriplaylistbin
from https://gitlab.freedesktop.org/gdesmott/gst-plugins-rs.git - go to
utils/uriplaylistbin
cargo run --features=clap --example playlist -- https://gitlab.freedesktop.org/gdesmott/karapulse/-/raw/main/tests/medias/video-2s.mkv?inline=false https://gitlab.freedesktop.org/gdesmott/karapulse/-/raw/main/tests/medias/test.mp3?inline=false -i 0
decodebin3
is dead locking itself by trying to acquire the INPUT
lock in gst_decodebin3_input_pad_unlink()
while it's already hold in gst_decodebin3_release_pad()
.
Thread 60 (Thread 0x7f4088df26c0 (LWP 136260) "souphttpsrc2:sr"):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x00007f41684d0dfc in g_mutex_lock_slowpath (mutex=0x55ccc1d98418) at ../glib/gthread-posix.c:1503
#2 0x00007f41684d0e24 in g_mutex_lock (mutex=mutex@entry=0x55ccc1d98418) at ../glib/gthread-posix.c:1532
#3 0x00007f4167c4374b in gst_decodebin3_input_pad_unlink (pad=0x7f41440e8c90, peer=<optimized out>, input=0x7f404801b690) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:1029
#4 0x00007f4168759a65 in g_cclosure_marshal_VOID__OBJECTv (closure=0x7f404801ba20, return_value=<optimized out>, instance=0x7f41440e8c90, args=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=0x55ccc1b22f20) at ../gobject/gmarshal.c:1910
#5 0x00007f4168778554 in _g_closure_invoke_va (param_types=<optimized out>, n_params=<optimized out>, args=0x7f4088df0310, instance=<optimized out>, return_value=<optimized out>, closure=0x7f404801ba20) at ../gobject/gclosure.c:895
#6 g_signal_emit_valist (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>, var_args=var_args@entry=0x7f4088df0310) at ../gobject/gsignal.c:3456
#7 0x00007f4168778633 in g_signal_emit (instance=instance@entry=0x7f41440e8c90, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3606
#8 0x00007f41683676c2 in gst_pad_unlink (srcpad=srcpad@entry=0x7f41440e8a20, sinkpad=sinkpad@entry=0x7f41440e8c90) at ../subprojects/gstreamer/gst/gstpad.c:2195
#9 0x00007f4168343bda in gst_element_remove_pad (element=0x55ccc1d982a0, pad=pad@entry=0x7f41440e8c90) at ../subprojects/gstreamer/gst/gstelement.c:888
#10 0x00007f4167c488df in free_input (dbin=dbin@entry=0x55ccc1d982a0, input=input@entry=0x7f404801b690) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:1173
#11 0x00007f4167c48dc9 in gst_decodebin3_release_pad (element=0x55ccc1d982a0, pad=<optimized out>) at ../subprojects/gst-plugins-base/gst/playback/gstdecodebin3.c:1127
#12 0x00007f4167c5739e in switch_and_activate_input_locked (uridecodebin=0x55ccc1dac060, new_item=0x7f414411cc30) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:1078
#13 0x00007f4167c578fe in uri_src_block_probe (pad=pad@entry=0x7f41440e9da0, info=info@entry=0x7f4088df0760, srcpad=<optimized out>) at ../subprojects/gst-plugins-base/gst/playback/gsturidecodebin3.c:1255
#14 0x00007f416836099d in probe_hook_marshal (hook=0x7f403c004340, data=0x7f4088df0660) at ../subprojects/gstreamer/gst/gstpad.c:3669
#15 0x00007f4168465a3e in g_hook_list_marshal (hook_list=0x7f41440e9e38, may_recurse=1, marshaller=0x7f4168360610 <probe_hook_marshal>, data=0x7f4088df0660) at ../glib/ghook.c:674
#16 0x00007f41683600de in do_probe_callbacks (pad=pad@entry=0x7f41440e9da0, info=info@entry=0x7f4088df0760, defaultval=defaultval@entry=GST_FLOW_OK) at ../subprojects/gstreamer/gst/gstpad.c:3853
#17 0x00007f416836487b in gst_pad_push_data (pad=pad@entry=0x7f41440e9da0, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4717
#18 0x00007f416836bc6b in gst_pad_push (pad=pad@entry=0x7f41440e9da0, buffer=buffer@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4858
#19 0x00007f416834ef53 in gst_proxy_pad_chain_default (pad=<optimized out>, parent=<optimized out>, buffer=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstghostpad.c:127
#20 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f4158126cf0, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4463
#21 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f415803f880, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4739
#22 0x00007f416836bc6b in gst_pad_push (pad=pad@entry=0x7f415803f880, buffer=buffer@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4858
#23 0x00007f416834ef53 in gst_proxy_pad_chain_default (pad=<optimized out>, parent=<optimized out>, buffer=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstghostpad.c:127
#24 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f4158126a90, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4463
#25 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f403c01a770, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4739
#26 0x00007f416836bc6b in gst_pad_push (pad=0x7f403c01a770, buffer=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4858
#27 0x00007f4167a6229a in gst_base_transform_chain (pad=<optimized out>, parent=0x7f41580b8f50, buffer=<optimized out>) at ../subprojects/gstreamer/libs/gst/base/gstbasetransform.c:2391
#28 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f403c01a520, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4463
#29 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f403c01a2d0, type=type@entry=4112, data=data@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4739
#30 0x00007f416836bc6b in gst_pad_push (pad=0x7f403c01a2d0, buffer=buffer@entry=0x7f4048024c60) at ../subprojects/gstreamer/gst/gstpad.c:4858
#31 0x00007f4167a42ab8 in gst_base_parse_push_frame (parse=parse@entry=0x7f403c018df0, frame=frame@entry=0x55ccc1d70e80) at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c:2607
#32 0x00007f4167a4599f in gst_base_parse_handle_and_push_frame (frame=0x55ccc1d70e80, parse=0x7f403c018df0) at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c:2458
#33 0x00007f4156e32a94 in gst_h264_parse_handle_frame_packetized (frame=0x55ccc1d70e80, parse=0x7f403c018df0) at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c:1307
#34 gst_h264_parse_handle_frame (parse=0x7f403c018df0, frame=0x55ccc1d70e80, skipsize=0x7f4088df100c) at ../subprojects/gst-plugins-bad/gst/videoparsers/gsth264parse.c:1358
#35 0x00007f4167a3d914 in gst_base_parse_handle_buffer (parse=parse@entry=0x7f403c018df0, buffer=<optimized out>, skip=skip@entry=0x7f4088df100c, flushed=flushed@entry=0x7f4088df1010) at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c:2266
#36 0x00007f4167a4374d in gst_base_parse_chain (pad=<optimized out>, parent=<optimized out>, buffer=<optimized out>) at ../subprojects/gstreamer/libs/gst/base/gstbaseparse.c:3315
#37 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f403c01a080, type=type@entry=4112, data=data@entry=0x7f415810e7e0) at ../subprojects/gstreamer/gst/gstpad.c:4463
#38 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f415811bc90, type=type@entry=4112, data=data@entry=0x7f415810e7e0) at ../subprojects/gstreamer/gst/gstpad.c:4739
#39 0x00007f416836bc6b in gst_pad_push (pad=0x7f415811bc90, buffer=0x7f415810e7e0) at ../subprojects/gstreamer/gst/gstpad.c:4858
#40 0x00007f4156e7c03f in gst_matroska_demux_parse_blockgroup_or_simpleblock (demux=demux@entry=0x7f41580a8fd0, ebml=ebml@entry=0x7f4088df14d0, cluster_time=<optimized out>, is_simpleblock=is_simpleblock@entry=1, cluster_offset=<optimized out>) at ../subprojects/gst-plugins-good/gst/matroska/matroska-demux.c:5069
#41 0x00007f4156e835a5 in gst_matroska_demux_parse_id (demux=demux@entry=0x7f41580a8fd0, id=<optimized out>, length=<optimized out>, needed=<optimized out>) at ../subprojects/gst-plugins-good/gst/matroska/matroska-demux.c:5807
#42 0x00007f4156e8914a in gst_matroska_demux_chain (pad=<optimized out>, parent=<optimized out>, buffer=0x0) at ../subprojects/gst-plugins-good/gst/matroska/matroska-demux.c:6202
#43 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f415811ba40, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4463
#44 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f415811b7f0, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4739
#45 0x00007f416836bc6b in gst_pad_push (pad=0x7f415811b7f0, buffer=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4858
#46 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f415811b5a0, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4463
#47 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f41581265d0, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4739
#48 0x00007f416836bc6b in gst_pad_push (pad=pad@entry=0x7f41581265d0, buffer=buffer@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4858
#49 0x00007f416834ef53 in gst_proxy_pad_chain_default (pad=<optimized out>, parent=<optimized out>, buffer=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstghostpad.c:127
#50 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x7f41440e9b30, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4463
#51 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x7f415811ac60, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4739
#52 0x00007f416836bc6b in gst_pad_push (pad=0x7f415811ac60, buffer=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4858
#53 0x00007f4168362681 in gst_pad_chain_data_unchecked (pad=pad@entry=0x55ccc1dc3520, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4463
#54 0x00007f4168364b11 in gst_pad_push_data (pad=pad@entry=0x55ccc1dc2e30, type=type@entry=4112, data=data@entry=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4739
#55 0x00007f416836bc6b in gst_pad_push (pad=pad@entry=0x55ccc1dc2e30, buffer=0x7f41580d47e0) at ../subprojects/gstreamer/gst/gstpad.c:4858
#56 0x00007f4167a5d4cd in gst_base_src_loop (pad=0x55ccc1dc2e30) at ../subprojects/gstreamer/libs/gst/base/gstbasesrc.c:3035
#57 0x00007f4168399f71 in gst_task_func (task=0x7f41580b1a70) at ../subprojects/gstreamer/gst/gsttask.c:384
#58 0x00007f41684aeaf2 in g_thread_pool_thread_proxy (data=<optimized out>) at ../glib/gthreadpool.c:352
#59 0x00007f41684a99c2 in g_thread_proxy (data=0x55ccc1da3180) at ../glib/gthread.c:831
#60 0x00007f416808714d in start_thread (arg=<optimized out>) at pthread_create.c:442
#61 0x00007f4168108a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
We can see it in the logs as well:
0:00:01.803888451 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1059:gst_decodebin3_release_pad:<decodebin3-0> input locking from thread 0x55ccc1da3180
0:00:01.803891527 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1059:gst_decodebin3_release_pad:<decodebin3-0> input locked from thread 0x55ccc1da3180
0:00:01.803898490 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1700:get_merged_collection:<decodebin3-0> Comparing res 0x7f416000ce80 input->collection (nil)
0:00:01.803958794 135992 0x55ccc1da3180 DEBUG decodebin3 gstdecodebin3-parse.c:407:remove_input_stream:<decodebin3-0> Removing input stream 0x7f404801c150 (b05dc2f7fd08c38d82dbb406a794bac04ce37fb136cf7604169514cc06b2f7b8)
0:00:01.803969805 135992 0x55ccc1da3180 DEBUG decodebin3 gstdecodebin3.c:2524:get_slot_for_input:<decodebin3-0> input 0x7f404801c150 (stream (nil) )
0:00:01.803972550 135992 0x55ccc1da3180 DEBUG decodebin3 gstdecodebin3.c:2539:get_slot_for_input:<decodebin3-0> Returning already specified slot 1
0:00:01.803975045 135992 0x55ccc1da3180 DEBUG decodebin3 gstdecodebin3-parse.c:430:remove_input_stream:<decodebin3-0> slot 0x7f404801d640 cleared
0:00:01.804002667 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1139:reset_input:<decodebin3-0> Resetting input 0x7f404801b690
0:00:01.804009009 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1171:free_input:<decodebin3-0> Freeing input 0x7f404801b690
0:00:01.804013097 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1027:gst_decodebin3_input_pad_unlink:<decodebin3-0> Got unlink on input pad <decodebin3-0:sink_0>
0:00:01.804015872 135992 0x55ccc1da3180 LOG decodebin3 gstdecodebin3.c:1029:gst_decodebin3_input_pad_unlink:<decodebin3-0> input locking from thread 0x55ccc1da3180
cc @bilboed