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

SrsSource destructor coredump #986

Closed fantasyARM closed 4 years ago

fantasyARM commented 7 years ago

srs_kernel_codec.cpp LINE:567 Passing acodec to the audio object internally, causing double free. Remove the free on line 420 of srs_kernel_codec.cpp. This object is passed in from the outside and its lifecycle is managed by the outside, so it should not be freed in the destructor of SrsFrame. [bug]

TRANS_BY_GPT3

ynchsung commented 7 years ago

Previously, when cleaning up SrsSource, it is possible that a premature free occurred, but other coroutines continued to use that memory, causing the process to crash. (https://github.com/ossrs/srs/issues/713) Would using std::shared_ptr for these pointers solve the problem? When using this type of pointer, there is no need to free the memory manually. When there are no pointers pointing to that memory, the library will automatically free it. This can solve the issue of double free or premature free.

TRANS_BY_GPT3

winlinvip commented 6 years ago

SRS2 or SRS3?

winlinvip commented 4 years ago

Dup to #413

Workaround: https://github.com/ossrs/srs/issues/1579#issuecomment-736232139