Edward-Wu / srt-live-server

srt live server for low latency
Other
644 stars 192 forks source link

SEGV if sls is executed with trace option #116

Open robertsong2019 opened 2 years ago

robertsong2019 commented 2 years ago

hello,

SEGV occurs if sls is executed with trace option.

./sls -c ../sls.conf  -l trace
2022-03-15 11:02:54:810 SLS TRACE: line:21='        idle_streams_timeout 10;#s -1: unlimited'
2022-03-15 11:02:54:810 SLS TRACE: line:21, set name='idle_streams_timeout', value='10'.
Segmentation fault

use gdb to trace

(gdb) bt
#0  0x00007ffff6fc5cc0 in _IO_vfprintf_internal (s=0x7ffff733c620 <_IO_2_1_stdout_>,
    format=<optimized out>, ap=ap@entry=0x7fffffffaa48) at vfprintf.c:1632
#1  0x00007ffff6fcc899 in __printf (format=<optimized out>) at printf.c:33
#2  0x0000000000405795 in CSLSLog::print_log (this=0x667890, level=5,
    fmt=0x43433f "line:%d='%s'", vl=0x7fffffffcbd0) at slscore/SLSLog.cpp:88
#3  0x00000000004055cb in CSLSLog::log (level=5, fmt=0x43433f "line:%d='%s'")
    at slscore/SLSLog.cpp:70
#4  0x0000000000408dc9 in sls_conf_parse_block (ifs=..., line=@0x7fffffffd54c: 22,
    b=0x67d5d0, child=@0x7fffffffd54b: true,
    p_runtime=0x651520 <sls_conf_server_t::runtime_conf>, brackets_layers=2)
    at slscore/conf.cpp:218
#5  0x0000000000409762 in sls_conf_parse_block (ifs=..., line=@0x7fffffffd54c: 22,
    b=0x67d5d0, child=@0x7fffffffd54b: true,
    p_runtime=0x651520 <sls_conf_server_t::runtime_conf>, brackets_layers=2)
    at slscore/conf.cpp:301
#6  0x0000000000409762 in sls_conf_parse_block (ifs=..., line=@0x7fffffffd54c: 22,
    b=0x67c240, child=@0x7fffffffd54b: true,
    p_runtime=0x6514e0 <sls_conf_srt_t::runtime_conf>, brackets_layers=1)
    at slscore/conf.cpp:301
#7  0x0000000000409bfd in sls_conf_open (conf_file=0x7fffffffd970 "../sls.conf")
    at slscore/conf.cpp:346
#8  0x00000000004042de in main (argc=5, argv=0x7fffffffe078) at srt-live-server.cpp:138
(gdb)
(gdb) p buf_info
$1 = "2022-03-15 11:03:21:953 SLS TRACE: line:22='        #on_event_url http://192.168.31.106:8000/sls/on_event; #?method=on_connect|on_close&role_name=&srt_url=%s'\n", '\000' <repeats 3936 times>

while parsing line in sls.conf , the line result in the crash.

on_event_url http://192.168.31.106:8000/sls/on_event; #?method=on_connect|on_close&role_name=&srt_url=%s

Here is the patch to fix it, please check it.

diff --git a/sls.conf b/sls.conf
index e9799bb..9cfc53b 100644
--- a/sls.conf
+++ b/sls.conf
@@ -19,7 +19,7 @@ srt {                #SRT
         domain_publisher uplive.sls.com;
         backlog 100; #accept connections at the same time
         idle_streams_timeout 10;#s -1: unlimited
-        #on_event_url http://192.168.31.106:8000/sls/on_event; #?method=on_connect|on_close&role_name=&srt_url=%s
+        #on_event_url http://192.168.31.106:8000/sls/on_event; #?method=on_connect|on_close&role_name=&srt_url=
         app {
             app_player live ;
             app_publisher live ;

Best Regards