Skip to content

obs-ffmpeg: zero-init missing-encoder error, publish connecting before worker (split from #1464) - #1554

Merged
zackees merged 2 commits into
masterfrom
fix/ffmpeg-output-split
Oct 20, 2026
Merged

zackees merged 2 commits into
masterfrom
fix/ffmpeg-output-split

Conversation

@zackees

@zackees zackees commented Oct 20, 2026

Copy link
Copy Markdown
Member

Split from #1464 (the obs-ffmpeg output/encoder part).

  • Missing encoder error (1b534db, obs-ffmpeg-video-encoders.c.h): ffmpeg_video_encoder_init() printed "Couldn't find encoder" into an uninitialized struct dstr, so dstr_printf reallocated leftover stack garbage. It is now = {0}.
  • Connecting state (c79ee27, obs-ffmpeg-output.c.h): ffmpeg_output_start() assigned connecting = (ret == 0) after pthread_create; if the connect worker already finished and cleared it, the flag stuck at true and every later start was refused. connecting is now set before the worker starts and cleared only if creation fails.

Evidence (commit 1 RED, commit 2 GREEN):

  • test/cmocka/test_ffmpeg_encoder_missing.c: includes the encoder file with dstr_printf replaced by a recorder; the stack is filled with 0xA5 right before the call so the uninitialized case is deterministic in practice. Asserts the dstr is zeroed and the error text is set.
  • test/cmocka/test_ffmpeg_output_connecting.c: includes the output file with pthread_create replaced. Limit: the real bug is a thread race; the stand-in reproduces the losing ordering deterministically by doing what a finished worker does (clear connecting) before returning, rather than running the real connect. Asserts connecting is false afterwards and a second start is accepted; also covers create failure.

Not built locally (no FFmpeg/cmocka on the shared host); ./lint passes; PR CI Tier 2 is the gate. Ledger line added to docs/features.md.

…e (RED)

Split from #1464. Fails on master: ffmpeg_video_encoder_init() prints into an
uninitialized dstr, and ffmpeg_output_start() overwrites connecting after a
worker that already finished cleared it.
… (GREEN)

Split from #1464 (commits 1b534db, c79ee27):
- ffmpeg_video_encoder_init() zero-initializes its error dstr;
- ffmpeg_output_start() sets connecting before creating the worker and
  clears it only when creation fails.
@zackees
zackees enabled auto-merge October 20, 2026 20:16
@zackees
zackees added this pull request to the merge queue Oct 20, 2026
Merged via the queue into master with commit e25757d Oct 20, 2026
23 checks passed
@zackees
zackees deleted the fix/ffmpeg-output-split branch October 26, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant