Segmentation fault in GstSdp.sdp_message_parse_buffer and GstSdp.sdp_message_add_media with GST-Python introduced in 1.21.2
Describe your issue
When running GstSdp GST-Python with 1.21.2, the below segmentation fault occurs continuously. webrtcbin
initializes without issues, but the segmentation fault consistently occurs after the ICE connection is established and right before the stream is sent to the client.
0:00:18.085279278 50036 0x15f8580 DEBUG GST_SCHEDULING gstpad.c:4452:gst_pad_chain_data_unchecked:<nvenc:sink> called chainfunction &gst_video_encoder_chain with buffer 0x1a0cb40, returned ok
0:00:18.085288794 50036 0x15f8580 DEBUG GST_SCHEDULING gstpad.c:4452:gst_pad_chain_data_unchecked:<capsfilter1:sink> called chainfunction &gst_base_transform_chain with buffer 0x1a0cb40, returned ok
0:00:18.085297796 50036 0x15f8580 DEBUG GST_SCHEDULING gstpad.c:4452:gst_pad_chain_data_unchecked:<cudaconvert0:sink> called chainfunction &gst_base_transform_chain with buffer 0x1a0c6c0, returned ok
0:00:18.085306723 50036 0x15f8580 DEBUG GST_SCHEDULING gstpad.c:4452:gst_pad_chain_data_unchecked:<cudaupload0:sink> called chainfunction &gst_base_transform_chain with buffer 0x1a0c5a0, returned ok
0:00:18.085315830 50036 0x15f8580 DEBUG GST_SCHEDULING gstpad.c:4452:gst_pad_chain_data_unchecked:<capsfilter0:sink> called chainfunction &gst_base_transform_chain with buffer 0x1a0c5a0, returned ok
0:00:18.085326936 50036 0x15f8580 LOG basesrc gstbasesrc.c:2902:gst_base_src_loop:<x11> next_ts 99:99:99.999999999 size 16384
0:00:18.085335725 50036 0x15f8580 DEBUG basesrc gstbasesrc.c:2579:gst_base_src_get_range:<x11> calling create offset 18446744073709551615 length 16384, time 0
0:00:18.085346351 50036 0x15f8580 DEBUG GST_CLOCK gstclock.c:1086:gst_clock_get_internal_time:<GstSystemClock> internal time 208:14:38.804611766
0:00:18.085355649 50036 0x15f8580 DEBUG GST_CLOCK gstclock.c:1129:gst_clock_get_time:<GstSystemClock> adjusted time 208:14:38.804611766
0:00:18.085365938 50036 0x15f8580 DEBUG GST_CLOCK gstclock.c:254:gst_clock_entry_new:<GstSystemClock> created entry 0xded990, time 208:14:38.866574866
0:00:18.085373852 50036 0x15f8580 DEBUG ximagesrc gstximagesrc.c:886:gst_ximage_src_create:<x11> Waiting for next frame time 466666666
0:00:18.085381734 50036 0x15f8580 DEBUG GST_CLOCK gstclock.c:548:gst_clock_id_wait:<GstSystemClock> waitingon clock entry 0xded990
0:00:18.085389334 50036 0x15f8580 DEBUG GST_CLOCK gstsystemclock.c:1121:gst_system_clock_id_wait_jitter:<GstSystemClock> waiting on entry 0xded990
0:00:18.085398694 50036 0x15f8580 DEBUG GST_CLOCK gstclock.c:1086:gst_clock_get_internal_time:<GstSystemClock> internal time 208:14:38.804664523
0:00:18.085407519 50036 0x15f8580 DEBUG GST_CLOCK gstclock.c:1129:gst_clock_get_time:<GstSystemClock> adjusted time 208:14:38.804664523
0:00:18.085419194 50036 0x15f8580 DEBUG GST_CLOCK gstsystemclock.c:973:gst_system_clock_id_wait_jitter_unlocked:<GstSystemClock> entry 0xded990 time 208:14:38.866574866 now 208:14:38.804664523 diff (time-now) 61910343
INFO:signaling:1 -> 0: {"sdp":{"type":"answer","sdp":"v=0\r\no=- 1501727331958550276 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE video0 application1\r\na=msid-semantic: WMS\r\nm=video 9 UDP/TLS/RTP/SAVPF 123 96\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9IN IP4 0.0.0.0\r\na=ice-ufrag:3vpx\r\na=ice-pwd:/4Ar7b1KEEabk7qK2+GZ4VO4\r\na=ice-options:trickle\r\na=fingerprint:sha-256 52:52:95:7A:83:34:1E:54:1D:22:85:CF:96:42:1F:CC:7D:E9:FA:E2:C5:BD:85:4D:71:AD:38:8F:8C:F2:47:D6\r\na=setup:active\r\na=mid:video0\r\na=recvonly\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:123 H264/90000\r\na=rtcp-fb:123 transport-cc\r\na=rtcp-fb:123 ccm fir\r\na=rtcp-fb:123 nack\r\na=rtcp-fb:123 nack pli\r\na=fmtp:123 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f\r\na=rtpmap:96 rtx/90000\r\na=fmtp:96 apt=123;rtx-time=125\r\nm=application 9 UDP/DTLS/SCTP webrtc-datachannel\r\nc=IN IP4 0.0.0.0\r\na=ice-ufrag:3vpx\r\na=ice-pwd:/4Ar7b1KEEabk7qK2+GZ4VO4\r\na=ice-options:trickle\r\na=fingerprint:sha-256 52:52:95:7A:83:34:1E:54:1D:22:85:CF:96:42:1F:CC:7D:E9:FA:E2:C5:BD:85:4D:71:AD:38:8F:8C:F2:47:D6\r\na=setup:active\r\na=mid:application1\r\na=sctp-port:5000\r\n"}}
[Detaching after fork from child process 50151]
/usr/local/lib/python3.8/dist-packages/selkies_gstreamer/gstwebrtc_app.py:725: Warning: g_array_append_vals: assertion 'array' failed
sdpmsg = GstSdp.sdp_message_parse_buffer(bytes(sdp.encode()))
/usr/local/lib/python3.8/dist-packages/selkies_gstreamer/gstwebrtc_app.py:725: Warning: g_array_append_vals: assertion 'array' failed
sdpmsg = GstSdp.sdp_message_parse_buffer(bytes(sdp.encode()))
0:00:18.126577032 50036 0x7fffcc002b00 INFO webrtcbin gstwebrtcbin.c:1450:_update_ice_gathering_state_task:<app> ICE gathering state change from gathering(1) to complete(2)
0:00:18.126608772 50036 0x7fffcc002b00 LOG GST_PROPERTIES gstobject.c:472:gst_object_dispatch_properties_changed:<pipeline0> deep notification from app (ice-gathering-state)
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007ffff410f417 in gst_sdp_message_add_media (msg=0x1c7f0c0, media=0x7fffffffa390)
at ../subprojects/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.c:1783
1783 len = msg->medias->len;
Expected Behavior
GStreamer 1.21.2 should run the pipeline correctly and send the stream.
Observed Behavior
Setup
- Operating System: Ubuntu 20.04, 18.04
- Device: Computer
- GStreamer Version: 1.21.2, GST-Python
- Command line: Located below.
Steps to reproduce the bug
When GST_DEBUG
set to *:6
, this is consistent when running the above GST Python pipeline:
0:00:18.126577032 50036 0x7fffcc002b00 INFO webrtcbin gstwebrtcbin.c:1450:_update_ice_gathering_state_task:<app> ICE gathering state change from gathering(1) to complete(2)
0:00:18.126608772 50036 0x7fffcc002b00 LOG GST_PROPERTIES gstobject.c:472:gst_object_dispatch_properties_changed:<pipeline0> deep notification from app (ice-gathering-state)
Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007ffff410f417 in gst_sdp_message_add_media (msg=0x1c7f0c0, media=0x7fffffffa390)
at ../subprojects/gst-plugins-base/gst-libs/gst/sdp/gstsdpmessage.c:1783
1783 len = msg->medias->len
How reproducible is the bug?
Always, after running the pipeline https://github.com/selkies-project/selkies-gstreamer/blob/gst-1.21.1/src/selkies_gstreamer/gstwebrtc_app.py on GST 1.21.2. Does not happen on 1.20.x.
Other notes
To @slomo: https://github.com/selkies-project/selkies-gstreamer/blob/gst-1.21.1/src/selkies_gstreamer/gstwebrtc_app.py#L725
Did I do this correctly as per !3194 (2650bba8) as @tpm informed me?
Previously it was like https://github.com/selkies-project/selkies-gstreamer/blob/276fe41d4a23d0985b819e3fc64b173753293456/src/selkies_gstreamer/gstwebrtc_app.py#L727 but GStreamer 1.21.2 threw an exception and we changed it to the above.
I see a warning about:
/usr/local/lib/python3.8/dist-packages/selkies_gstreamer/gstwebrtc_app.py:725: Warning: g_array_append_vals: assertion 'array' failed
sdpmsg = GstSdp.sdp_message_parse_buffer(bytes(sdp.encode()))
/usr/local/lib/python3.8/dist-packages/selkies_gstreamer/gstwebrtc_app.py:725: Warning: g_array_append_vals: assertion 'array' failed
sdpmsg = GstSdp.sdp_message_parse_buffer(bytes(sdp.encode())