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

ERROR: LeakSanitizer: detected memory leaks #3532

Closed fonoisrev closed 1 year ago

fonoisrev commented 1 year ago

Note: Please read FAQ before file an issue, see #2716

Description

Please description your issue here

  1. SRS Version: v6.0.10 or v6.0.36

  2. Linux 5.4.0-77 ubuntu x86_64

  3. SRS Log:

[2023-05-05 18:50:47.710][INFO][123604][hke970rr] XCORE-SRS/6.0.10(Bee)
[2023-05-05 18:50:47.711][INFO][123604][hke970rr] config parse complete
[2023-05-05 18:50:47.711][INFO][123604][hke970rr] you can check log by: tail -n 30 -f /data/log/srs_v6/srs_v6_01.log
[2023-05-05 18:50:47.711][INFO][123604][hke970rr] please check SRS by: ./etc/init.d/srs status

=================================================================
==123604==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f96ef0cc587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x56439dad36cb in discover_network_iface(ifaddrs*, std::vector<SrsIPAddress*, std::allocator<SrsIPAddress*> >&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, bool, bool) src/protocol/srs_protocol_utility.cpp:697
    #2 0x56439dad439b in retrieve_local_ips() src/protocol/srs_protocol_utility.cpp:754
    #3 0x56439dad4e65 in srs_get_local_ips() src/protocol/srs_protocol_utility.cpp:811
    #4 0x56439dc5ae4c in SrsConfig::check_normal_config() src/app/srs_app_config.cpp:2424
    #5 0x56439dc5804d in SrsConfig::check_config() src/app/srs_app_config.cpp:2250
    #6 0x56439df92a04 in do_main(int, char**, char**) src/main/srs_main_server.cpp:217
    #7 0x56439df92d86 in main src/main/srs_main_server.cpp:249
    #8 0x7f96eea6e082 in __libc_start_main ../csu/libc-start.c:308

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f96ef0cc587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x56439dad36cb in discover_network_iface(ifaddrs*, std::vector<SrsIPAddress*, std::allocator<SrsIPAddress*> >&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >&, bool, bool) src/protocol/srs_protocol_utility.cpp:697
    #2 0x56439dad469d in retrieve_local_ips() src/protocol/srs_protocol_utility.cpp:775
    #3 0x56439dad4e65 in srs_get_local_ips() src/protocol/srs_protocol_utility.cpp:811
    #4 0x56439dc5ae4c in SrsConfig::check_normal_config() src/app/srs_app_config.cpp:2424
    #5 0x56439dc5804d in SrsConfig::check_config() src/app/srs_app_config.cpp:2250
    #6 0x56439df92a04 in do_main(int, char**, char**) src/main/srs_main_server.cpp:217
    #7 0x56439df92d86 in main src/main/srs_main_server.cpp:249
    #8 0x7f96eea6e082 in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 32 byte(s) in 1 object(s) allocated from:
    #0 0x7f96ef0cc587 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cc:104
    #1 0x7f96eeeeb29e in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/lib/x86_64-linux-gnu/libstdc++.so.6+0x14329e)

SUMMARY: AddressSanitizer: 176 byte(s) leaked in 3 allocation(s).
  1. SRS Config:
# @see https://ossrs.net/lts/zh-cn/docs/v4/doc/sample-hls
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
daemon              on;
pid                 /home/toc/SDE/directRecordSrs_H265/srs_v6_01/srs.pid;
srs_log_tank        file;
srs_log_file        /data/log/srs_v6/srs_v6_01.log;

vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_fragment    10;
        hls_window      200;
        hls_cleanp      off;
        hls_path        /data/hls/direct_record/srs_v6_01;
        hls_m3u8_file   [app]/[stream].m3u8;
        hls_ts_file     [app]/[2006]-[01]-[02]-[15]/[02]-[15]-[04]-[05]-[stream]-[seq].ts;
    }
}

Replay

Please describe how to replay the bug?

Step 1: Compile SRS version with H265.

./configure --h265=on && make

Step 2: Copy the default configuration file and modify it according to the above description.

cp conf/hls.conf conf/hls2.conf

Step 3: Start SRS and encounter an error.

./objs/srs -c conf/hls2.conf

Expect

Normal startup.

TRANS_BY_GPT3

chen-guanghua commented 1 year ago

fixed by https://github.com/ossrs/srs/pull/3541

From the current analysis, it appears that the failure to start is caused by using hls2.conf. The hls2.conf log will be outputted to the log file, and the provided log is the console log.

It is necessary to check the reason for the failure in the /data/log/srs_v6/srs_v6_01.log log file.

In summary, the unsuccessful startup caused the console to output logs about memory leaks. This issue has been fixed, and in subsequent unsuccessful startups, the leaked memory will also be released.

TRANS_BY_GPT3