ZLMediaKit / ZLMediaKit

WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181/SRT server and client framework based on C++11
https://docs.zlmediakit.com
Other
13.95k stars 3.41k forks source link

[Bug] Using built-in web page test, a segmentation fault appears when testing WEBRTC functionality. #2911

Closed heyingjie closed 1 year ago

heyingjie commented 1 year ago

Phenomenon Description

Use the built-in WEBRTC testing interface, open two browser windows, one pushes and the other plays, and after a few minutes, a segmentation fault occurs.

How to reproduce?

Related logs or screenshots

Expand to view detailed logs
2023-10-20 13:47:54.268 W [MediaServer] [218624-event poller 4] Rtcp.cpp:234 loa                                                                                                                                                             dFromBytes | rtcp xr bt * not support,长度为:16
## crash date:2023-10-20 13:47:54
## exe:       MediaServer
## signal:    11
## version:   ZLMediaKit(git hash:7ee2d66/2023-10-19T17:55:30+08:00,branch:maste                                                                                                                                                             r,build time:2023-10-20T13:28:17)
## stack:
[0]: ./MediaServer() [0x5bdff4]
sig_crash(int)
System.cpp:?

[1]: /lib64/libc.so.6(+0x39770) [0x7f80d8cbb770]
??
??:0

[2]: /usr/local/lib/libjemalloc.so.2(+0x20a6c) [0x7f80d961ea6c]
??
??:0

[3]: ./MediaServer() [0x8f7f28]
onRecvSctpData(socket*, sctp_sockstore, void*, unsigned long, sctp_rcvinfo, int,                                                                                                                                                              void*)
SctpAssociation.cpp:?

[4]: /usr/local/lib/libusrsctp.so.1(sctp_add_to_readq+0xb01) [0x7f80d9235e10]
??
??:0

[5]: /usr/local/lib/libusrsctp.so.1(+0x9c989) [0x7f80d9230989]
??
??:0

[6]: /usr/local/lib/libusrsctp.so.1(sctp_ulp_notify+0x430) [0x7f80d92332cc]
??
??:0

[7]: /usr/local/lib/libusrsctp.so.1(sctp_abort_notification+0x131) [0x7f80d92345                                                                                                                                                             df]
??
??:0

[8]: /usr/local/lib/libusrsctp.so.1(sctp_abort_an_association+0xab) [0x7f80d9234                                                                                                                                                             7aa]
??
??:0

[9]: /usr/local/lib/libusrsctp.so.1(+0x7d8a5) [0x7f80d92118a5]
??
??:0

[10]: /usr/local/lib/libusrsctp.so.1(sctp_t1init_timer+0x8b) [0x7f80d92140d7]
??
??:0

[11]: /usr/local/lib/libusrsctp.so.1(sctp_timeout_handler+0x4ac) [0x7f80d922e685                                                                                                                                                             ]
??
??:0

[12]: /usr/local/lib/libusrsctp.so.1(+0x250ee) [0x7f80d91b90ee]
??
??:0

[13]: /usr/local/lib/libusrsctp.so.1(user_sctp_timer_iterate+0xac) [0x7f80d91b91                                                                                                                                                             f1]
??
??:0

[14]: /lib64/libpthread.so.0(+0x8fed) [0x7f80d925cfed]
??
??:0

[15]: /lib64/libc.so.6(clone+0x3f) [0x7f80d8d7f18f]
??
??:0

段错误 (核心已转储)

Configuration

