Skip to content

bug: obs-ffmpeg: Start Recording again after an "Unable to write to" error crashes OBS (upstream #11940) #802

Closed

Description

@rdoupe

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.c ffmpeg_mux_start() (line 454) takes a reference to the output's settings with obs_output_get_settings() and releases it after ffmpeg_mux_start_internal() returns.
  • ffmpeg_mux_start_internal() (line 380) checks that the recording path can be opened. When it cannot, it calls set_file_not_readable_error() (line 314), which sets the "Unable to write to ..." error and also calls obs_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 into ffmpeg_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:

  1. Start Recording: "Failed to start recording / Unable to write to ...". Click OK.
  2. Start Recording again: OBS crashes (glibc: free(): invalid size or double free or corruption, or SIGSEGV in get_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.

Activity

  1. rdoupe commented on Oct 15, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: this issue.

    1. RED: test_ffmpeg_mux_unwritable_path builds obs-ffmpeg-mux.c and starts the real ffmpeg_muxer output on a path that cannot be created, with obs_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.
    2. GREEN: 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.
  2. added
    claimed
    on Oct 15, 2026
  3. rdoupe commented on Oct 15, 2026

    @rdoupe
    CollaboratorAuthor

    @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-git in 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions