Skip to content

obs-output: swap output name getter to safe Rust (Refs #5302) - #5358

Queued
rdoupe wants to merge 2 commits into
masterfrom
port/5302-output-get-name
Queued

rdoupe wants to merge 2 commits into
masterfrom
port/5302-output-get-name

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #5302

obs_output_get_name now runs as safe Rust in the hybrid libobs. After obs_output_valid()'s exact NULL diagnostic (LOG_DEBUG, "%s: Null '%s' parameter", obs_output_get_name, output), it returns the output's borrowed context.name pointer, read once through a new private adapter, obs_output_get_name_context_name() (libobs/obs-output-get-name-fields.c.h). Nothing is copied, cached, referenced or locked; NULL, empty and non-UTF-8 names come back unchanged. The original moves whole into libobs.ported-output-get-name, which only the C reference builds.

The interleaver now names its output through a private seam, obs_output_interleave_output_name(), the same way #5257 handled its encoders. Without it, the interleaver's synthetic test fixture and the port comparison bench would define the public symbol a second time. The bench stand-in moves to the seam, and ci/test_bench_libobs_stand_ins.py says why.

Public headers, existing C tests and OBS WebSocket are unchanged.

Tests

  • Tier 1 (rust/obs-output/tests/output/output_get_name.rs) mirrors every case of the unchanged test_output_get_name.c: the NULL diagnostic with nothing read, the borrowed pointer read silently and repeatedly, a generated __unnamed name, the current slot after it changes, and exactly one projection.
  • Tier 3 (output_get_name_parity.rs, oracle rust/obs-c-oracle/oracle/output_get_name.c) runs the extracted original and the shim on one real-layout output. It compares pointer identity, the exact NULL log fields and untouched output bytes, checks that the adapter addresses the original's field, and runs randomized names. Four mutants are caught: a silent NULL, the wrong function name in the log, NULL for a live output, and a cached name.
  • Tier 2: the unchanged C tests run against both builds.
  • Registration: canonical_output_get_name_swap_is_registered covers the ported group, the hybrid group, the Rust-static support manifest and the export list.

Evidence

RED (test: mirror output name getter characterization): the safe getter is a stub that neither logs nor projects.

soldr cargo test -p obs-data --test obs-tests-core -- output::output_get_name
test result: FAILED. 1 passed; 7 failed

(The one pass is the mutant test, which only needs the oracle.)

GREEN (obs-output: swap output name getter to safe Rust):

soldr cargo test -p obs-data --test obs-tests-core -- output::output_get_name output::interleave
test result: ok. 73 passed; 0 failed
soldr cargo test -p obs-data --test obs-tests-core -- output::
test result: ok. 1397 passed; 0 failed
soldr cargo test -p obs-studio-rust --test obs-tests-app -- canonical_output_get
test result: ok. 2 passed; 0 failed
uv run ci/test_bench_libobs_stand_ins.py
OK
./lint
== lane lint: ok

Tier 2 (OBS_CTEST_JOBS=10 uv run rust/tools/linux-validate/run.py --repeat 1 --tests "test_output_get_name|test_context_names|test_hotkey_unregister|test_encoder_error_stop|test_output_get_last_error|test_output_interleave|test_rtmp_send_thread_leak|test_rtmp_dbr_user_bitrate|test_rtmps_cert_no_fallback|test_output_mixer"), symbol diff included:

== [OFF] ctest                 (C reference)  100% tests passed, 0 tests failed out of 1055
== [OFF] ctest --repeat ... -R <above>        100% tests passed, 0 tests failed out of 14
== [ON] ctest                  (hybrid)       100% tests passed, 0 tests failed out of 1055
== [ON] ctest --repeat ... -R <above>         100% tests passed, 0 tests failed out of 14

No intentional differences. Tier 4 does not apply: this is a borrowed-pointer getter with no protocol surface.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner November 20, 2026 07:46
@rdoupe
rdoupe added this pull request to the merge queue Nov 20, 2026
Any commits made after this event will not be merged.
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 20, 2026
rdoupe and others added 2 commits November 20, 2026 03:34
Tier 1 mirrors every case of the unchanged test_output_get_name.c on the
safe getter: the NULL diagnostic with nothing read, the borrowed
context-name pointer read silently and repeatedly, a generated name, and
the current slot after it changes. Tier 3 runs the extracted original and
the shim on one real-layout output through the new private context-name
adapter, compares pointer identity, the exact obs_output_valid() log and
untouched output bytes, and shows four mutants caught.

The interleaver now names its output through a private seam,
obs_output_interleave_output_name(), as it already does for its encoders,
so its synthetic fixture stops defining the public getter the port will
export. The bench stand-in moves to the seam with it.

The safe getter is a stub that neither logs nor projects:

    soldr cargo test -p obs-data --test obs-tests-core -- output::output_get_name
    test result: FAILED. 1 passed; 7 failed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After obs_output_valid()'s exact NULL diagnostic, the safe getter
returns the output's borrowed context.name pointer, read once through the
private obs_output_get_name_context_name() adapter: no copy, cache,
reference or lock, and NULL, empty and non-UTF-8 names come back
unchanged.

The adapter joins the shared Rust-static support manifest (#5246) as a
lazy member, so a standalone Rust-static fixture that pulls the getter
links its real C.

The original moves whole into libobs.ported-output-get-name, which only
the C reference builds; the hybrid core-output group drops it and the
Rust symbol is exported in its place.

    soldr cargo test -p obs-data --test obs-tests-core -- output::output_get_name output::interleave
    test result: ok. 73 passed; 0 failed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Ci-Attestation: {"at":1795166687,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":94,"stamp":"a80aa6ab8d996bc123f554c816ec497c","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166687,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":94,"stamp":"a115f5a822a05ef893f0f8b1863d6d2b","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166687,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":94,"stamp":"8c7435bb1dbd749e91e1bfc62124b445","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166687,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":94,"stamp":"558b808c91263b94add310ba8b9b4c11","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"general/all/client-lint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"1fe2f1b5ccf360d9937e69aaedec0cad","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166687,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":94,"stamp":"8b3b31f71efc515f5bfc0595fae27a7a","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"861025b77b3edd97871f2ab615bb8278","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"e7a6d27997dfee6bfe38814acab7064d","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"ea4dadf615000282424a556f5c960f53","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"4da888ef5a62ff5a7217e28b45950ea1","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"ab2db4ab59cdacf6279f670a0a15fe4c","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"d1a0b2a9860e02da1e5a9e79e90c6ef0","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"d676da58ee4022a420c729467541492f","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"0946882b9546b7a0632a89628c9e8ebb","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"1acb66375a62177b5869d3acc4bcca19","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"f99405bdb82a30c9034319561d9045f5","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"9a16934117276256560f02fec20d885f","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166592,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"b4936cf2492adbc414968395857f60001822732a50d0695e3a053c4452b843a3","lane":"client-lint","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":85,"stamp":"35f41ca5770ac83667b680a54debf5fc","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}
Ci-Attestation: {"at":1795166829,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"3189028b6269f043b306f36cdfa6f1f983790dcbf787a12a08a4802f70e68c42","lane":"client-test-x86_64-unknown-linux-gnu","parents":["79fa2cf6f1d94651e9a2f80e0be439df2ebd9162"],"secs":142,"stamp":"58be6e03e0c66814aace0a739d0e73da","tree":"5434f3e5899983aba9359904776346e92b9d5e3e","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"52ccd8385b7bbdd7451bfd314112f4339073ae6b","coverage":"all-tracked-applicable-files","diff":["ci/test_bench_libobs_stand_ins.py","libobs/build/libobs.core-output+.h.c","libobs/build/libobs.ported-output-get-name+.h.c","libobs/build/ported-source-sets/output-get-name.json","libobs/cmake/rust-exports.d/obs-output-output_get_name.txt","libobs/obs-output-get-name-fields.c.h","libobs/obs-output-interleave-name-fields.c.h","rust/README.md","rust/obs-build/tests/native.rs","rust/obs-build/tests/native/registration/canonical_output_get_name_swap_is_registered.rs","rust/obs-c-oracle/benches/port_comparison.rs","rust/obs-c-oracle/oracle/output_get_name.c","rust/obs-c-oracle/oracle/output_interleave.c","rust/obs-output/src/ffi/mod.rs","rust/obs-output/src/ffi/output_get_name.rs","rust/obs-output/src/ffi/output_interleave.rs","rust/obs-output/src/lib.rs","rust/obs-output/src/output_get_name.rs","rust/obs-output/tests/output/interleave_parity.rs","rust/obs-output/tests/output/main.rs","rust/obs-output/tests/output/output_get_name.rs","rust/obs-output/tests/output/output_get_name_parity.rs","test/cmocka/build/rust-static-support.json","test/cmocka/output-get-name-link-support.c"],"head":"d895a94575f63d98398ed97449fafc809f51d492","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":"1f6e59232f513163ea691e0d7beb76aa794c7ae740a77f76bd48ba6374578f25","tree":"5434f3e5899983aba9359904776346e92b9d5e3e"}}
@rdoupe
rdoupe force-pushed the port/5302-output-get-name branch from da46951 to cda5c92 Compare November 20, 2026 09:27
@rdoupe
rdoupe enabled auto-merge November 20, 2026 09:27
@rdoupe
rdoupe added this pull request to the merge queue Nov 20, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant