Repository navigation
obs-output: swap service info-table and plugin-data accessors to safe Rust (Refs #3840) - #5379
Merged
Merged
Conversation
…3840) Tier 1 mirrors every assertion of the unchanged test_service_info_accessors.c on a safe core: the table is copied whole, by value, into the service and nothing else changes; a later change to the source does not reach the service; the table getter borrows the service's own copy and returns the same address every time; a second set and an all-NULL table overwrite it in place; the plugin data round-trips as it is, NULL included, and reading it changes nothing. Tier 3 runs the extracted original (oracle/service_info_accessors.c) and the Rust shims on two services built from the same byte pattern, through the real field adapter: the characterized sequence plus random sequences of sets (including a table copied onto itself) and gets, comparing each result as an offset into its service, both services byte for byte and the source tables, with real-header layout checks and four mutants. The plumbing for the swap is in place: the private field adapter obs_service_info_accessors_fields() (obs-internal.h), the hidden list, the C-reference-only ported group, the refit Rust-static support member, the oracle's own copies of the four names dropped from service_getters.c, and the test_service_info_accessors_rust twin with its registration test. The safe setters are stubs that write nothing: soldr cargo test -p obs-data --test obs-tests-core -- output::service_info_accessors test result: FAILED. 2 passed; 4 failed (The 2 passes are the layout/adapter check and the mutant check.) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Rust (Refs #3840) The hidden obs_service_set_info, obs_service_set_plugin_data, obs_service_get_info_table and obs_service_get_plugin_data are now safe Rust in obs-output. set_info reads the caller's table whole and then writes it over the service's own copy, so a later change to the source never reaches the service and a table copied onto itself stays as it was; get_info_table hands back the borrowed address of that copy; the plugin data is stored and returned as it is, NULL included. Nothing else in the service changes and nothing is logged. The private field adapter obs_service_info_accessors_fields() keeps struct obs_service in C, and the original moves to libobs.ported-service-info-accessors for the C reference. soldr cargo test -p obs-data --test obs-tests-core -- output:: test result: ok. 1412 passed; 0 failed Co-Authored-By: Claude Opus 5.5 <[email protected]> Ci-Attestation: {"at":1795242605,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":94,"stamp":"1444ef8f34b9fbadbad11b20ecc03002","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242605,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":94,"stamp":"7af7d503f9cd1374c179ac361caa697a","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242605,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":94,"stamp":"e812f00bb81fa06aaa4e4fe9df065fbb","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242605,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":94,"stamp":"381d7935a79c166a091450704ccf21ca","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242509,"gate":"general/all/client-lint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"38fb3a4b0d065d19e62a1e026723295e","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242605,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":94,"stamp":"fc22a0cfc1c86ef268bbc922cc07d411","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"d737ae2b249cae7effd07b02c81a5d66","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"e0cb786feb676fbd7821c20eea4b16db","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"6b039949d9a38d245b4c18a6fe9471eb","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"2d33406fe35a74d783311a0f2ae80a99","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242509,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"3d01dadf43fbf9e6579fcd365f474c8b","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"4b01efa9ffeeb9c676d6c5f795f8c807","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"db04188d32d565fec65c0b826ac4f885","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"b2c1c9251e7abfdf6e6cc1c4ae99571b","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"ddd24bddc8dbe0ae4e26870d5c477313","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242510,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"f8ccd3a3293cc9544760e24a537506f5","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242509,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"8b9a41530d2526a338a12795edaecf0f","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242509,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"972616a69fa8eb969354ddbc85bffcd8bb53622b8792d209eb6f96c697bbede9","lane":"client-lint","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":79,"stamp":"73c567186e63376ce49f3fb5c21680b7","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Ci-Attestation: {"at":1795242831,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"1da07565b70582fe1946ce26dfb0542da34f362c818ab2930812c2fb2c4a09ca","lane":"client-test-x86_64-unknown-linux-gnu","parents":["0dd0a09cf02db94a07fbb4ece749de848fd3902d"],"secs":226,"stamp":"2c057a7b0dfaeb50e7abfd3426a6253f","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64","v":1,"via":"run"} Client-Checks: {"checks":{"base":"0419d4a268c3fb3bcdbe3fbe3908b3f4d75e380c","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-output+.h.c","libobs/build/libobs.ported-service-info-accessors+.h.c","libobs/build/ported-source-sets/service-info-accessors.json","libobs/cmake/rust-hidden.d/obs-output-service_info_accessors.txt","libobs/obs-internal.h","libobs/obs-service-info-accessors-fields.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_service_info_accessors_swap_is_registered.rs","rust/obs-build/tests/native/registration/rust-static/cases/core-relinked/test_service_info_accessors_rust.json","rust/obs-c-oracle/oracle/service_getters.c","rust/obs-c-oracle/oracle/service_info_accessors.c","rust/obs-output/src/ffi/mod.rs","rust/obs-output/src/ffi/service.rs","rust/obs-output/src/ffi/service_info_accessors.rs","rust/obs-output/src/lib.rs","rust/obs-output/src/service_info_accessors.rs","rust/obs-output/tests/output/main.rs","rust/obs-output/tests/output/service_info_accessors.rs","rust/obs-output/tests/output/service_info_accessors_parity.rs","test/cmocka/build/test-graph.json","test/cmocka/service-info-accessors-link-support.c"],"head":"b6836b083a0c0580d8b61f1299df82adc729abcb","tools":{"orchestrator-python":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]","schema-dependencies":"3.13.16 (main, Oct 14 2026, 01:04:01) [Clang 23.1.3 ]\n{'jsonschema': '4.26.0', 'json_source_map': '1.0.5'}","uv":"uv 0.13.5 (x86_64-unknown-linux-gnu)","xmllint":"xmllint: using libxml version 21504-GITv2.15.4\n compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 DTDValid HTML C14N Catalog XPath XPointer XInclude Iconv ICU ISO8859X Regexps Automata RelaxNG Schemas Schematron Modules Debug Zlib"},"tracked-digest":"2ce93df4c3f0bacfe28ef4668d6453f74d3cacefa040757dbc4730018d4b0017","tree":"d2d75da3e018bba593063f9c8bf479e2dbdd9e64"}}
This was referenced Nov 21, 2026
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.
Refs #3840
Step 2 of my #3840 claim: swaps the four hidden service accessors that #5367 extracted and characterized (
obs_service_set_info,obs_service_set_plugin_data,obs_service_get_info_table,obs_service_get_plugin_data, declared inobs-internal.hwithoutEXPORT) into safe Rust in obs-output.set_inforeads the caller's table whole, then writes it over the service's own copy. A later change to the source never reaches the service, and a table copied onto itself stays as it was (the C struct assignment).get_info_tablereturns the borrowed address of the service's own copy, never the source.struct obs_servicestays in C behind one private field adapter,obs_service_info_accessors_fields()(libobs/obs-service-info-accessors-fields.c.h, declared inobs-internal.h, noEXPORT), which returns the addresses ofinfoandcontext.data. The original moves tolibobs.ported-service-info-accessors, which only the C reference builds. The four names go inrust-hidden.d, so they stay hidden as before. No intentional behavior differences. No public header, existing C test, obs-websocket code or workflow is changed. Not user-visible, so there is no features-ledger line.Consumers checked
obs-service-getters.c.h'sservice_info()/service_data()macros and the reference lifecycle) now resolve to the hidden Rust exports.rust/obs-output/src/ffi/service.rs) already called these names throughexterndeclarations. They now resolve to the same crate's definitions. Its imports are unchanged; only a doc comment changed.rust/obs-c-oracle/oracle/service_getters.chad its own copies of all four names. They would collide with the Rust exports inobs-tests-core, so they are gone. The service parity fixtures now go through the Rust shims and the real adapter, whichoracle/service_info_accessors.cdefines once. Itsset_info/set_datatrace events go with them. The lifecycle parity is unaffected because both sides call the same shim.test/cmocka/service-info-accessors-link-support.c(in the shared Rust-static support manifest) included the original. It now includes the field adapter, so a standalone Rust-static consumer that pulls the shims links the real C adapter.RED (0dd0a09)
Tier 1 (
tests/output/service_info_accessors.rs) mirrors every assertion oftest_service_info_accessors.con the safe core:Tier 3 (
tests/output/service_info_accessors_parity.rs) runs the extracted original and the shims on two services built from the same byte pattern, through the real adapter. It covers the characterized sequence and random set/get sequences (up to 24 operations, self-copy included). After every step it compares:It also checks the real-header layout (the adapter struct,
struct obs_service_infovsObsServiceInfo, the member addresses) and catches four mutants: a partial table copy, a dropped NULL, a wrong table address, and a NULL data read.The setters were stubs that wrote nothing:
The 2 passes are the layout/adapter check and the mutant check.
GREEN (42419a6)
The full
obs-tests-corerun under plaincargo test(one process, many threads) showsobs_core::canvas_valid_video_info_parityfailing with "8: it allocated". This happens with this PR's modules skipped too. That probe counts process-wide allocations, so other threads trip it. It passes alone (4/4) and under nextest's one-process-per-test, so it is not caused by this change.Tier 2
OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests service:To prove the cases ran rather than skipped, I ran the binaries from the kept build volume. On both
libobsandlibobs-c-reference,test_service_info_accessorsand its new twintest_service_info_accessors_rusteach ran 2 tests, and both passed. The hybridlibobs.soexports none of the four names or the adapter. The twin defines all five itself: the shims come from the Rust archive and the adapter from the support source.The unchanged
test_service_info_accessorskeeps testing the C source. The twin compiles the same fixture withOBS_SERVICE_INFO_ACCESSORS_RUST, so it takes the Rust shims instead. A registration test (canonical_service_info_accessors_swap_is_registered) pins:EXPORT;Other checks
uv run --no-project ci/windows_link_check.py: exit 0. All category binaries linked, and so did the Windows MSVC (win-x64) and Darwin (mac-arm64) hybrid libobs and every*_rustfixture, includingtest_service_info_accessors_rust. This only links; nothing was executed../lint: ok../push: client-lint (clippy and Dylint on all six targets) ok, client-test ok. The optional Swift lane is not available here, and the head is unsigned, so the regular PR checks run.Test cost: the 6 new tests take under 0.01 s together at
OBS_PARITY_CASES=reducedin the debug build. Peak memory for the module is 8 MB over 21 runs. They start no threads of their own.Tier 4 does not apply (no protocol). Not verified locally: native macOS and Windows runs (CI covers those).
🤖 Generated with Claude Code