ossrs / srs

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

Running on a 32-bit ARM platform generates a segmentation fault because of a log #3714

Closed terrencetang2023 closed 1 year ago

terrencetang2023 commented 1 year ago

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

Description

Running on a 32-bit ARM platform generates a segmentation fault because of a log

  1. SRS Version: v6.0-d0

  2. SRS Log:

# gdb ./objs/srs
warning: Found custom handler for signal 4 (Illegal instruction) preinstalled.
warning: Found custom handler for signal 36 (RT36) preinstalled.
warning: Found custom handler for signal 37 (RT37) preinstalled.
warning: Found custom handler for signal 44 (RT44) preinstalled.
Some signal dispositions inherited from the environment (SIG_DFL/SIG_IGN)
won't be propagated to spawned programs.
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./objs/srs...
(gdb)
(gdb) r -c conf/srs.conf
Starting program: /data/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk/objs/srs -c conf/srs.conf
[2017-08-07 22:52:40.816][INFO][2426][052fh262] XCORE-SRS/6.0.59(Bee)
[2017-08-07 22:52:40.816][INFO][2426][052fh262] config parse complete
[2017-08-07 22:52:40.816][INFO][2426][052fh262] write log to console
[2017-08-07 22:52:40.816][INFO][2426][052fh262] SRS/6.0.59(Bee), MIT
[2017-08-07 22:52:40.816][INFO][2426][052fh262] authors: Winlin<winlin@vip.126.com> ZhaoWenjie<zhaowenjie@tal.com> ShiWei<shiwei05@kuaishou.com> XiaoZhihong<hondaxiao@tencent.com> WuPengqiang<pengqiang.wpq@alibaba-inc.com> XiaLixin<xialixin@kanzhun.com> LiPeng<mozhan.lp@alibaba-inc.com> ChenGuanghua<jinxue.cgh@alibaba-inc.com> ChenHaibo<nmgchenhaibo@foxmail.com> ZhangJunqin<chundonglinlin@126.com> and https://github.com/ossrs/srs/blob/develop/trunk/AUTHORS.md#contributors
[2017-08-07 22:52:40.817][INFO][2426][052fh262] cwd=/data/lycium_back/main/srs/srs-server-6.0-d0-armeabi-v7a-build/trunk, work_dir=./, build: 2023-07-26 16:33:27, configure: --prefix=/home/tangshaoteng/codes/gitee_priv/lycium_back/usr/srs/armeabi-v7a --cross-build --cc=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang --cxx=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang++ --ar=/data/local/ohos-sdk/linux/native/llvm/bin/llvm-ar --ld=/data/local/ohos-sdk/linux/native/llvm/bin/ld.lld --randlib=/data/local/ohos-sdk/linux/native/llvm/bin/llvm-ranlib --backtrace=off, uname: Linux issuser-ThinkCentre-M920t-N000 5.15.0-76-generic #83~20.04.1-Ubuntu SMP Wed Jun 21 20:23:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux, osx: 0, env: 0, pkg:
[2017-08-07 22:52:40.817][INFO][2426][052fh262] configure detail: --prefix=/home/tangshaoteng/codes/gitee_priv/lycium_back/usr/srs/armeabi-v7a --config=conf/srs.conf --osx=off --hls=on --hds=off --dvr=on --ssl=on --https=on --ssl-1-0=off --ssl-local=off --sys-ssl=off --transcode=on --ingest=on --stat=on --http-callback=on --http-server=on --stream-converter=on --http-api=on --utest=off --srt=on --rtc=on --h265=off --gb28181=off --simulator=off --cxx11=on --cxx14=off --backtrace=off --ffmpeg-fit=on --ffmpeg-opus=on --nasm=on --srtp-nasm=on --clean=on --gperf=off --gmc=off --gmd=off --gmp=off --gcp=off --gprof=off --static=off --shared-st=off --shared-srt=off --shared-ffmpeg=off --log-verbose=off --log-info=off --log-trace=on --log-level_v2=on --gcov=off --apm=off --debug=off --debug-stats=off --cross-build=on --sanitizer=off --sanitizer-static=off --sanitizer-log=off --cygwin64=off --single-thread=off --generic-linux=off --arch=arm --host=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang --cross-prefix=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang- --cc=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang --cxx=/data/local/ohos-sdk/linux/native/llvm/bin/arm-linux-ohos-clang++ --ar=/data/local/ohos-sdk/linux/native/llvm/bin/llvm-ar --ld=/data/local/ohos-sdk/linux/native/llvm/bin/ld.lld --randlib=/data/local/ohos-sdk/linux/native/llvm/bin/llvm-ranlib
[2017-08-07 22:52:40.817][INFO][2426][052fh262] srs checking config...
[2017-08-07 22:52:40.831][INFO][2426][052fh262] ips, iface[0] lo ipv4 0x10049 127.0.0.1
[2017-08-07 22:52:40.831][INFO][2426][052fh262] devices, intranet lo 127.0.0.1
[2017-08-07 22:52:40.831][WARN][2426][052fh262][2] stats network use index=0, ip=127.0.0.1, ifname=lo
[2017-08-07 22:52:40.831][WARN][2426][052fh262][2] stats disk not configed, disk iops disabled.
[2017-08-07 22:52:40.831][INFO][2426][052fh262] write log to console
[2017-08-07 22:52:40.831][INFO][2426][052fh262] features, rch:on, dash:on, hls:on, hds:off, srt:on, hc:on, ha:on, hs:on, hp:on, dvr:on, trans:on, inge:on, stat:on, sc:on
[2017-08-07 22:52:40.832][INFO][2426][052fh262] SRS on arm(crossbuild), conf:conf/srs.conf, limit:1000, writev:1024, encoding:little-endian, HZ:100
[2017-08-07 22:52:40.832][INFO][2426][052fh262] mw sleep:350ms. mr enabled:on, default:0, sleep:350ms
[2017-08-07 22:52:40.832][INFO][2426][052fh262] gc:on, pq:30000ms, cscc:[0,16), csa:on, tn:on(may hurts performance), ss:auto(guess by merged write)
[2017-08-07 22:52:40.832][INFO][2426][052fh262] system default latency(ms): mw(0-350) + mr(0-350) + play-queue(0-30000)
[2017-08-07 22:52:40.832][WARN][2426][052fh262][2] SRS/6.0.59 is not stable
[2017-08-07 22:52:40.832][INFO][2426][052fh262] write pid=2426 to ./objs/srs.pid success!
[2017-08-07 22:52:40.832][INFO][2426][052fh262] Thread #1(primordial): init name=srs-master-1, interval=5000ms
[New LWP 2428]
[2017-08-07 22:52:40.833][INFO][2426][052fh262] Pool: Start threads primordial=1, hybrids=1 ok
[2017-08-07 22:52:40.833][INFO][2426][07lq9045] Thread #2: run with tid=2428, entry=0xf7eb1a90, label=hybrid, name=srs-hybrid-2
[2017-08-07 22:52:40.855][INFO][2426][07lq9045] fingerprint=FD:92:C8:4F:FC:EA:04:D8:FF:8B:EA:DD:12:8C:E0:8C:BD:EB:59:A3:1E:A8:4A:70:A7:17:27:20:9B:15:63:9A
[2017-08-07 22:52:40.855][INFO][2426][07lq9045] CircuitBreaker: enabled=1, high=2x90, critical=1x95, dying=5x99
[2017-08-07 22:52:40.855][INFO][2426][07lq9045] http flv live stream, vhost=__defaultVhost__, mount=[vhost]/[app]/[stream].flv
[2017-08-07 22:52:40.855][INFO][2426][07lq9045] http: root mount to ./objs/nginx/html
[2017-08-07 22:52:40.855][INFO][2426][07lq9045] server main cid=07lq9045, pid=2426, ppid=2401, asprocess=0
[2017-08-07 22:52:40.873][INFO][2426][07lq9045] RTMP listen at tcp://0.0.0.0:1935, fd=11
[2017-08-07 22:52:40.873][INFO][2426][07lq9045] HTTP-API listen at tcp://0.0.0.0:1985, fd=15
[2017-08-07 22:52:40.874][INFO][2426][07lq9045] HTTP-Server listen at tcp://0.0.0.0:8080, fd=16
[2017-08-07 22:52:40.874][INFO][2426][07lq9045] signal installed, reload=1, reopen=10, fast_quit=15, grace_quit=3
[2017-08-07 22:52:40.875][INFO][2426][07lq9045] http: api mount /console to ./objs/nginx/html/console
[2017-08-07 22:52:40.876][INFO][2426][07lq9045] rtc listen at udp://0.0.0.0:8000, fd=17
[2017-08-07 22:52:40.877][INFO][2426][9bbg1059] Hybrid cpu=0.00%,18MB
[2017-08-07 22:52:40.877][WARN][2426][n69kg36c][2] use first address as ip: 127.0.0.1, ifname=lo
[2017-08-07 22:52:40.877][INFO][2426][n69kg36c] Startup query id=vid-1anvu81, session=vid-7399d84, eip=127.0.0.1, wait=300s
[2017-08-07 22:52:40.877][INFO][2426][8899ppn0] TCP: connection manager run, conns=0
[2017-08-07 22:52:40.879][INFO][2426][u95c8s4y] SRT: connection manager run, conns=0
[2017-08-07 22:52:40.879][INFO][2426][59oz6242] UDP #17 LISTEN at 0.0.0.0:8000, SO_SNDBUF(default=212992, expect=10485760, actual=524288, r0=0), SO_RCVBUF(default=212992, expect=10485760, actual=524288, r0=0)
[2017-08-07 22:52:40.879][INFO][2426][53hz1095] RTC: connection manager run, conns=0
[2017-08-07 22:52:45.834][INFO][2426][] Hybrid cpu=3.00%,18MB
[2017-08-07 22:52:45.839][INFO][2426][] Process: cpu=3.00%,18MB, threads=2
[2017-08-07 22:52:48.540][INFO][2426][0bf36422] RTMP client ip=192.168.3.5:43952, fd=19
[2017-08-07 22:52:48.556][INFO][2426][] complex handshake success
[2017-08-07 22:52:48.599][INFO][2426][] connect app, tcUrl=rtmp://192.168.3.5:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=192.168.3.5, port=1935, app=live, args=null
[2017-08-07 22:52:48.600][INFO][2426][] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=128, out.chunk=128
[2017-08-07 22:52:48.686][INFO][2426][] client identified, type=fmle-publish, vhost=192.168.3.5, app=live, stream=livestream, param=, duration=0ms
[2017-08-07 22:52:48.686][INFO][2426][] connected stream, tcUrl=rtmp://192.168.3.5:1935/live, pageUrl=, swfUrl=, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=livestream, param=, args=null
[2017-08-07 22:52:48.687][INFO][2426][] new live source, stream_url=/live/livestream
[2017-08-07 22:52:48.688][INFO][2426][] source url=/live/livestream, ip=192.168.3.5, cache=1/2500, is_edge=0, source_id=/
[2017-08-07 22:52:48.773][INFO][2426][] new rtc source, stream_url=/live/livestream
[2017-08-07 22:52:48.778][INFO][2426][] hls: win=60000ms, frag=10000ms, prefix=, path=./objs/nginx/html, m3u8=[app]/[stream].m3u8, ts=[app]/[stream]-[seq].ts, aof=2.00, floor=0, clean=1, waitk=1, dispose=0ms, dts_directly=1
[2017-08-07 22:52:48.779][INFO][2426][] ignore disabled exec for vhost=__defaultVhost__
[2017-08-07 22:52:48.780][INFO][2426][] http: mount flv stream for sid=/live/livestream, mount=/live/livestream.flv
[2017-08-07 22:52:48.781][INFO][2426][] start publish mr=0/350, p1stpt=20000, pnt=5000, tcp_nodelay=0
[2017-08-07 22:52:48.861][INFO][2426][] got metadata, width=768, height=320, vcodec=7, acodec=10
[2017-08-07 22:52:48.862][INFO][2426][] 46B video sh, codec(7, profile=High, level=3.2, 768x320, 0kbps, 0.0fps, 0.0s)
[2017-08-07 22:52:48.863][INFO][2426][] 4B audio sh, codec(10, profile=LC, 2channels, 0kbps, 44100HZ), flv(16bits, 2channels, 44100HZ)
[2017-08-07 22:52:50.835][INFO][2426][] Hybrid cpu=11.95%,18MB
[2017-08-07 22:52:50.845][INFO][2426][] Process: cpu=9.05%,18MB, threads=2
[2017-08-07 22:52:55.849][INFO][2426][] Hybrid cpu=15.92%,18MB, cid=2,1, timer=61,0,0, clock=1,34,13,1,1,0,1,0,0, objs=(pkt:0,raw:0,fua:0,msg:97,oth:0,buf:0)
[2017-08-07 22:52:55.851][INFO][2426][] Process: cpu=15.92%,18MB, threads=2

