fix(rtmp): avoid segfault on connection-refused teardown

Track libavformat RTMP session initialization state so teardown only writes a trailer after the muxer header succeeds. This avoids calling av_write_trailer() on partially initialized sessions when avio_open2() fails with Connection refused.

Add a fault-suite regression for libavformat RTMP connection refusal and update the summary helper to compute all_pass from the actual manifest size instead of a hardcoded seven-row expectation.

Verified by rebuilding cvmmap_streamer and rtmp_output_tester, reproducing the refused-connection path without a crash, and running ./scripts/fault_suite.sh successfully (8/8).
This commit is contained in:
2026-04-14 10:21:04 +08:00
parent b277ed363f
commit 30cd956c5c
3 changed files with 26 additions and 4 deletions
+13 -1
View File
@@ -238,6 +238,18 @@ EOF
--frame-interval-ms 1 \
--linger-ms 0
run_expected_failure 8 "libavformat_connection_refused" "libavformat connection refusal surfaces without crashing" \
"failed to open RTMP output 'rtmp://127.0.0.1:1/live/test': Connection refused" \
"${RTMP_OUTPUT_TESTER}" \
--rtmp-url rtmp://127.0.0.1:1/live/test \
--transport libavformat \
--codec h264 \
--frames 1 \
--width 320 \
--height 240 \
--frame-interval-ms 1 \
--linger-ms 0
local finished_at_utc
finished_at_utc="$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
@@ -294,7 +306,7 @@ PY
echo "counts_pass=${pass_count}"
echo "counts_fail=${fail_count}"
echo "all_pass=${all_pass}"
echo "scenarios=removed_encoder_backend,removed_rtmp_transport,removed_rtmp_mode_cli,removed_rtmp_mode_toml,missing_rtmp_url,invalid_rtp_endpoint,ffmpeg_process_bad_binary"
echo "scenarios=removed_encoder_backend,removed_rtmp_transport,removed_rtmp_mode_cli,removed_rtmp_mode_toml,missing_rtmp_url,invalid_rtp_endpoint,ffmpeg_process_bad_binary,libavformat_connection_refused"
} > "${EVIDENCE_TEXT}"
if [[ "${all_pass}" == "true" ]]; then