ossrs / srs

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

`rtmp推流断开SrsRtcFromRtmpBridger::on_unpublish异常crash` translates to: `RTMP push stream disconnected. SrsRtcFromRtmpBridger::on_unpublish exception crash.` #2142

Closed ghostsf closed 3 years ago

ghostsf commented 3 years ago

Description'

Please ensure that you maintain the markdown structure.

Please describe the issue you encountered here. ' Make sure to maintain the markdown structure.

rtmp push stream disconnected, SrsRtcFromRtmpBridger::on_unpublish exception.

  1. SRS version: 4.0 release
  2. SRS log is as follows:
    Program terminated with signal 11, Segmentation fault.
    #0  0x000000000062823f in SrsRtcFromRtmpBridger::on_unpublish (this=0x1ac07e0) at src/app/srs_app_rtc_source.cpp:672
    672         meta->update_previous_vsh();
    Missing separate debuginfos, use: debuginfo-install glibc-2.17-307.el7.1.x86_64 libgcc-4.8.5-39.el7.x86_64 libstdc++-4.8.5-39.el7.x86_64
    (gdb) where
    #0  0x000000000062823f in SrsRtcFromRtmpBridger::on_unpublish (this=0x1ac07e0) at src/app/srs_app_rtc_source.cpp:672
    #1  0x0000000000504128 in SrsSource::on_unpublish (this=0x1abefb0) at src/app/srs_app_source.cpp:2571
    #2  0x00000000004f57ae in SrsRtmpConn::release_publish (this=0x1cbb9c0, source=0x1abefb0) at src/app/srs_app_rtmp_conn.cpp:984
    #3  0x00000000004f4a05 in SrsRtmpConn::publishing (this=0x1cbb9c0, source=0x1abefb0) at src/app/srs_app_rtmp_conn.cpp:865
    #4  0x00000000004f20c1 in SrsRtmpConn::stream_service_cycle (this=0x1cbb9c0) at src/app/srs_app_rtmp_conn.cpp:565
    #5  0x00000000004f0f5c in SrsRtmpConn::service_cycle (this=0x1cbb9c0) at src/app/srs_app_rtmp_conn.cpp:419
    #6  0x00000000004efbaf in SrsRtmpConn::do_cycle (this=0x1cbb9c0) at src/app/srs_app_rtmp_conn.cpp:232
    #7  0x00000000004f7cac in SrsRtmpConn::cycle (this=0x1cbb9c0) at src/app/srs_app_rtmp_conn.cpp:1445
    #8  0x0000000000524015 in SrsSTCoroutine::cycle (this=0x1cf2790) at src/app/srs_app_st.cpp:226
    #9  0x00000000005240a3 in SrsSTCoroutine::pfn (arg=0x1cf2790) at src/app/srs_app_st.cpp:241
    #10 0x000000000063e00b in _st_thread_main () at sched.c:337
    #11 0x000000000063e77b in st_thread_create (start=0x63d809 <st_poll+328>, arg=0x1a3e860, joinable=0, stk_size=33689104) at sched.c:616
    Backtrace stopped: previous frame inner to this frame (corrupt stack?)
  3. SRS configuration is as follows:
    
    rtc_server on


`TRANS_BY_GPT3`
ghostsf commented 3 years ago

4.0.56 is good, 4.0.59 has issues

TRANS_BY_GPT3

ghostsf commented 3 years ago

Found a problem. Winlin 2021/1/7, 11:45 AM RTC: Fix memory leak. commit 2492b726af2a0f60ff1bc7a951cf5679243861f0

TRANS_BY_GPT3

iceylm commented 3 years ago

I have also encountered it.

Program received signal SIGSEGV, Segmentation fault. 0x0000000000635f47 in SrsRtcFromRtmpBridger::on_unpublish (this=0xf7d440) at src/app/srs_app_rtc_source.cpp:672 672 meta->update_previous_vsh(); (gdb) bt

0 0x0000000000635f47 in SrsRtcFromRtmpBridger::on_unpublish (this=0xf7d440) at src/app/srs_app_rtc_source.cpp:672

1 0x000000000051183e in SrsSource::on_unpublish (this=0xf97c20) at src/app/srs_app_source.cpp:2571

2 0x0000000000502ec4 in SrsRtmpConn::release_publish (this=0xf60e70, source=0xf97c20) at src/app/srs_app_rtmp_conn.cpp:984

3 0x000000000050211b in SrsRtmpConn::publishing (this=0xf60e70, source=0xf97c20) at src/app/srs_app_rtmp_conn.cpp:865

4 0x00000000004ff7d7 in SrsRtmpConn::stream_service_cycle (this=0xf60e70) at src/app/srs_app_rtmp_conn.cpp:565

5 0x00000000004fe672 in SrsRtmpConn::service_cycle (this=0xf60e70) at src/app/srs_app_rtmp_conn.cpp:419

6 0x00000000004fd2c5 in SrsRtmpConn::do_cycle (this=0xf60e70) at src/app/srs_app_rtmp_conn.cpp:232

7 0x00000000005053c2 in SrsRtmpConn::cycle (this=0xf60e70) at src/app/srs_app_rtmp_conn.cpp:1445

8 0x000000000053172b in SrsSTCoroutine::cycle (this=0xf60d00) at src/app/srs_app_st.cpp:226

9 0x00000000005317b9 in SrsSTCoroutine::pfn (arg=0xf60d00) at src/app/srs_app_st.cpp:241

10 0x000000000067c9c4 in _st_thread_main () at sched.c:337

11 0x000000000067d134 in st_thread_create (start=0x67c1c2 <st_poll+328>, arg=0xe9bae0, joinable=0, stk_size=16234752) at sched.c:616

Backtrace stopped: previous frame inner to this frame (corrupt stack?) (gdb) p meta $1 = (SrsMetaCache *) 0x0

meta is empty.

TRANS_BY_GPT3

zsinba commented 3 years ago

4.0.56 is good, 4.0.59 has issues

Indeed, it is true.

TRANS_BY_GPT3

zsinba commented 3 years ago

Discovered the problem winlin 2021/1/7, 11:45 AM RTC: Fix memory leak commit 2492b72

Discovered a problem, how to handle it?

TRANS_BY_GPT3

ghostsf commented 3 years ago

Found the problem winlin 2021/1/7, 11:45 AM RTC: Fix memory leak commit 2492b72

Found a problem, how to handle it?

Directly revert the commit.

Specific optimization is still needed. Temporarily handle it this way.

src/app/srs_app_rtc_source.cpp

// release unpublish stream description. // set_stream_desc(NULL); // srs_freep(bridger_);

TRANS_BY_GPT3

zsinba commented 3 years ago

Found the problem winlin 2021/1/7, 11:45 AM RTC: Fix memory leak commit 2492b72

Found the problem, how was it handled?

Revert the commit directly.

Specific optimization is still needed. Temporarily handle it like this.

src/app/srs_app_rtc_source.cpp

// release unpublish stream description. // set_stream_desc(NULL); // srs_freep(bridger_);

Commenting it out is possible.

What is the difference between commenting out this line and two lines? // set_stream_desc(NULL); // srsfreep(bridger);

TRANS_BY_GPT3

winlinvip commented 3 years ago

Still not possible, Bridger serves as a bridge between creating RTMP and RTC sources, and this bridge cannot be directly dismantled.

TRANS_BY_GPT3

winlinvip commented 3 years ago

I have revoked: https://github.com/ossrs/srs/commit/2492b72 and https://github.com/ossrs/srs/commit/06adb9d

I will see how to better release this bridger.

TRANS_BY_GPT3

zsinba commented 3 years ago

After handling it properly, can we perform WebRTC for upstream and FLV for downstream, right?

TRANS_BY_GPT3

winlinvip commented 3 years ago

After processing, can we do uplink with WebRTC and downlink with FLV?

This is just a bugfix to solve a memory leak issue, unrelated to functionality.

TRANS_BY_GPT3

winlinvip commented 3 years ago

Fixed.