Thread 2 "srs-hybrid-2" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 2428]
0xf7fc431e in memchr () from /lib/ld-musl-arm.so.1
(gdb)
(gdb) bt
#0  0xf7fc431e in memchr () from /lib/ld-musl-arm.so.1
#1  0xf7fb3f80 in strnlen () from /lib/ld-musl-arm.so.1
#2  0xf7fab1a4 in printf_core () from /lib/ld-musl-arm.so.1
#3  0xf7faa904 in vfprintf () from /lib/ld-musl-arm.so.1
#4  0xf7fb0160 in vsnprintf () from /lib/ld-musl-arm.so.1
#5  0x006631ac in SrsFileLog::log (this=0xf7e51080, level=SrsLogLevelTrace,
    tag=0x0, context_id=...,
    fmt=0x4c8e3b "-> HLS time=%dms, sno=%d, ts=%s, dur=%dms, dva=%dp",
    args=...) at ./src/app/srs_app_log.cpp:105
#6  0x0052a3f8 in srs_logger_impl (level=SrsLogLevelTrace, tag=0x0,
    context_id=...,
    fmt=0x4c8e3b "-> HLS time=%dms, sno=%d, ts=%s, dur=%dms, dva=%dp")
    at ./src/kernel/srs_kernel_log.cpp:54
