txproto icon indicating copy to clipboard operation
txproto copied to clipboard

Segmentation fault if trying to push to an rtmp endpoint that is down

Open tmatth opened this issue 1 year ago • 0 comments

To reproduce, push to a non-existent RTMP server, e.g.

diff --git a/DOCS/examples/stream_to_twitch.lua b/DOCS/examples/stream_to_twitch.lua
index b0534b1..c854aad 100644
--- a/DOCS/examples/stream_to_twitch.lua
+++ b/DOCS/examples/stream_to_twitch.lua
@@ -75,7 +75,7 @@ function main(...)
     encoder_a.link(filter_audio, "out0")
 
     muxer = tx.create_muxer({
-            out_url = "rtmp://live-cdg.twitch.tv/app/    TWITCH PRIVATE STREAM KEY GOES HERE",
+            out_url = "rtmp://127.0.0.1:2935/live/foo",
             out_format = "flv",
             priv_options = { dump_info = true, low_latency = true },
         })

then

build/src/txproto -s DOCS/examples/stream_to_twitch.lua -V debug

will crash on:

[0.325|ffmpeg->tcp] Starting connection attempt to 127.0.0.1 port 2935
[0.325|ffmpeg->tcp] Connection attempt to 127.0.0.1 port 2935 failed: Connection refused
[0.326|ffmpeg->tcp] Connection to tcp://127.0.0.1:2935?tcp_nodelay=0 failed: Connection refused
[0.326|ffmpeg->rtmp] Cannot open connection tcp://127.0.0.1:2935?tcp_nodelay=0
[0.326|lavf:flv] Couldn't open rtmp://127.0.0.1:2935/live/foo: Connection refused!
[0.326|tx] tx->create_muxer: Unable to init muxer: Connection refused!
Segmentation fault (core dumped)

Backtrace:

#0  0x00007ffff4e49db6 in av_opt_next () from /home/tmatth/local/lib/libavutil.so.59
#1  0x00007ffff4e4a09b in av_opt_free () from /home/tmatth/local/lib/libavutil.so.59
#2  0x00007ffff6662bdd in avformat_free_context () from /home/tmatth/local/lib/libavformat.so.61
#3  0x00007ffff7f882a8 in muxer_free (opaque=<optimized out>, data=0x555555617e40 "\200raUUU") at ../src/mux.c:479
#4  0x00007ffff4e26826 in av_buffer_unref () from /home/tmatth/local/lib/libavutil.so.59
#5  0x00007ffff7f854d8 in lua_create_muxer (L=0x555555591ea8) at ../src/lua_api.c:542
#6  0x00007ffff69d05ea in precallC (f=<optimized out>, nresults=1, func=0x555555591fb0, L=0x555555591ea8) at /build/lua5.4-GCEpSw/lua5.4-5.4.6/src/ldo.c:529
#7  luaD_precall (L=0x555555591ea8, func=<optimized out>, nresults=1) at /build/lua5.4-GCEpSw/lua5.4-5.4.6/src/ldo.c:595
#8  0x00007ffff69dd673 in luaV_execute (L=<optimized out>, ci=<optimized out>) at /build/lua5.4-GCEpSw/lua5.4-5.4.6/src/lvm.c:1684
#9  0x00007ffff69cbf35 in luaD_rawrunprotected (L=L@entry=0x555555591ea8, f=f@entry=0x7ffff69d2b90 <resume>, ud=ud@entry=0x7fffffffd7bc)
    at /build/lua5.4-GCEpSw/lua5.4-5.4.6/src/ldo.c:144
#10 0x00007ffff69ccf96 in lua_resume (L=L@entry=0x555555591ea8, from=from@entry=0x0, nargs=<optimized out>, nargs@entry=0, nresults=nresults@entry=0x7fffffffd804)
    at /build/lua5.4-GCEpSw/lua5.4-5.4.6/src/ldo.c:849
#11 0x00007ffff7f7e71d in sp_lua_run_generic_yieldable (lctx=0x5555555947c0, nb_args=nb_args@entry=0, clean_stack=clean_stack@entry=1, ctx_is_locked=ctx_is_locked@entry=1)
    at ../src/lua_common.c:904
#12 0x0000555555557180 in main (argc=<optimized out>, argv=<optimized out>) at ../src/txproto_main.c:348

tmatth avatar Nov 06 '24 01:11 tmatth