Repository navigation
obs-source: swap obs_weak_source_addref and obs_weak_source_release to Rust (Fixes #5665) - #5717
Merged
Merged
Conversation
… (Refs #5665) New cmocka test_source_weak_refs, run unchanged against hybrid libobs and the C reference: NULL handles are silent no-ops; each addref and release moves only the weak count by one; the release that takes the weak count from 0 to -1 frees the control whatever the strong count is, and no earlier one does; a count already below zero is lowered further and never freed (characterized, not endorsed); on a live private scene the control outlives the source until its last weak reference is released. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Refs #5665) Mirrors the four cases of test_source_weak_refs that need no live core in the existing obs-tests-core binary. All four panic on the stub. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…o Rust (Fixes #5665) A safe core in rust/obs-source/src/weak_refs.rs adds or drops one weak reference on a borrowed native-long atomic; release reports true only on the exact step from 0 to -1, as the C's os_atomic_dec_long(...) == -1. The shims in ffi/source_weak_refs.rs reject NULL before reading, borrow the count through the private adapter obs-source-weak-refs-fields.c.h, and bfree the control on the final release. The extracted C moves unchanged to the reference-only group libobs.ported-source-weak-refs; the rust-static link support now carries the adapter instead of the C. Oracle refits for the new Rust symbols: source_get_weak.c renames its recording copy of the original addref (the Rust side is compared on returns and counts), and hotkey_unregister_links.c drops its never-called obs_weak_source_release stand-in, which obs-source now provides. Tier 3 runs the renamed original C and the Rust exports over noise-filled real-header controls: pinned edge sequences (including counts below zero) and generated addref/release sequences, comparing both counts, the source bytes and the adapter address after every step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rdoupe
marked this pull request as ready for review
November 25, 2026 18:45
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.
Fixes #5665.
Ports
obs_weak_source_addrefandobs_weak_source_release(both exported) to Rust in obs-source. The C was already extracted tolibobs/obs-source-weak-refs.c.h.Commits
4c82acaa5test: characterize the pair in a new cmocka test,test/cmocka/test_source_weak_refs.c, run unchanged against hybrid libobs and the C reference: NULL handles are silent no-ops; each addref/release moves only the weak count by one; the release that takes the weak count from 0 to -1 frees the control whatever the strong count is, and no earlier one does; a count already below zero is lowered further and never freed (characterized, not endorsed); on a live private scene the control outlives the source until its last weak reference is released.e1e910e63test: RED. Tier 1 mirrors against atodo!()core.0f78a4289obs-source: GREEN. Safe corerust/obs-source/src/weak_refs.rson a borrowed native-long atomic (release reports true only on the exact 0 → -1 step, as the C'sos_atomic_dec_long(...) == -1); C ABI shims inffi/source_weak_refs.rsreject NULL before reading, borrow the count through the private adapterobs-source-weak-refs-fields.c.h, andbfreethe control on the final release. The extracted C moves unchanged to the reference-only grouplibobs.ported-source-weak-refs. Oracle refits for the new Rust symbols:source_get_weak.crenames its recording copy of the original addref, andhotkey_unregister_links.cdrops its never-calledobs_weak_source_releasestand-in. Tier 3 parity runs the renamed original C and the Rust exports over noise-filled real-header controls: pinned edge sequences (including counts below zero) and generated sequences, comparing both counts, the source bytes and the adapter address after every step.No public header, existing C test, frontend, plugin or obs-websocket change. Exports are unchanged (1769 symbols, identical between the C and Rust builds).
Evidence
RED (
e1e910e63):GREEN (head, on
8a1954247):🤖 Generated with Claude Code