#7  0x006542f8 in SrsHls::hls_show_mux_log (this=0xf7c85840)
    at ./src/app/srs_app_hls.cpp:1416
#8  0x00654134 in SrsHls::on_video (this=0xf7c85840, shared_video=0xf6e54a30,
    format=0xf7c85c50) at ./src/app/srs_app_hls.cpp:1400
#9  0x0063b4b4 in SrsOriginHub::on_video (this=0xf7c85800,
    shared_video=0xf6e54a30, is_sequence_header=false)
    at ./src/app/srs_app_source.cpp:1061
#10 0x00642094 in SrsLiveSource::on_video_imp (this=0xf7ed2db0,
    msg=0xf6e54a30) at ./src/app/srs_app_source.cpp:2457
#11 0x00641370 in SrsLiveSource::on_frame (this=0xf7ed2db0, msg=0xf6e54a30)
--Type <RET> for more, q to quit, c to continue without paging--
    at ./src/app/srs_app_source.cpp:2282
#12 0x00641ce8 in SrsLiveSource::on_video (this=0xf7ed2db0,
    shared_video=0xf7c85b80) at ./src/app/srs_app_source.cpp:2416
#13 0x006348b0 in SrsRtmpConn::process_publish_message (this=0xf7e57860,
    source=0xf7ed2db0, msg=0xf7c85b80) at ./src/app/srs_app_rtmp_conn.cpp:1213
#14 0x006346c8 in SrsRtmpConn::handle_publish_message (this=0xf7e57860,
    source=0xf7ed2db0, msg=0xf7c85b80) at ./src/app/srs_app_rtmp_conn.cpp:1185
#15 0x006e7598 in SrsPublishRecvThread::consume (this=0xf6ee0538,
    msg=0xf7c85b80) at ./src/app/srs_app_recv_thread.cpp:373
#16 0x006e672c in SrsRecvThread::do_cycle (this=0xf6ee0548)
    at ./src/app/srs_app_recv_thread.cpp:131
#17 0x006e65bc in SrsRecvThread::cycle (this=0xf6ee0548)
    at ./src/app/srs_app_recv_thread.cpp:100
#18 0x006628f0 in SrsFastCoroutine::cycle (this=0xf708f850)
    at ./src/app/srs_app_st.cpp:285
#19 0x00662784 in SrsFastCoroutine::pfn (arg=0xf708f850)
    at ./src/app/srs_app_st.cpp:300
#20 0x007b3550 in _st_thread_main () at sched.c:380
#21 0x007b2978 in st_thread_create (start=0xf6ee0264, arg=0xf7c86da0,
    joinable=-135982612, stk_size=-152173980) at sched.c:666
#22 0x00000000 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)
  1. SRS Config:
# main config for srs.
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
srs_log_tank        console;
#srs_log_file        ./objs/srs.log;
daemon              off;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc off;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp off;
    }

    play{
        gop_cache_max_frames 2500;
    }
}

Replay

bug at trunk/src/app/srs_app_hls.cpp srs_trace("-> " SRS_CONSTS_LOG_HLS " time=%dms, sno=%d, ts=%s, dur=%dms, dva=%dp", pprint->age(), controller->sequence_no(), controller->ts_url().c_str(), srsu2msi(controller->duration()), controller->deviation());

pprint->age() return value type is srs_utime_t (typedef int64_t), %lld is required instead of %d to output logs.

Step 1: xxxxxx

use gdb for debug:
gdb ./objs/srs
(gdb) r -c conf/srs.conf

Step 2: xxxxxx

ffmpeg -re -i ./doc/source.flv -c copy -f flv rtmp://192.168.3.5/live/livestream

Step 3: xxxxxx

(gdb) bt

Expect

Expect to fix the bug here to support 32-bit ARM platforms

TRANS_BY_GPT3