Skip to content

obs-output: Port the output weak-handle lifetime (Refs #4778) - #4942

Merged
rdoupe merged 2 commits into
masterfrom
port/4778-weak-output
Nov 17, 2026
Merged

rdoupe merged 2 commits into
masterfrom
port/4778-weak-output

Conversation

@rdoupe

@rdoupe rdoupe commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #4778

Swaps the five output weak-handle functions extracted in #4824 (obs_weak_output_addref, obs_weak_output_release, obs_output_get_weak_output, obs_weak_output_get_output, obs_weak_output_references_output) to obs-output. The two commits are @zackees's from port/4778-weak-output-rust, rebased onto master with his authorship kept; the extraction half of that branch is already on master.

What changes

  • libobs/obs-output-weak-lifetime.c.h now builds only into the C reference (libobs.ported-output-weak-lifetime+.h.c); hybrid libobs takes the five symbols from obs-output.
  • The control lookup and the shared weak-ref atomics stay in C, in a small private adapter (libobs/obs-output-weak-lifetime-fields.c.h), so allocation (bfree) and the atomic counters are the ones libobs already uses. test/cmocka/output-weak-lifetime-link-support.c links that adapter into standalone consumers of the Rust archive.
  • Tier 1 mirrors of test/cmocka/test_output_weak_lifetime.c plus edge cases, and Tier 3 parity against the retained C (real-header layout, helper parity, characterized edges and final free).

No C test or public header is changed. Tier 4 does not apply (no protocol surface).

Evidence

RED (d9b32ff31, tests against panicking stubs):

soldr cargo test -p obs-data --test obs-tests-core -- output_weak_lifetime
test result: FAILED. 0 passed; 5 failed

GREEN (655ea8f4e):

soldr cargo test -p obs-data --test obs-tests-core -- output_weak_lifetime
test result: ok. 8 passed; 0 failed

Mutation checks on the GREEN head:

  • Freeing when the release is not final (&& !host.release(weak)): test_output_weak_lifetime_weak_ownership and ..._real_output_lifetime_policy fail, then the binary aborts with double free or corruption.
  • Inverting the identity check in references: output_weak_lifetime_parity::helpers_match_c and characterized_edges_and_final_free fail.

Local ./lint: ok. Local ./unittest on the head: rust-test ok; tier2-linux 949/949 passed on both hybrid libobs and the C reference, test_output_weak_lifetime passing on both.

🤖 Generated with Claude Code

Refs #4778. Mirror unchanged C weak-output ownership, promotion, identity and lifetime assertions in obs-tests-core. Safe core intentionally panics until the Rust swap.
Refs #4778. Replace only the extracted five helpers. Keep control access and shared atomic operations in a private C adapter, preserve bfree ownership, and link the real adapter into standalone Rust-static consumers. Add real-header layout and original-C differential coverage; identity inversion is detected by the differential edge test. Tier 4 does not apply to this local lifetime unit.

Ci-Attestation: {"at":1794880386,"gate":"data/all/compatibility","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":53,"stamp":"f00718fa01ab5006b3fd24ea384c180a","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880386,"gate":"data/all/flatpak-manifest","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":53,"stamp":"39a3ac5643786884021b110472093104","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880386,"gate":"data/all/qt-xml","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":53,"stamp":"6d975d94a080badc6abfd4d4d2d08c08","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880386,"gate":"data/all/services-schema","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":53,"stamp":"eebb4f65bac38fdd3342594ec4290d89","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"general/all/client-lint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"fe760d2be7562e50715f4e781ecd5e26","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880386,"gate":"python/all/self-test","host":"linux-x86_64","key":"","lane":"client-checks","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":53,"stamp":"074c8f214c9450c38ca11ccd46c5afdc","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/aarch64-apple-darwin/client-clippy","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"9864efb1224cec57c7a86cf9d78240d4","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/aarch64-apple-darwin/client-dylint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"4d5756248fb17dd587068582fb9a3d7f","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/aarch64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"d50bec4599de18f405797841cb94ac0a","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/aarch64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"b90521183914d2bd317e05f3d84ec7a1","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/aarch64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"a1ce80d720803e4cde25cf535b990a57","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/aarch64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"47134cd70c28d67454d9ba584fce8682","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/x86_64-apple-darwin/client-clippy","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"b6d85e95b20839f726cd18ca0c376256","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/x86_64-apple-darwin/client-dylint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"a366b08237635e30647d46c7a069a281","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/x86_64-pc-windows-msvc/client-clippy","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"7c76f02ff4e903254e998e1dd3eedbed","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/x86_64-pc-windows-msvc/client-dylint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"b05c8ff17e90541d8a34c9dfd949a429","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/x86_64-unknown-linux-gnu/client-clippy","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"44a50ec2573a3e86544c9fad09a14b52","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880332,"gate":"rust/x86_64-unknown-linux-gnu/client-dylint","host":"linux-x86_64","key":"88af175cf8413a93a1529eef888e8dfc5e571b51ba75e888bc81fc13087ad1df","lane":"client-lint","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":96,"stamp":"2583e65d7b0b7bf7a556e8fd88368268","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}
Ci-Attestation: {"at":1794880516,"gate":"rust/x86_64-unknown-linux-gnu/client-test","host":"linux-x86_64","key":"9c55c23e40c48d83176eab123b93a8280cd1402d9ce11cd43929fbdaecd1ea38","lane":"client-test-x86_64-unknown-linux-gnu","parents":["d9b32ff3163ca62522153382ce5911699cec1e76"],"secs":129,"stamp":"e2b12776fb1d26da4a64372356a095a3","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2","v":1,"via":"run"}

Client-Checks: {"checks":{"base":"aace99f022e7df01735d4fc3d8072e89b557631b","coverage":"all-tracked-applicable-files","diff":["libobs/build/libobs.core-output-weak-lifetime+.h.c","libobs/build/libobs.ported-output-weak-lifetime+.h.c","libobs/build/ported-source-sets/output-weak-lifetime.json","libobs/cmake/rust-exports.d/obs-output-output_weak_lifetime.txt","libobs/obs-internal.h","libobs/obs-output-weak-lifetime-fields.c.h","rust/README.md","rust/obs-c-oracle/oracle/output_weak_lifetime.c","rust/obs-output/src/ffi/mod.rs","rust/obs-output/src/ffi/output_weak_lifetime.rs","rust/obs-output/src/lib.rs","rust/obs-output/src/output_weak_lifetime.rs","rust/obs-output/tests/output/main.rs","rust/obs-output/tests/output/output_weak_lifetime.rs","rust/obs-output/tests/output/output_weak_lifetime_parity.rs","test/cmocka/output-weak-lifetime-link-support.c","test/cmocka/tests.d/output_weak_lifetime_link_support.cmake"],"head":"3a28c6a75588d943346ee2ba6087e2e2ef9f8002","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":"2750b52865161a6004fdbc56940a76fba3a6e3f665e5b1f7c9821828d4265430","tree":"fe4fbbdb1d759b3df2fba91ba477cc06b93bb9c2"}}
@rdoupe rdoupe changed the title obs-output: port weak output lifetime with preserved C atomics (GREEN) obs-output: Port the output weak-handle lifetime (Refs #4778) Nov 17, 2026
@rdoupe
rdoupe marked this pull request as ready for review November 17, 2026 03:20
@rdoupe
rdoupe requested a review from zackees as a code owner November 17, 2026 03:20
@rdoupe
rdoupe added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit e5522a3 Nov 17, 2026
43 checks passed
@rdoupe
rdoupe deleted the port/4778-weak-output branch November 17, 2026 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants