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.75k stars 5.28k forks source link

Publish crash when `dvr` `forward` enabled and `dvr_path` file exists #3901

Closed ysc3839 closed 5 months ago

ysc3839 commented 7 months ago

Describe the bug When dvr forward enabled in a vhost, and the file specified by dvr_path exists, publish to this vhost cause SRS crash.

Version v6.0-d3

To Reproduce Steps to reproduce the behavior:

  1. Use config file below.
  2. Execute command:
    touch stream1.flv
    ./srs -c srs.conf
  3. Publish stream to rtmp://127.0.0.1:8800/app/stream1: ffmpeg -f lavfi -i testsrc -c:v h264 -f flv 'rtmp://127.0.0.1:8800/app/stream1'
  4. SRS crash.

Expected behavior No crash.

Screenshots N/A

Additional context config file:

listen 8800;
pid ./srs.pid;
srs_log_tank file;
srs_log_level_v2 trace;
srs_log_file ./srs.log;
daemon off;

vhost __defaultVhost__ {
    dvr {
        enabled on;
        dvr_path ./[stream].flv;
    }
    forward 127.0.0.1:60000;
}

gdb backtrace:

#0  0x0000000000792c8b in SrsForwarder::on_unpublish (this=0x7f6aac040af0) at ./src/app/srs_app_forward.cpp:97
#1  0x000000000077e5a4 in SrsOriginHub::destroy_forwarders (this=0x7f6aac04d600) at ./src/app/srs_app_source.cpp:1559
#2  0x000000000077c875 in SrsOriginHub::on_unpublish (this=0x7f6aac04d600) at ./src/app/srs_app_source.cpp:1162
#3  0x00000000007835e2 in SrsLiveSource::on_unpublish (this=0x7f6aac04da60) at ./src/app/srs_app_source.cpp:2629
#4  0x00000000007752c9 in SrsRtmpConn::release_publish (this=0x7f6aac042f90, source=0x7f6aac04da60)
    at ./src/app/srs_app_rtmp_conn.cpp:1146
#5  0x0000000000773ae9 in SrsRtmpConn::publishing (this=0x7f6aac042f90, source=0x7f6aac04da60)
    at ./src/app/srs_app_rtmp_conn.cpp:964
#6  0x0000000000770bce in SrsRtmpConn::stream_service_cycle (this=0x7f6aac042f90)
    at ./src/app/srs_app_rtmp_conn.cpp:630
#7  0x000000000076f383 in SrsRtmpConn::service_cycle (this=0x7f6aac042f90) at ./src/app/srs_app_rtmp_conn.cpp:446
#8  0x000000000076e254 in SrsRtmpConn::do_cycle (this=0x7f6aac042f90) at ./src/app/srs_app_rtmp_conn.cpp:262
#9  0x0000000000777620 in SrsRtmpConn::cycle (this=0x7f6aac042f90) at ./src/app/srs_app_rtmp_conn.cpp:1604
#10 0x000000000079f739 in SrsFastCoroutine::cycle (this=0x7f6aac043190) at ./src/app/srs_app_st.cpp:285
#11 0x000000000079f7bc in SrsFastCoroutine::pfn (arg=0x7f6aac043190) at ./src/app/srs_app_st.cpp:300
#12 0x000000000090c8af in _st_thread_main () at sched.c:380
#13 0x000000000090d19e in st_thread_create (start=0x7f6ab4008e58, arg=0xb28b3700, joinable=32618, stk_size=-1408971248)
    at sched.c:666
#14 0x0000000000742ab6 in srs_context_set_cid_of (trd=0x7f6ab4008e58, v=...) at ./src/protocol/srs_protocol_log.cpp:91
#15 0x000000000067f75f in _SrsContextId::~_SrsContextId (this=0x7f6ab4008b78, __in_chrg=<optimized out>)
    at ./src/core/srs_core.cpp:24
#16 0x00007f6ab36ebe23 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() ()
   from /lib64/libstdc++.so.6
#17 0x000000000076159a in SrsServer::do_on_tcp_client (this=0x38b7, listener=0x2, stfd=@0x7f6ab4008bd0: 0x7f6ab28b34f0)
    at ./src/app/srs_app_server.cpp:1239
Backtrace stopped: frame did not save the PC
winlinvip commented 6 months ago

This issue appears to be consistently reproducible. You are welcome to submit a patch.

TRANS_BY_GPT4