Repository navigation
Conversation
A buffered fwrite can succeed while fclose fails on a full disk. Report the close error before config_save_safe replaces the original. Allow saving an empty configuration as well. Add Linux /dev/full regressions for direct and safe saves.
Member
zackees
added a commit
to nathan-v/obs-studio
that referenced
this pull request
Oct 10, 2026
Write configuration files to /dev/full, where small writes succeed in the stdio buffer and fail at fclose: config_save must report the error, config_save_safe must keep the original and not rotate a backup, and an empty configuration must still save directly and safely. test_config_file pinned the empty-save CONFIG_ERROR as characterized, not endorsed; it now expects CONFIG_SUCCESS. Rebased from obs-rust#35 onto current master. Co-Authored-By: Mquarmoc <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
open() spawns a real audio thread on both sides, whose ~21 ms worker ticks race the driver's explicit oracle_audio_tick/tick_for_test calls and the shared TICK recorder. Review comment on fork PR #35: - DRIVER mutex held for every test body so parallel #[test]s cannot interleave into TICK/ORDER. - Every recorded action now gates on the timestamp: input callbacks already filtered start_ts==MAGIC, but output callbacks pushed into TICK whenever it was Some; record_output and output_full_* now also require data.timestamp in [MAGIC, MAGIC+1e9), which real worker ticks (os_gettime_ns ~1e18) never enter. No production-code change; all 4 tests still pass.
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
Deterministic C-vs-Rust regressions (fork PR #35 acceptance): - self_disconnect_parity: oracle removes only itself, the port's iter_mut().rev() drops the whole tail — 1 vs 0 inputs left. - earlier_input_removal_parity: [A,B,C] with B removing A => order [3,2,2] (shifted element re-invoked) — locks the index-read semantics in for the rewrite. - vec_growth_parity: a callback connects a 5th input; the oracle's fixed bound yields [4,3,2,1], the port yields [4,3,2]. - concurrent_connect_disconnect_parity: churn from another thread across 10 driven ticks + quiesced final-tick order. - audio_io_core.rs call sites move to the new safe API (connect takes Option<&audio_convert_info>, disconnect is &self) — fails to compile on the current unsafe-FFI-shaped core: RED.
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
Fork PR #35 review: the worker held &mut AudioOutput for its whole life while connect/disconnect shims minted another &mut — aliasing UB ahead of the lock. And do_audio_output held mix.inputs.iter_mut().rev() across the callback, so a re-entrant connect could realloc the Vec under a live iterator (self-disconnect dropped the tail: oracle 1 vs port 0 inputs; push mid-tick lost the last element: [4,3,2] vs oracle [4,3,2,1]). Restructure, matching the C one-for-one: - AudioOutput is the owner (info getters, JoinHandle, initialized); the state the thread and FFI callers share lives in a Box<Shared> created before the recursive pthread mutex is initialized at its final address (POSIX forbids moving an initialized mutex). - The worker gets a &Shared only — no &mut AudioOutput or &mut Shared exists after open. connect/disconnect/active/tick_for_test are &self; mixes sit behind input_mutex + UnsafeCell with borrows scoped to a single statement. - do_audio_output keeps C's reverse-index traversal: bound fixed at entry, inputs[i-1] re-read per iteration, callback/param/resampler/ allow_clipping copied into locals, every borrow ended, callback invoked while still holding the recursive lock. Mid-dispatch removal past the loop index is skipped instead of calling freed tail memory (documented deviation; the C's stale-tail call has no defined equivalent). - Drop: stop + join complete before the shared box is freed, and the join never runs under the input lock. - NULL input_cb: tick treated as failed (C faults). NULL output cb: connect accepted, dead call skipped (C faults next tick). Both documented at the top of audio_io.rs. - Test determinism: a shared DRIVER mutex serializes MAGIC-stamped manual ticks in both test files (the real worker never produces MAGIC timestamps); the parity TICK record is replaced per driven tick so a test that never takes its record cannot poison the next case. unsafe stays confined to the UnsafeCell/FFI sites with SAFETY comments; the exception is recorded for the tracking issue.
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
Unix-first portability per fork PR #35 review: libc exposes no pthread API on Windows, so the port, its shims, oracle and tests are #[cfg(unix)] / #![cfg(unix)] and libobs keeps building media-io/audio-io.c on Windows (same ENABLE_RUST_LIBOBS + PLATFORM_ID:Windows guard shape as util/utf8.c). The 10 audio_output_* exports get the ' unix' marker so rust.cmake does not /EXPORT them on Windows — enforced by obs-util's export_list scan. A Windows backend behind the same safe API is separate work (noted in audio_io.rs). Also pins the audio_io_parity proptest-regressions file (repo convention: bitstream/config_file ship theirs).
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
obs_startup needs an X display; on headless Linux every obs-dependent case silently skipped (!obs_up -> skip). The fork PR #35 review requires a Tier 2 that cannot skip: the cases now assert obs_up loudly, and the test is registered via xvfb-run -a where xvfb exists (validate image gains the xvfb package) so they actually run — failures like an always-false audio_output_connect can no longer hide behind a skip. Local-Gate: v1 tree=c8db6ae56f567359dffd12caa5966158ab439936 secs=33 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791693456,"gate":"rust/all/fmt","host":"linux-x86_64","key":"cd423e03662fdf0d13cd05a924d8451ac1dcaa75ee035f6f256a7b48857f7b95","lane":"lint","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":5,"stamp":"5d0ec5461ad708d9efedb55ff851aefd","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"} Ci-Attestation: {"at":1791693456,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"cd423e03662fdf0d13cd05a924d8451ac1dcaa75ee035f6f256a7b48857f7b95","lane":"lint","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":5,"stamp":"2127baeef10d9722e392e4e1d8f43ff9","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"} Ci-Attestation: {"at":1791693456,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e53b1970f5af9aa3341c8c5341de995d6153585e927c48db3af11d6a8ffd5f3d","lane":"rust-test","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":20,"stamp":"3fcd1fe0ce7b781cbcaf03ea972473c9","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"} Ci-Attestation: {"at":1791693456,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"2add412b2ec51597e865ca2744b1b89e7e1d3a898d52de9f57597c5ba43a02c1","lane":"tier2-linux","parents":["f03b6ed91acbb9db863d37858469f1995b248ad9"],"secs":8,"stamp":"af2df4e9aa76ea57216a87a6d914f2b6","tree":"c8db6ae56f567359dffd12caa5966158ab439936","v":1,"via":"run"}
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
Fork PR #35 review items: - fresh_clamp_snapshot_parity: input cb connects an allow_clipping input to a mix that was empty at the active_mixes snapshot. C re-checks !mix->inputs.num at clamp time, so the new mix is clamped and the unclamped row carries the marker (recorded 2.5f); the port skips it behind the stale mask (recorded 0.0). - resample_parity: a rate-differing conversion must create a resampler and run the resample path; the NULL stub refuses the connect on both sides, so the assertion fails until a real resampler exists.
zackees
pushed a commit
that referenced
this pull request
Oct 12, 2026
Fork PR #35 items 3+4: explicit test ticks raced the real audio thread — a worker tick could interleave between an oracle tick and the matching port tick, mutating buffers and the registry under the same state the test was reading. Every driven-tick test now runs on a no-worker pair: oracle_audio_output_open_no_thread (same object minus stop_event and pthread; close destroys the mutex then frees inputs like the C) and AudioOutput::open_no_worker (open minus spawn). The concurrent test still exercises cross-thread connect/disconnect through the hammer threads; only the tick is exclusive. Shared TICK/ORDER statics are drained after closes via close_pair so nothing leaks between tests. audio_io.rs's input_thread_runs keeps the real worker — the thread is its subject.
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.
Description
Check the
fcloseresult inconfig_savesoconfig_save_safedoes not replace the original after a failed buffered write. Also let an empty configuration save successfully by skipping the zero-lengthfwrite.Motivation and Context
On a full disk, a small
fwritecan succeed in the stdio buffer whilefclosefails. The previous code reported success and allowed the temporary file to replace valid settings. Three new C tests cover direct flush errors, preservation of the original and backup on a safe-save error, and empty direct/safe saves.How Has This Been Tested?
The new failure cases were run against the original implementation and failed before the fix. The complete repository
./lintand./unittestcommands pass independently on this branch (Ubuntu 24.04 WSL host, Ubuntu 26.04 validation container):ENABLE_RUST_LIBOBS=OFFandON.The new filesystem failure tests are Linux-only because they use
/dev/full. Windows/macOS and an interactive OBS session were not run locally. These fixes detect buffered write errors; they do not add power-loss durability.Types of changes
Checklist: