close
The Wayback Machine - https://web.archive.org/web/20220411202950/https://github.com/ossrs/srs/issues/2819
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTC推流转rtmp,偶现packet_video_rtmp函数参数start为0,导致pkt空指针,触发死机bug #2819

Open
mapengfei53 opened this issue Dec 27, 2021 · 0 comments
Assignees
Labels
Bug good first issue WebRTC
Milestone

Comments

@mapengfei53
Copy link
Contributor

@mapengfei53 mapengfei53 commented Dec 27, 2021

描述(Description)

RTC推流转rtmp,偶现packet_video_rtmp函数参数start为0,导致pkt空指针,触发死机bug

  1. SRS版本(Version): 4.0210

  2. SRS的日志如下(Log):

 [2021-12-24 15:20:31.786][Trace][58792][m7039d48] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
 [2021-12-24 15:20:31.786][Trace][58792][by696p1r] TCP: disposing #0 resource(HttpsConn)(0x3058370), conns=1, disposing=1, zombies=0
 [2021-12-24 15:20:31.797][Trace][58792][ati38uw8] https: api server done, use key ./conf/server.key and cert ./conf/server.crt, cost=8ms
 [2021-12-24 15:20:31.798][Trace][58792][ati38uw8] HTTP #0 10.0.3.116:56842 OPTIONS https://10.0.3.251/rtc/v1/publish/, content-length=-1
 [2021-12-24 15:20:31.800][Trace][58792][ati38uw8] HTTP #1 10.0.3.116:56842 POST https://10.0.3.251/rtc/v1/publish/, content-length=5968
 [2021-12-24 15:20:31.801][Trace][58792][ati38uw8] http: hook callback report url is http://127.0.0.1:8085/api/v1/streams
 [2021-12-24 15:20:31.810][Trace][58792][ati38uw8] http: on_publish ok, client_id=ati38uw8, url=http://127.0.0.1:8085/api/v1/streams, request={"server_id":"vid-52ed128","action":"on_publish","client_id":"a
 [2021-12-24 15:20:31.811][Trace][58792][ati38uw8] RTC publish webrtc://10.0.3.251/live/livestream, api=https://10.0.3.251:443/rtc/v1/publish/, tid=b410491, clientip=10.0.3.116, app=live, stream=livestream
 [2021-12-24 15:20:31.811][Trace][58792][ati38uw8] ignore attribute=, value=
 [2021-12-24 15:20:31.812][Trace][58792][ati38uw8] RTC publisher nack=1, nnc=1, pt-drop=0, twcc=1/3
 [2021-12-24 15:20:31.813][Trace][58792][ati38uw8] RTC: Init tracks {track: 87330456-1561-4882-b8af-4b2221d48c7a, is_active: 0=>1},{track: 5a53ec57-41c5-4319-ba56-56dee4de3355, is_active: 0=>1}, ok
 [2021-12-24 15:20:31.813][Trace][58792][ati38uw8] Best matched ip=10.0.3.251, ifname=ens33
 [2021-12-24 15:20:31.813][Trace][58792][ati38uw8] RTC: Use candidates 10.0.3.251
 [2021-12-24 15:20:31.814][Trace][58792][ati38uw8] RTC init session, user=6099428l:cbVA, url=/live/livestream, encrypt=1/1, DTLS(role=passive, version=auto), timeout=30000ms, nack=1
 [2021-12-24 15:20:31.814][Trace][58792][ati38uw8] RTC username=6099428l:cbVA, offer=5503B, answer=1444B
 [2021-12-24 15:20:31.814][Trace][58792][ati38uw8] RTC remote offer: v=0\r\no=- 8815264866949187145 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS\
 [2021-12-24 15:20:31.814][Trace][58792][ati38uw8] RTC local answer: v=0\r\no=NSS/4.0.210(NGAA) 49315648 2 IN IP4 0.0.0.0\r\ns=SRSPublishSession\r\nt=0 0\r\na=ice-lite\r\na=group:BUNDLE 0 1\r\na=msid-seman
 [2021-12-24 15:20:31.815][Trace][58792][ati38uw8] TCP: before dispose resource(HttpsConn)(0x3058370), conns=1, zombies=0, ign=0, inz=0, ind=0
 [2021-12-24 15:20:31.816][Warn][58792][ati38uw8][104] client disconnect peer. ret=1007
 [2021-12-24 15:20:31.816][Trace][58792][m7039d48] TCP: clear zombies=1 resources, conns=1, removing=0, unsubs=0
 [2021-12-24 15:20:31.816][Trace][58792][ati38uw8] TCP: disposing #0 resource(HttpsConn)(0x3058370), conns=1, disposing=1, zombies=0
 [2021-12-24 15:20:31.919][Trace][58792][ati38uw8] RTC: session address init 10.0.3.116:62017
 [2021-12-24 15:20:31.920][Trace][58792][ati38uw8] RTC: session STUN done, waiting DTLS handshake.
 [2021-12-24 15:20:31.921][Trace][58792][ati38uw8] DTLS: State Passive RECV, done=0, arq=0/0, r0=1, r1=0, len=157, cnt=22, size=144, hs=1
 [2021-12-24 15:20:31.921][Trace][58792][ati38uw8] DTLS: State Passive SEND, done=0, arq=0/0, r0=-1, r1=2, len=680, cnt=22, size=82, hs=2
 [2021-12-24 15:20:31.923][Trace][58792][ati38uw8] DTLS: State Passive RECV, done=0, arq=0/0, r0=1, r1=0, len=579, cnt=22, size=299, hs=11
 [2021-12-24 15:20:31.924][Trace][58792][ati38uw8] DTLS: State Passive SEND, done=1, arq=0/0, r0=1, r1=0, len=554, cnt=22, size=466, hs=4
 [2021-12-24 15:20:31.924][Trace][58792][ati38uw8] RTC: DTLS handshake done.
 [2021-12-24 15:20:31.924][Trace][58792][ati38uw8] RTC: session pub=1, sub=0, to=30000ms connection established
 [2021-12-24 15:20:31.924][Trace][58792][ati38uw8] RTC: Publisher url=/live/livestream established
 [2021-12-24 15:20:31.925][Trace][58792][ati38uw8] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1
 [2021-12-24 15:20:31.925][Trace][58792][ati38uw8] ignore disabled exec for vhost=__defaultVhost__
 [2021-12-24 15:20:31.950][Trace][58792][5mntfn0l] update source_id=ati38uw8/403mj639
  1. SRS的core文件如下(Log):
#0  0x00000000006316d2 in SrsRtpPacket::get_avsync_time (this=0x0) at src/kernel/srs_kernel_rtc_rtp.hpp:335
#1  0x000000000062bd99 in SrsRtmpFromRtcBridger::packet_video_rtmp (this=0x2ea7cd0, start=0, end=29154) at src/app/srs_app_rtc_source.cpp:1615
#2  0x000000000062aef9 in SrsRtmpFromRtcBridger::packet_video (this=0x2ea7cd0, src=0x3063220) at src/app/srs_app_rtc_source.cpp:1452
#3  0x000000000062a6ae in SrsRtmpFromtcBridger::on_rtp (this=0x2ea7cd0, pt=0x3063220) at src/app/srs_app_rtc_source.cpp:1348
#4  0x0000000000627b82 in SrsRtcSource::on_rtp(this=0x2e8e4c0,pkt=0x3063220)at src/app/srs_app_rtc_source.cpp:633
#5  0x0000000000630581 in SrsRtcVideoRecvTrack::on_rtp (this=0x32bb920, source=0x2e8e4c0, pkt=0x3063220) at src/app/srs_app_rtc_source.cpp:2521
#6  0x00000000005eca81 in SrsRtcPublishstream::do_on_rtp_plaintext (this=0x30e2320, pkt=@0x7f06b6565758: 0x3063220, buf=0x7f06b6565740) at sc/app/srs_app_rtc_conn.cpp:1453
#7  0x00000000005ec83c in SrsRtcPublishStream::on_rtp_plaintext (this=0x30e2320, plaintext=0x2e1e000 "\220\375q\343\377U\353GD\211\340\005\276", <incomplete sequence \336>, nb_plaintext=147)
    at src/app/srs_app_rtc_conn.cpp:1421
#8  0x00000000005ec56e in SrsRtcPublishStream::on_rtp (this=0x30e2320, data=0x2e1e000 "\220\375q\343\377U\353GD\211\340\005\276", <incomplete sequence \336>, nb_data=157) at src/app/srs_app_rtc_conn.cpp:1388
#9  0x00000000005f0cb2 in SrsRtcConnection::on_rtp (this=0x2f07f40, data=0x2e1e000 "\220\375q\343\377U\353GD\211\340\005\276", <incomplete sequence \336>, nb_data=157) at src/app/srs_app_rtc_conn.cpp:2284
#10 0x0000000000622322 in SrsRtcServer::on_udp_packet (this=0x2e0ad50, skt=0x100947570) at src/app/srs_app_rtc_server.cpp:416
#11 0x00000000005c2a52 in SrsUdpMuxListener::cycle (this=0x2dfac60) at src/app/srs_app_listener.cpp:620
#12 0x000000000053a981 in SrsFastCoroutine::cycle (this=0x2e0ada0) at src/app/srs_app_st.cpp:272
#13 0x000000000053aa04 in SrsFastCoroutine::pfn (arg=0x2e0ada0) at src/app/srs_app_st.cpp:287
#14 0x00000000006419dd in st thread main () at sched.c:363
#15 0x0000000000642250 in st thread create (start=0x7f06b551b760 <main arena>,
arg=0x38, joinable=32518, stk_size=-1256351860) at sched.c:694
#16 0x00007ffca5446850 in ?? ()
#17 0x00007ffca5446930 in ?? ()
#18 0x00007ffca5446940 in ?? ()
#19 0x0000000000000000 in ?? ()
  1. SRS的配置如下(Config):
listen 1935;
max_connections 1000;
chunk_size 60000;
daemon on;
srs_log_tank file;
pid ./objs/nsrs.pid;
srs_log_file ./objs/nsrs.log;
ff_log_dir ./objs;
srs_log_level trace;

http_server {
    enabled         on;
    listen          80;
    dir             ./objs/nginx/html;
    https {
        enabled on;
        listen 1443;
        key ./conf/server.key;
        cert ./conf/server.crt;
    }
}

http_api {
    enabled         on;
    listen          1985;
    https {
        enabled on;
        listen 443;
        key ./conf/server.key;
        cert ./conf/server.crt;
    }
}

stats {
    network         0;
}

rtc_server {
    enabled on;
    listen 8000;
    candidate *;
}

vhost __defaultVhost__ {
    enabled on;

    hls {
        enabled         on;                
        hls_fragment    10;
        hls_window      60;
        hls_path        ./objs/nginx/html;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[stream]-[seq].ts;
    }

    rtc {
        enabled     on;
        rtmp_to_rtc on;
        rtc_to_rtmp on;
    }

    http_remux {
        enabled on;
        mount [vhost]/[app]/[stream].flv;
    }
}

重现(Replay)

重现Bug的步骤(How to replay bug?)

  1. 目前看日志,没看出来异常,但是不清楚在什么情况下,start会变成0,触发死机问题

期望行为(Expect)

期望即使遇到start为0的情况,srs也能规避到这个异常的bug。

@winlinvip winlinvip added Bug WebRTC labels Dec 29, 2021
@winlinvip winlinvip added this to the 4.0 milestone Dec 29, 2021
@winlinvip winlinvip added the good first issue label Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug good first issue WebRTC
Projects
None yet
Development

No branches or pull requests

3 participants