Repository navigation
libobs: Preserve serialized files when safe saves fail - #71
Merged
Merged
Conversation
This was referenced Oct 9, 2026
Safely serialize to a temporary file symlinked to /dev/full, or whose rename fails: an immediate write error, a buffered flush error and a failed replacement must each leave the original file intact, and a successful save must replace it and remove the temporary file. The tests live beside the unchanged test_file_serializer characterization test, Linux-only for /dev/full. Rebased from #36 onto current master. Co-Authored-By: Mquarmoc <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
file_output_serializer_free ignored write and flush errors and then unlinked the destination before renaming the temporary file over it, so a full disk installed a truncated file and a failed rename lost the original entirely. Check ferror and fclose, replace through os_safe_replace only on success, and log a failed save. Fixes #36 Co-Authored-By: Mquarmoc <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=221c837eae4bc17d00f21dfb5c3f41d4e82ada8b secs=28 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791591328,"gate":"rust/all/fmt","host":"linux-x86_64","key":"2bfcc62af1ced1616cb453b0ff44edb11ac9a067bd015231c277ec3d90cf8ca1","lane":"lint","parents":["456bf8e160c7e710264c338c53514f42eb66a339"],"secs":9,"stamp":"07e30a3915b1acd9508bd08f758277e8","tree":"221c837eae4bc17d00f21dfb5c3f41d4e82ada8b","v":1,"via":"run"} Ci-Attestation: {"at":1791591328,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"2bfcc62af1ced1616cb453b0ff44edb11ac9a067bd015231c277ec3d90cf8ca1","lane":"lint","parents":["456bf8e160c7e710264c338c53514f42eb66a339"],"secs":9,"stamp":"9268efd573f8779f2cb907efa407aedc","tree":"221c837eae4bc17d00f21dfb5c3f41d4e82ada8b","v":1,"via":"run"} Ci-Attestation: {"at":1791591328,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"2931c01a2b511eb9a87a9771a8f991aeb5ded7821e822be3ed33db850eff2c54","lane":"rust-test","parents":["456bf8e160c7e710264c338c53514f42eb66a339"],"secs":5,"stamp":"aaa15bdfc341d1d1b18abd9f8d2dbf42","tree":"221c837eae4bc17d00f21dfb5c3f41d4e82ada8b","v":1,"via":"run"} Ci-Attestation: {"at":1791591328,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"66075c26f9bafd72ec84ad7353e4120ff921d9678b1eb00590909c7e96be34f1","lane":"tier2-linux","parents":["456bf8e160c7e710264c338c53514f42eb66a339"],"secs":14,"stamp":"40faec51a8a855ba8abbffeca9fba51a","tree":"221c837eae4bc17d00f21dfb5c3f41d4e82ada8b","v":1,"via":"run"}
zackees
force-pushed
the
fix/serializer-safe-replace
branch
from
October 10, 2026 00:15
16c8d17 to
2cfa79d
Compare
7 tasks done
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
file-serializer.c now replaces safe saves through os_safe_replace (obs-rust#71), so the oracle host provides it, following platform-nix.c and platform-windows.c. fseeko/ftello are POSIX and hidden by -std=c11; GCC 14 rejects the implicit declarations, so expose them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
Mirror test_file_serializer_safe.c (obs-rust#71) in Tier 1: a write to a /dev/full temporary file and a vanished temporary file must both leave the original destination intact. The port still unlinks the destination and renames the temporary file over it regardless of errors, so with ENABLE_RUST_LIBOBS=ON test_file_serializer_safe fails all three failure cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
Follow the C fix in obs-rust#71. Output buffers writes like fwrite, records a short write or failed flush, and on drop installs the temporary file with a single rename only after a clean write, instead of unlinking the destination and renaming over it regardless of errors. A full disk or a failed rename now leaves the original intact. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=abdadacf8c512ab9ee957f8404e624d40569edee secs=180 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791594564,"gate":"rust/all/fmt","host":"linux-x86_64","key":"3ac7a0f9758cc2eb386d1aba1d4332bcd8c0f397f2699e63c137383d2e21e7f9","lane":"lint","parents":["1cf9795603dcc49bdd4a722f5ebaea19b259b12e"],"secs":110,"stamp":"94b1cacf62926ded5589edad70f6862e","tree":"abdadacf8c512ab9ee957f8404e624d40569edee","v":1,"via":"run"} Ci-Attestation: {"at":1791594564,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"3ac7a0f9758cc2eb386d1aba1d4332bcd8c0f397f2699e63c137383d2e21e7f9","lane":"lint","parents":["1cf9795603dcc49bdd4a722f5ebaea19b259b12e"],"secs":110,"stamp":"78f876756e10f4207fc504529f0a8bb6","tree":"abdadacf8c512ab9ee957f8404e624d40569edee","v":1,"via":"run"} Ci-Attestation: {"at":1791594564,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"aee2b0321da147a1d4d0f179081b551d04abfa54b3dc92d424ad7974440f522d","lane":"rust-test","parents":["1cf9795603dcc49bdd4a722f5ebaea19b259b12e"],"secs":28,"stamp":"5fb9c3fe2d98bcc8abaf1b178f1e73d0","tree":"abdadacf8c512ab9ee957f8404e624d40569edee","v":1,"via":"run"} Ci-Attestation: {"at":1791594564,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"fd43799a8129adc9c4441152fba8db4164aab102fd8d43265bd593169fffa2cb","lane":"tier2-linux","parents":["1cf9795603dcc49bdd4a722f5ebaea19b259b12e"],"secs":42,"stamp":"30be8ef02098e2219e20b34bd71cd6d7","tree":"abdadacf8c512ab9ee957f8404e624d40569edee","v":1,"via":"run"}
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
file-serializer.c now replaces safe saves through os_safe_replace (obs-rust#71), so the oracle host provides it, following platform-nix.c and platform-windows.c. fseeko/ftello are POSIX and hidden by -std=c11; GCC 14 rejects the implicit declarations, so expose them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
Mirror test_file_serializer_safe.c (obs-rust#71) in Tier 1: a write to a /dev/full temporary file and a vanished temporary file must both leave the original destination intact. The port still unlinks the destination and renames the temporary file over it regardless of errors, so with ENABLE_RUST_LIBOBS=ON test_file_serializer_safe fails all three failure cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
Follow the C fix in obs-rust#71. Output buffers writes like fwrite, records a short write or failed flush, and on drop installs the temporary file with a single rename only after a clean write, instead of unlinking the destination and renaming over it regardless of errors. A full disk or a failed rename now leaves the original intact. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=fcf1cb0bdb4abc27e9d34fe187941805188dcae0 secs=83 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791594782,"gate":"rust/all/fmt","host":"linux-x86_64","key":"c73e811b613c4ea37b837bf9f54f9f316207792d1e5c5b9be7f477eb0e01b927","lane":"lint","parents":["3e595ef9ff93286bf5b6a6f3023c750d328dec24"],"secs":28,"stamp":"58051c4640b294d4cac649658c2c39c2","tree":"fcf1cb0bdb4abc27e9d34fe187941805188dcae0","v":1,"via":"run"} Ci-Attestation: {"at":1791594782,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"c73e811b613c4ea37b837bf9f54f9f316207792d1e5c5b9be7f477eb0e01b927","lane":"lint","parents":["3e595ef9ff93286bf5b6a6f3023c750d328dec24"],"secs":28,"stamp":"c02d0c41fac01b88105f8a282574db34","tree":"fcf1cb0bdb4abc27e9d34fe187941805188dcae0","v":1,"via":"run"} Ci-Attestation: {"at":1791594782,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"9d7df3a023b40aa8216e052722ab7cc7d37469f720fb78c495f0c7f7c105f1bc","lane":"rust-test","parents":["3e595ef9ff93286bf5b6a6f3023c750d328dec24"],"secs":18,"stamp":"d931f130ec57616189be2d03ba13d832","tree":"fcf1cb0bdb4abc27e9d34fe187941805188dcae0","v":1,"via":"run"} Ci-Attestation: {"at":1791594782,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"9338b4f97214c3bbc516bb75440c537403b08a3d8d2e9095949ec77be6b6c923","lane":"tier2-linux","parents":["3e595ef9ff93286bf5b6a6f3023c750d328dec24"],"secs":37,"stamp":"2a152f1bbd28b20fe4d8b44bb44cff2d","tree":"fcf1cb0bdb4abc27e9d34fe187941805188dcae0","v":1,"via":"run"}
7 tasks done
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.
Supersedes #36 (by @Mquarmoc), rebased onto current master as a RED → GREEN pair.
RED —
c878e8f20test(libobs): RED safe file-serializer failure testsMaster already has a
test_file_serializer.ccharacterization test, which stays unchanged. The PR's tests move to a new Linux-onlytest/cmocka/test_file_serializer_safe.c(/dev/full). Against master:GREEN —
16c8d1748libobs: Preserve serialized files when safe saves failfile_output_serializer_freenow checksferrorandfclose. On success it installs the temporary file withos_safe_replace, which handles a missing target on both nix and Windows, instead ofos_unlinkfollowed byos_rename. Otherwise it logs a warning and leaves the original alone../unittest: 27/27 cmocka withENABLE_RUST_LIBOBSOFF and ON, identical exported symbols. Local gate stamped.Note: #66 (file-serializer Rust port) will need to carry this behavior;
test_file_serializer_safebecomes a Tier 2 check for it.