Skip to content

Source Cleanup: When there is a large amount of streaming, Source leakage causes OOM (Out of Memory). #1509

Closed
@2k9laojia

Description

@2k9laojia

Description
Describe the problem you encountered.
When pushing the stream to SRS, the SRS process crashed.

Environment

  1. Operating System: CentOS
  2. Encoder (Tool and Version): ...
  3. Player (Tool and Version): ...
  4. SRS Version: 2.0.248
  5. SRS log is as follows:
    client identified, type=fmle-publish, stream_name=62c1352ea3a64621999bfd946081f392, duration=-1.00
    connected stream, tcUrl=rtmp://172.16.129.97/netposa, pageUrl=, swfUrl=, schema=rtmp, vhost=defaultVhost, port=1935, app=netposa, stream=62c1352ea3a64621999bfd946081f392, args=null
    st_thread_create failed. ret=1017(Cannot allocate memory)

Reproduction
The steps to reproduce the bug are as follows:

  1. Start SRS, run ...
  2. Push the stream, run ...
  3. The bug is reproduced, and the key information is as follows:
...

Expected Behavior
Describe what you expect to happen.

By examining the stack analysis, the reasons are as follows:
During the push stream process, the function SrsSource::initialize is called, which then calls hls->initialize. However, an error occurs in hls->initialize, specifically st_thread_create failed, resulting in an error code being returned. In the function SrsSource::fetch_or_create, srs_freep(source) is called, leading to the destructor of SrsSource being invoked. As a result, the member variable play_edge is released, triggering its destructor and subsequently calling the destructor of the SrsPlayEdge member variable ingester. The stop function is called, ultimately invoking _source->on_unpublish(). Since the call to hls->initialize failed and returned without calling play_edge->initialize(this, _req), the _source pointer in SrsEdgeIngester is null, causing a core dump. Therefore, adding a null check before using _source can resolve the issue.

I hope someone knowledgeable can help answer why st_thread_create failed and why it resulted in a failure.

TRANS_BY_GPT3

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions