Repository navigation
Description
Upstream OBS bug, reported twice by users on Windows. working-name in obsproject/obs-websocket#1216 (OBS 30.1.2, April 2024): with a | in the filename formatting, Start Recording shows "Failed to start recording", and Start Recording again after clicking OK crashes OBS. obsproject/obs-studio#11940 (OBS 31.0.1, March 2025, still open): with a folder name that ends in a space (%CCYY-%MM-%DD /%hh-%mm-%ss), the first Start Recording shows the error and the second one crashes. The trigger is not specific to Windows: any recording path OBS cannot write (a read-only or missing folder, a removed drive, a name the file system refuses) gives the error, and the retry crashes. Still present in this fork.
Location
plugins/obs-ffmpeg/obs-ffmpeg-mux.cffmpeg_mux_start()(line 454) takes a reference to the output's settings withobs_output_get_settings()and releases it afterffmpeg_mux_start_internal()returns.ffmpeg_mux_start_internal()(line 380) checks that the recording path can be opened. When it cannot, it callsset_file_not_readable_error()(line 314), which sets the "Unable to write to ..." error and also callsobs_data_release(settings)on the same settings.- So every failed start releases the settings twice and drops a reference the output owns. After the first failed start the output's settings are freed while the output still points to them. The frontend's next Start Recording calls
obs_output_update()(SimpleOutput::ConfigureRecording()/AdvancedOutput), which writes into the freed settings. - The release in
set_file_not_readable_error()was right when it was written:ffmpeg_mux_start()itself returned right after it. It became a second release in September 2022 (9d7a6e7 "obs-ffmpeg: Fix m3u8 recording in AMF"), when the start code moved intoffmpeg_mux_start_internal()and the wrapper took over releasing the settings.
Class
Crash (use after free / double free) on the UI thread.
How it is reached
Any recording with the ffmpeg_muxer output (Simple or Advanced output, Standard recording type, any format except Hybrid MP4/MOV) to a path that cannot be opened for writing:
- Start Recording: "Failed to start recording / Unable to write to ...". Click OK.
- Start Recording again: OBS crashes (glibc:
free(): invalid sizeordouble free or corruption, or SIGSEGV inget_item()<-obs_data_apply()<-obs_output_update()<-SimpleOutput::ConfigureRecording()).
Users usually do step 2 right away, before they look at the path, so the error turns into a lost session.
Reproduced in the current release
v0.1.0-beta.20261014 AppImage, headless (private Xvfb, private HOME, dbus-run-session, --multi), Simple output, recording path set to a read-only folder. obs-websocket sends StartRecord; a small test module clicks OK on the error dialog as a user would; then StartRecord again:
| Build | Runs | First start | Second start |
|---|---|---|---|
| v0.1.0-beta.20261014 | 5 | "Unable to write to ..." dialog | OBS crashes (SIGSEGV), 5 of 5 |
| Stock OBS 32.2.2 (Arch) | 2 | same dialog | SIGSEGV, 2 of 2 |
Without the module (the second StartRecord arrives while the first error dialog is still open) the release aborts instead, with free(): invalid size or double free or corruption (out), 3 of 3.
A build of current master under gdb stops with SIGSEGV in get_item() <- obs_data_apply() <- obs_output_update() <- SimpleOutput::ConfigureRecording() <- SimpleOutput::StartRecording().
Proposed fix and failing test
Fix: remove the obs_data_release(settings) from set_file_not_readable_error() (and its now unused settings parameter), so a failed start releases only the reference ffmpeg_mux_start() took.
RED test (cmocka, 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 (fails for every user, root included), with obs_data_release() wrapped to count releases of the output's settings. One failed start must release them once (today: twice), and three failed starts in a row, each after an obs_output_update() as the frontend does, three times (today: six). Needs a display (xvfb-run on Linux) and skips without one, like test_output_filename_reserve.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 15, 2026
Claiming: this issue.
test_ffmpeg_mux_unwritable_pathbuildsobs-ffmpeg-mux.cand starts the real ffmpeg_muxer output on a path that cannot be created, withobs_data_release()wrapped to count releases of the output's settings. Both cases fail: one failed start releases the settings twice, three failed starts six times.set_file_not_readable_error()no longer releases the settings;ffmpeg_mux_start()releases the one reference it took, so Start Recording can be retried after "Unable to write to ...".PR today.
test/cmocka: Add failing test for retrying a recording on an unwritab…
obs-ffmpeg: Release the settings once when a recording path is unwrit…
rdoupe commentedon Oct 15, 2026
@working-name you reported this in obsproject/obs-websocket#1216 (after "Failed to start recording", pressing Start Recording again crashes OBS), so a heads-up: it's fixed here in obs-rust by #803, merged today with a regression test.
Cause: when the recording path can't be opened for writing, the ffmpeg muxer output set the "Unable to write to ..." error and also released the output's settings, which its caller released again. Each failed start dropped one reference the output still owned, so the settings were freed and the next Start Recording wrote into freed memory. The extra release dates from a 2022 refactor. In our release the retry crashed 5 of 5 times (stock OBS 32.2.2 too); with the fix it crashed 0 of 4, the error dialog simply shows again, and once the path is fixed the recording works.
Workaround on stock OBS: after that error, fix the path (or filename formatting) and restart OBS before starting the recording again (not tested here).
It will be in the next obs-rust daily release after 0.1.0-beta.20261014: https://github.com/obs-rust/obs-studio/releases (Windows, macOS and Linux builds; on Arch it's
obs-studio-rust-gitin the AUR). obs-rust is an AI-assisted fork of OBS.If you get a chance to try it, a reply here on whether retrying after the error now works would really help.
obs-ffmpeg: Release the settings once when a recording path is unwrit…