Please expand to view detailed configuration
; auto-generated by mINI class {

[api]
apiDebug=1
defaultSnap=./www/logo.png
secret=M7nARfASubXxPgOMePEkGeGf0jnFVeeH
snapRoot=./www/snap/

[cluster]
origin_url=
retry_count=3
timeout_sec=15

[ffmpeg]
bin=/usr/bin/ffmpeg
cmd=%s -re -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s
log=./ffmpeg/ffmpeg.log
restart_sec=0
snap=%s -i %s -y -f mjpeg -frames:v 1 %s

[general]
check_nvidia_dev=1
enableVhost=0
enable_ffmpeg_log=0
flowThreshold=1024
maxStreamWaitMS=15000
mediaServerId=your_server_id
mergeWriteMS=0
resetWhenRePlay=1
streamNoneReaderDelayMS=20000
unready_frame_cache=100
wait_add_track_ms=3000
wait_track_ready_ms=10000

[hls]
broadcastRecordTs=0
deleteDelaySec=10
fileBufSize=65536
segDur=2
segKeep=0
segNum=3
segRetain=5

[hook]
alive_interval=10.0
enable=0
on_flow_report=https://127.0.0.1/index/hook/on_flow_report
on_http_access=https://127.0.0.1/index/hook/on_http_access
on_play=https://127.0.0.1/index/hook/on_play
on_publish=https://127.0.0.1/index/hook/on_publish
on_record_mp4=https://127.0.0.1/index/hook/on_record_mp4
on_record_ts=https://127.0.0.1/index/hook/on_record_ts
on_rtp_server_timeout=https://127.0.0.1/index/hook/on_rtp_server_timeout
on_rtsp_auth=https://127.0.0.1/index/hook/on_rtsp_auth
on_rtsp_realm=https://127.0.0.1/index/hook/on_rtsp_realm
on_send_rtp_stopped=https://127.0.0.1/index/hook/on_send_rtp_stopped
on_server_exited=https://127.0.0.1/index/hook/on_server_exited
on_server_keepalive=https://127.0.0.1/index/hook/on_server_keepalive
on_server_started=https://127.0.0.1/index/hook/on_server_started
on_shell_login=https://127.0.0.1/index/hook/on_shell_login
on_stream_changed=https://127.0.0.1/index/hook/on_stream_changed
on_stream_none_reader=https://127.0.0.1/index/hook/on_stream_none_reader
on_stream_not_found=https://127.0.0.1/index/hook/on_stream_not_found
retry=1
retry_delay=3.0
stream_changed_schemas=rtsp/rtmp/fmp4/ts/hls/hls.fmp4
timeoutSec=10

[http]
allow_cross_domains=1
allow_ip_range=::1,127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255
charSet=utf-8
dirMenu=1
forbidCacheSuffix=
forwarded_ip_header=
keepAliveSecond=30
maxReqSize=40960
notFound=404 Not Found

您访问的资源不存在!


ZLMediaKit(git hash:7ee2d66/2023-10-19T17:55:30+08:00,branch:master,build time:2023-10-20T13:28:17)
port=80 rootPath=./www sendBufSize=65536 sslport=443 virtualPath= [multicast] addrMax=239.255.255.255 addrMin=239.0.0.0 udpTTL=64 [protocol] add_mute_audio=1 auto_close=0 continue_push_ms=15000 enable_audio=1 enable_fmp4=1 enable_hls=1 enable_hls_fmp4=0 enable_mp4=0 enable_rtmp=1 enable_rtsp=1 enable_ts=1 fmp4_demand=0 hls_demand=0 hls_save_path=./www modify_stamp=2 mp4_as_player=0 mp4_max_second=3600 mp4_save_path=./www rtmp_demand=0 rtsp_demand=0 ts_demand=0 [record] appName=record fastStart=0 fileBufSize=65536 fileRepeat=0 sampleMS=500 [rtc] externIP= port=8000 preferredCodecA=PCMU,PCMA,opus,mpeg4-generic preferredCodecV=H264,H265,AV1,VP9,VP8 rembBitRate=0 tcpPort=8000 timeoutSec=15 [rtmp] handshakeSecond=15 keepAliveSecond=15 port=1935 sslport=0 [rtp] audioMtuSize=600 h264_stap_a=1 lowLatency=0 rtpMaxSize=10 videoMtuSize=1400 [rtp_proxy] dumpDir= gop_cache=1 h264_pt=98 h265_pt=99 opus_pt=100 port=10000 port_range=30000-35000 ps_pt=96 timeoutSec=15 [rtsp] authBasic=0 directProxy=1 handshakeSecond=15 keepAliveSecond=15 lowLatency=0 port=554 rtpTransportType=-1 sslport=0 [shell] maxReqSize=1024 port=0 [srt] latencyMul=4 pktBufSize=8192 port=9000 timeoutSec=5 ; } ---

Various environment information

现象描述

使用自带的WEBRTC测试界面,在浏览器上开两个窗口,一个窗口push,一个窗口play,过了几分钟出现段错误

如何复现?

相关日志或截图

展开查看详细日志
2023-10-20 13:47:54.268 W [MediaServer] [218624-event poller 4] Rtcp.cpp:234 loa                                                                                                                                                             dFromBytes | rtcp xr bt * not support,长度为:16
## crash date:2023-10-20 13:47:54
## exe:       MediaServer
## signal:    11
## version:   ZLMediaKit(git hash:7ee2d66/2023-10-19T17:55:30+08:00,branch:maste                                                                                                                                                             r,build time:2023-10-20T13:28:17)
## stack:
[0]: ./MediaServer() [0x5bdff4]
sig_crash(int)
System.cpp:?

[1]: /lib64/libc.so.6(+0x39770) [0x7f80d8cbb770]
??
??:0

[2]: /usr/local/lib/libjemalloc.so.2(+0x20a6c) [0x7f80d961ea6c]
??
??:0

[3]: ./MediaServer() [0x8f7f28]
onRecvSctpData(socket*, sctp_sockstore, void*, unsigned long, sctp_rcvinfo, int,                                                                                                                                                              void*)
SctpAssociation.cpp:?

[4]: /usr/local/lib/libusrsctp.so.1(sctp_add_to_readq+0xb01) [0x7f80d9235e10]
??
??:0

[5]: /usr/local/lib/libusrsctp.so.1(+0x9c989) [0x7f80d9230989]
??
??:0

[6]: /usr/local/lib/libusrsctp.so.1(sctp_ulp_notify+0x430) [0x7f80d92332cc]
??
??:0

[7]: /usr/local/lib/libusrsctp.so.1(sctp_abort_notification+0x131) [0x7f80d92345                                                                                                                                                             df]
??
??:0

[8]: /usr/local/lib/libusrsctp.so.1(sctp_abort_an_association+0xab) [0x7f80d9234                                                                                                                                                             7aa]
??
??:0

[9]: /usr/local/lib/libusrsctp.so.1(+0x7d8a5) [0x7f80d92118a5]
??
??:0

[10]: /usr/local/lib/libusrsctp.so.1(sctp_t1init_timer+0x8b) [0x7f80d92140d7]
??
??:0

[11]: /usr/local/lib/libusrsctp.so.1(sctp_timeout_handler+0x4ac) [0x7f80d922e685                                                                                                                                                             ]
??
??:0

[12]: /usr/local/lib/libusrsctp.so.1(+0x250ee) [0x7f80d91b90ee]
??
??:0

[13]: /usr/local/lib/libusrsctp.so.1(user_sctp_timer_iterate+0xac) [0x7f80d91b91                                                                                                                                                             f1]
??
??:0

[14]: /lib64/libpthread.so.0(+0x8fed) [0x7f80d925cfed]
??
??:0

[15]: /lib64/libc.so.6(clone+0x3f) [0x7f80d8d7f18f]
??
??:0

段错误 (核心已转储)

配置

展开查看详细配置
; auto-generated by mINI class {

[api]
apiDebug=1
defaultSnap=./www/logo.png
secret=M7nARfASubXxPgOMePEkGeGf0jnFVeeH
snapRoot=./www/snap/

[cluster]
origin_url=
retry_count=3
timeout_sec=15

[ffmpeg]
bin=/usr/bin/ffmpeg
cmd=%s -re -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264 -f flv %s
log=./ffmpeg/ffmpeg.log
restart_sec=0
snap=%s -i %s -y -f mjpeg -frames:v 1 %s

[general]
check_nvidia_dev=1
enableVhost=0
enable_ffmpeg_log=0
flowThreshold=1024
maxStreamWaitMS=15000
mediaServerId=your_server_id
mergeWriteMS=0
resetWhenRePlay=1
streamNoneReaderDelayMS=20000
unready_frame_cache=100
wait_add_track_ms=3000
wait_track_ready_ms=10000

[hls]
broadcastRecordTs=0
deleteDelaySec=10
fileBufSize=65536
segDur=2
segKeep=0
segNum=3
segRetain=5

[hook]
alive_interval=10.0
enable=0
on_flow_report=https://127.0.0.1/index/hook/on_flow_report
on_http_access=https://127.0.0.1/index/hook/on_http_access
on_play=https://127.0.0.1/index/hook/on_play
on_publish=https://127.0.0.1/index/hook/on_publish
on_record_mp4=https://127.0.0.1/index/hook/on_record_mp4
on_record_ts=https://127.0.0.1/index/hook/on_record_ts
on_rtp_server_timeout=https://127.0.0.1/index/hook/on_rtp_server_timeout
on_rtsp_auth=https://127.0.0.1/index/hook/on_rtsp_auth
on_rtsp_realm=https://127.0.0.1/index/hook/on_rtsp_realm
on_send_rtp_stopped=https://127.0.0.1/index/hook/on_send_rtp_stopped
on_server_exited=https://127.0.0.1/index/hook/on_server_exited
on_server_keepalive=https://127.0.0.1/index/hook/on_server_keepalive
on_server_started=https://127.0.0.1/index/hook/on_server_started
on_shell_login=https://127.0.0.1/index/hook/on_shell_login
on_stream_changed=https://127.0.0.1/index/hook/on_stream_changed
on_stream_none_reader=https://127.0.0.1/index/hook/on_stream_none_reader
on_stream_not_found=https://127.0.0.1/index/hook/on_stream_not_found
retry=1
retry_delay=3.0
stream_changed_schemas=rtsp/rtmp/fmp4/ts/hls/hls.fmp4
timeoutSec=10

[http]
allow_cross_domains=1
allow_ip_range=::1,127.0.0.1,172.16.0.0-172.31.255.255,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255
charSet=utf-8
dirMenu=1
forbidCacheSuffix=
forwarded_ip_header=
keepAliveSecond=30
maxReqSize=40960
notFound=404 Not Found

您访问的资源不存在!


ZLMediaKit(git hash:7ee2d66/2023-10-19T17:55:30+08:00,branch:master,build time:2023-10-20T13:28:17)
port=80 rootPath=./www sendBufSize=65536 sslport=443 virtualPath= [multicast] addrMax=239.255.255.255 addrMin=239.0.0.0 udpTTL=64 [protocol] add_mute_audio=1 auto_close=0 continue_push_ms=15000 enable_audio=1 enable_fmp4=1 enable_hls=1 enable_hls_fmp4=0 enable_mp4=0 enable_rtmp=1 enable_rtsp=1 enable_ts=1 fmp4_demand=0 hls_demand=0 hls_save_path=./www modify_stamp=2 mp4_as_player=0 mp4_max_second=3600 mp4_save_path=./www rtmp_demand=0 rtsp_demand=0 ts_demand=0 [record] appName=record fastStart=0 fileBufSize=65536 fileRepeat=0 sampleMS=500 [rtc] externIP= port=8000 preferredCodecA=PCMU,PCMA,opus,mpeg4-generic preferredCodecV=H264,H265,AV1,VP9,VP8 rembBitRate=0 tcpPort=8000 timeoutSec=15 [rtmp] handshakeSecond=15 keepAliveSecond=15 port=1935 sslport=0 [rtp] audioMtuSize=600 h264_stap_a=1 lowLatency=0 rtpMaxSize=10 videoMtuSize=1400 [rtp_proxy] dumpDir= gop_cache=1 h264_pt=98 h265_pt=99 opus_pt=100 port=10000 port_range=30000-35000 ps_pt=96 timeoutSec=15 [rtsp] authBasic=0 directProxy=1 handshakeSecond=15 keepAliveSecond=15 lowLatency=0 port=554 rtpTransportType=-1 sslport=0 [shell] maxReqSize=1024 port=0 [srt] latencyMul=4 pktBufSize=8192 port=9000 timeoutSec=5 ; } ---

各种环境信息

TRANS_BY_GITHUB_AI_ASSISTANT

xia-chu commented 1 year ago

You enabled the datachannel function which caused a crash, however I can't see which line caused the crash.

Could you try debugging with gdb and give me the backtrace stack?

Datachannel should be stable, I think there might be other reasons for the crash.

你这个开启了datachannel功能 这个导致崩溃的 但是看不到具体崩溃在哪一行 可以gdb调休下 然后给下bt栈不?

datachannel应该是稳定的 我觉得可能是其他原因导致崩溃

TRANS_BY_GITHUB_AI_ASSISTANT

heyingjie commented 1 year ago

Here is the translation:

image

I do not have a datachannel option on the website, as shown in the above figure, gdb bt information.

image

网页上我没有选datachannel选项,上图是gdb bt信息

TRANS_BY_GITHUB_AI_ASSISTANT

heyingjie commented 1 year ago

It seems I know the cause now, possibly it's due to the problems with the usrsctp library I used, which I obtained from an unofficial code library. I've already replaced it with the official library, and currently the testing is normal, I'll run it for a while to see if there are any issues, and if everything goes smoothly by tomorrow, I'll come back and close this issue.

大概知道原因了,可能是我用的usrsctp库的问题,下了个非官方的代码库。已经更换了官方的库,目前测试正常,我这边跑一段时间老化看看,跑到明天没问题的话,我过来把这个issue close掉。

TRANS_BY_GITHUB_AI_ASSISTANT

heyingjie commented 1 year ago

Results are normal, close this issue.

测试正常,关闭该issue

TRANS_BY_GITHUB_AI_ASSISTANT