ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.86k stars 5.29k forks source link

HLS: Coredump after running for a period of time #3789

Closed ztt19851213 closed 10 months ago

ztt19851213 commented 10 months ago

Please description your issue here

  1. SRS Version: 4.0.251

  2. SRS Log: Did not see any issues in the srs log, the call stack is as follows:

    
    GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-120.el7
    Copyright (C) 2013 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
    and "show warranty" for details.
    This GDB was configured as "x86_64-redhat-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /root/debug/srs...(no debugging symbols found)...done.
    [New LWP 4759]
    [Thread debugging using libthread_db enabled]
    Using host libthread_db library "/usr/lib64/libthread_db.so.1".
    Core was generated by `./objs/srs -c conf/srs.conf'.
    Program terminated with signal 6, Aborted.
    #0  0x00007f0efd701387 in raise () from /usr/lib64/libc.so.6
    Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.el7_9.x86_64 libgcc-4.8.5-44.el7.x86_64 libstdc++-4.8.5-44.el7.x86_64
    (gdb) bt
    #0  0x00007f0efd701387 in raise () from /usr/lib64/libc.so.6
    #1  0x00007f0efd702a78 in abort () from /usr/lib64/libc.so.6
    #2  0x00007f0efd6fa1a6 in __assert_fail_base () from /usr/lib64/libc.so.6
    #3  0x00007f0efd6fa252 in __assert_fail () from /usr/lib64/libc.so.6
    #4  0x0000000000501a1f in SrsHlsMuxer::is_segment_absolutely_overflow() ()
    #5  0x0000000000505300 in SrsHlsController::write_audio(SrsAudioFrame*, long) ()
    #6  0x0000000000506431 in SrsHls::on_audio(SrsSharedPtrMessage*, SrsFormat*) ()
    #7  0x00000000004ef6e0 in SrsOriginHub::on_audio(SrsSharedPtrMessage*) ()
    #8  0x00000000004f612b in SrsLiveSource::on_audio_imp(SrsSharedPtrMessage*) ()
    #9  0x00000000004f5dc7 in SrsLiveSource::on_audio(SrsCommonMessage*) ()
    #10 0x00000000004e9173 in SrsRtmpConn::process_publish_message(SrsLiveSource*, SrsCommonMessage*) ()
    #11 0x00000000004e901d in SrsRtmpConn::handle_publish_message(SrsLiveSource*, SrsCommonMessage*) ()
    #12 0x0000000000589b72 in SrsPublishRecvThread::consume(SrsCommonMessage*) ()
    #13 0x0000000000588cea in SrsRecvThread::do_cycle() ()
    #14 0x0000000000588b56 in SrsRecvThread::cycle() ()
    #15 0x0000000000517759 in SrsFastCoroutine::cycle() ()
    #16 0x00000000005177dc in SrsFastCoroutine::pfn(void*) ()
    #17 0x0000000000614252 in _st_thread_main ()
    #18 0x0000000000614ac5 in st_thread_create ()

Backtrace stopped: previous frame inner to this frame (corrupt stack?) (gdb) frame 4

4 0x0000000000501a1f in SrsHlsMuxer::is_segment_absolutely_overflow() ()

(gdb)?p current Undefined command: "". Try "help". (gdb) p current $1 = 0

The corresponding code exception part is as follows:

bool SrsHlsMuxer::is_segment_absolutely_overflow() { // @see https://github.com/ossrs/srs/issues/151#issuecomment-83553950 srs_assert(current);

// to prevent very small segment.
if (current->duration() < 2 * SRS_HLS_SEGMENT_MIN_DURATION) {
    return false;
}

// use N% deviation, to smoother.
srs_utime_t deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0;
return current->duration() >= hls_aof_ratio * hls_fragment + deviation;

}

current' is 0, causing an exception, but I don't understand why the exception occurs.

3. SRS Config:

main config for srs.

@see full.conf for detail config.

listen 1935; max_connections ; srs_log_tank file; srs_log_level info; srs_log_file /var/log/cloudland/srs.log; query_latest_version off; http_api { enabled on; listen 1985; raw_api { enabled on; allow_reload on; allow_query on; allow_update on; } } http_server { enabled on; listen 9080; dir ./objs/nginx/html; } stats { network 0; disk sda sdb xvda xvdb; } vhost defaultVhost { tcp_nodelay on; min_latency on; http_remux { enabled on; mount [vhost]/raw/[app]/[stream].flv; } hls { enabled on; hls_path ./objs/nginx/html/raw; hls_fragment 3; hls_window 15; hls_dispose 15; hls_wait_keyframe on; hls_m3u8_file [app]/[stream].m3u8; hls_ts_file [app]/[stream]-[seq].ts; hls_cleanup off; } publish { mr off; } play { mw_latency 100; gop_cache on; queue_length 10; } http_hooks { enabled on; on_publish http://127.0.0.1:3002/api/rest/v1/live/stream/publish; on_unpublish http://127.0.0.1:3002/api/rest/v1/live/stream/unpublish; on_play http://127.0.0.1:3002/api/rest/v1/live/stream/play; on_stop http://127.0.0.1:3002/api/rest/v1/live/stream/stop; onhls http://127.0.0.1:3002/api/rest/v1/live/stream/hls; } transcode live { enabled on; ffmpeg /usr/cloudland/srs/ffmpeg/bin/ffmpeg; engine sd { enabled on; vcodec libx264; vbitrate 512; vfps 25; vwidth 640; vheight 360; vthreads 4; vprofile high; vpreset veryfast; acodec copy; output rtmp://127.0.0.1:[port]/live?vhost=localvhost/[stream][engine]; } engine hd { enabled on; vcodec libx264; vbitrate 1024; vfps 25; vwidth 1280; vheight 720; vthreads 4; vprofile high; vpreset veryfast; acodec copy; output rtmp://127.0.0.1:[port]/live?vhost=localvhost/[stream]_[engine]; } } } vhost localvhost { tcp_nodelay on; min_latency on; http_remux { enabled on; mount [vhost]/transcode/[app]/[stream].flv; } hls { enabled on; hls_path ./objs/nginx/html/transcode; hls_fragment 3; hls_window 15; hls_dispose 15; hls_wait_keyframe on; hls_m3u8_file [app]/[stream].m3u8; hls_ts_file [app]/[stream]-[seq].ts; hls_cleanup off; } publish { mr off; } play { mw_latency 100; gop_cache on; queue_length 10; } http_hooks { enabled on; on_play http://127.0.0.1:3002/api/rest/v1/live/stream/play; on_stop http://127.0.0.1:3002/api/rest/v1/live/stream/stop; on_hls http://127.0.0.1:3002/api/rest/v1/live/stream/hls; } }


`TRANS_BY_GPT4`
winlinvip commented 10 months ago

Duplicated to #3773 and fixed in SRS 5. Please upgrade to SRS 5.0.

ztt19851213 commented 10 months ago

I have looked at the 3773 issue, the phenomenon is the same, but when I look at the srs log and my code, the publish stream has been going on for several minutes, and there has been no reload srs operation, the log shows everything is normal, yet it just crashed.

TRANS_BY_GPT4