Repository navigation
obs-ffmpeg: Release the settings once when a recording path is unwritable - #803
Merged
Merged
Conversation
…le path When a recording cannot be written (a folder or character the file system refuses, a read-only or missing folder), Start Recording fails with "Unable to write to ...", and the next Start Recording crashes OBS. ffmpeg_mux_start() takes one reference to the output's settings and releases it after ffmpeg_mux_start_internal() returns, but on this failure set_file_not_readable_error() releases the same settings again. After the first failed start the output's settings are freed while the output still owns them, and the frontend's next obs_output_update() writes into freed memory. test_ffmpeg_mux_unwritable_path builds obs-ffmpeg-mux.c and starts the real ffmpeg_muxer output against core video on a path whose parent is a regular file, with obs_data_release() wrapped to count releases of the output's settings. Both cases fail: one failed start releases them twice, three failed starts six times. Needs a display (xvfb-run) and skips without one. Refs obs-rust#802. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…able When ffmpeg_muxer cannot write its recording path, Start Recording fails with "Unable to write to ...", and the next Start Recording crashed OBS. ffmpeg_mux_start() releases the reference to the output's settings that it takes, but set_file_not_readable_error() released it too, so every failed start dropped a reference the output owns. The output's settings were freed while it still used them, and the next obs_output_update() wrote into freed memory. The release has been in set_file_not_readable_error() since it was written; it became an extra one when ffmpeg_mux_start() took over releasing the settings (9d7a6e7, 2022). Remove it. Fixes obs-rust#802. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=7ef19538370df4c7d0425adfedb1f52024190c30 secs=1634 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1792042674,"gate":"rust/all/fmt","host":"linux-x86_64","key":"063fa1a2a1fafc58e4c43a19381d11b670ad7235e2ba9ff23c4b75f661fbce50","lane":"lint","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":68,"stamp":"03846058a9ed48f16594923c162dae77","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"063fa1a2a1fafc58e4c43a19381d11b670ad7235e2ba9ff23c4b75f661fbce50","lane":"lint","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":68,"stamp":"1e67886e6062309129fafab8018665fb","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"14d13724c5ad22d6dd08f61c0cf97f7b6365c4d9817cd4e184e2e5cf87c154ba","lane":"rust-test","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":147,"stamp":"0bc06a9770f6c8707a52e5b98b1302bf","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"422166a2d51bd93b29ea4486a1be1a05ea03397a2ce59961ad95e206d00d3511","lane":"cross","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":127,"stamp":"c8b70b93ddd1a9466552dc713b758c5d","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"422166a2d51bd93b29ea4486a1be1a05ea03397a2ce59961ad95e206d00d3511","lane":"cross","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":127,"stamp":"ef0f93df5eeeba79150c908832d94397","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"422166a2d51bd93b29ea4486a1be1a05ea03397a2ce59961ad95e206d00d3511","lane":"cross","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":127,"stamp":"0d443186e49ed745eaa1411b679bfeaf","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"422166a2d51bd93b29ea4486a1be1a05ea03397a2ce59961ad95e206d00d3511","lane":"cross","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":127,"stamp":"75d7e2a574c81e59f87514edfc303602","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"422166a2d51bd93b29ea4486a1be1a05ea03397a2ce59961ad95e206d00d3511","lane":"cross","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":127,"stamp":"929d0517baeea01b8177d480886150d7","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"422166a2d51bd93b29ea4486a1be1a05ea03397a2ce59961ad95e206d00d3511","lane":"cross","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":127,"stamp":"0b76ac4924e482afcb60e45458bc1bd8","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"} Ci-Attestation: {"at":1792042674,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"926b8459fac58a49cbb8222f9a40e5eb2bf9b4770b983d08de485d7cdd31ab0c","lane":"tier2-linux","parents":["4f81b2ef3a6744394a449ca7fd1f70d6b2eb0223"],"secs":1291,"stamp":"a3d81debe8d17d38ec562ef2377842df","tree":"7ef19538370df4c7d0425adfedb1f52024190c30","v":1,"via":"run"}
Member
|
Rebased onto master, set
|
zackees
force-pushed
the
fix/record-retry-crash
branch
from
October 15, 2026 05:37
358693a to
0b3dd63
Compare
zackees
enabled auto-merge
October 15, 2026 05:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #802
What and why
Start Recording no longer crashes OBS when the previous attempt failed with "Unable to write to ..." (a read-only or missing folder, a removed drive, a folder name or character the file system refuses).
ffmpeg_mux_start()(plugins/obs-ffmpeg/obs-ffmpeg-mux.cline 454) takes a reference to the output's settings and releases it afterffmpeg_mux_start_internal()returns. When the recording path cannot be opened,ffmpeg_mux_start_internal()callsset_file_not_readable_error()(line 314), which released the same settings again. Each failed start dropped a reference the output owns, so the output's settings were freed while it still used them, and the frontend's next Start Recording (obs_output_update()inSimpleOutput::ConfigureRecording()) wrote into freed memory.ffmpeg_mux_start_internal()and made the wrapper release the settings; the release in the error helper was left in. This change removes it (and the helper's now unusedsettingsparameter).|in the filename formatting, OBS 30.1.2) and in Error and crash when trying to create a folder with trailing spaces obsproject/obs-studio#11940 (a folder name ending in a space, OBS 31.0.1, open): the first Start Recording shows the error, the second, after clicking OK, crashes. Both on Windows; the path check is the same on every platform.Reproduced headless (private Xvfb, private HOME,
dbus-run-session,--multi): Simple and Advanced output, recording folder read-only; obs-websocket sends StartRecord, a small test module clicks OK on the error dialog as a user would, then StartRecord again:On a master build under gdb the crash is in
get_item()<-obs_data_apply()<-obs_output_update()<-SimpleOutput::ConfigureRecording()<-SimpleOutput::StartRecording().RED → GREEN
test/cmocka: Add failing test for retrying a recording on an unwritable path.test_ffmpeg_mux_unwritable_pathbuildsobs-ffmpeg-mux.cand starts the real ffmpeg_muxer output against core video on a path whose parent is a regular file (fails for root too), withobs_data_release()wrapped (--wrap) to count releases of the output's settings. Both cases fail in both lanes:test_failed_start_releases_settings_once(released 2 times, took 1 reference) andtest_retry_after_failed_start_keeps_settings(3 failed starts, each after anobs_output_update()like the frontend's, released 6 times). Needs a display (xvfb-run, liketest_output_filename_reserve); skips without one (checked withenv -u DISPLAY).ENABLE_RUST_LIBOBSOFF and ON. Full ctest (private Xvfb, systemlibobs-openglmasked, TMPDIR unset): 237/237 in both lanes, every PipeWire/PulseAudio test ran; skipped onlyopen_crashes_without_obs_core(two binaries). clang-format, gersemi andci/test_registration.pyclean.Checklist
master-W..., ratchets): noneSide finding, not changed here: a start that fails this way leaves the output's encoders initialized (the next start logs "Cannot apply a new video_t object after the encoder has been initialized"); #237 shuts encoders down after a start that fails later, not after
start()returns false.AI note: Claude Code (Claude Opus 5.5) wrote the code, the test, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.
🤖 Generated with Claude Code