You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: libobs/util: with ENABLE_RUST_LIBOBS=ON, config_save ignores the final close error and config_save_safe promotes the temp file #489
With ENABLE_RUST_LIBOBS=ON, config_save ignores a failed final close and reports success, and config_save_safe then renames the possibly truncated temp file over the real config. The C reference checks the close result, returns CONFIG_ERROR and leaves the original file alone. Severity: medium. It needs a close failure (disk full or a network filesystem write-back error), but the result is a good config silently replaced by a truncated one.
Steps / trigger
Build with ENABLE_RUST_LIBOBS=ON.
Call config_save_safe(config, "tmp", "bak") (or config_save) on a filesystem where the final close of the written file fails. A test can inject EIO into close.
ON returns CONFIG_SUCCESS and, for the safe variant, replaces the target with the temp file. OFF returns CONFIG_ERROR, keeps the original, and config_save_safe logs "failed to write to ".
Cause
Line numbers are against current master.
C reference, libobs/util/config-file.c:388-389: if (fclose(f) != 0) ret = CONFIG_ERROR; (added by libobs: Detect failed configuration flushes #70). config_save_safe then logs at :425-426 and skips the replace.
rust/obs-util/src/config_file.rs:881-885: write_to checks write_all and flush, but then does drop(f). Dropping a File discards the close error, and flush on a File does nothing, so it returns CONFIG_SUCCESS.
rust/obs-util/src/config_file.rs:901-916: save_safe sees success and renames the temp file into place. When the write fails it returns without the config_save_safe: failed to write to %s message the C version logs.
Direct config_save logs nothing on any failure in C, so the Rust version stays silent there too. Only the safe path logs.
Proposed fix
Close the file explicitly and treat a close failure as CONFIG_ERROR: take ownership of the descriptor or handle from the File and call the native close once, with no retry, in the platform layer. In save_safe, release the config mutex and log config_save_safe: failed to write to %s at error level when write_to fails, to match the C message and level. The regression test injects one close failure through an interposed close and checks the return code, that the original file and backup are untouched, that exactly one close was attempted, and the single log line on the safe path and none on the direct path.
I'd like to work on this; a fix with a regression test is ready.
@chriscoveries go ahead: please open the PR with the RED test commit first, then the fix (one PR per issue, targeting master). Marking it claimed for you so nobody duplicates it.
Releasing this one. We're backed up on CI and won't get it landed soon, so anyone who wants it is welcome to take it.
If it helps, our RED test and fix are on the fork branch fix/config-save-close-error-parity. They passed review on our side but haven't been through CI, so reuse them or start fresh, whichever you prefer.
Activity
zackees commentedon Oct 13, 2026
@chriscoveries go ahead: please open the PR with the RED test commit first, then the fix (one PR per issue, targeting master). Marking it claimed for you so nobody duplicates it.
chriscoveries commentedon Oct 14, 2026
Releasing this one. We're backed up on CI and won't get it landed soon, so anyone who wants it is welcome to take it.
If it helps, our RED test and fix are on the fork branch
fix/config-save-close-error-parity. They passed review on our side but haven't been through CI, so reuse them or start fresh, whichever you prefer.zackees commentedon Oct 14, 2026
Claiming.
config-file: Log config_save_safe temp-file write failures in Rust (#489
config-file: report a failed final close in config_save (obs-rust#709)