Skip to content

rust: Port libobs/util/pipe.c + pipe-posix.c to obs-util (Phase 4 #5) - #78

Merged
zackees merged 7 commits into
obs-rust:masterfrom
chriscoveries:rust/pipe-port
Oct 10, 2026
Merged

zackees merged 7 commits into
obs-rust:masterfrom
chriscoveries:rust/pipe-port

Conversation

@chriscoveries

Copy link
Copy Markdown
Contributor

RED first: Tier 1 port of test/cmocka/test_pipe.c against todo!() stubs (15 tests, all failing). GREEN to follow: safe core, thin shim, oracle wrapper, Tier 3 parity, ENABLE_RUST_LIBOBS guard, rust-exports.txt.

Refs #44

@zackees
zackees marked this pull request as ready for review October 10, 2026 16:45
@zackees

zackees commented Oct 10, 2026

Copy link
Copy Markdown
Member

Maintainer fixup: rebased on master (resolved obs-c-oracle/build.rs conflict with the dstr/utf8 oracle sources); oracle/pipe_posix.c now defines GNU_SOURCE (GCC 14 + -std=c11 hid fdopen, so the oracle failed to build). Windows: pipe-windows.c stays C, but rust.cmake would have /EXPORTed the cfg(unix) os_process_pipe* shims, duplicating its dllexport symbols under the /WX linker. rust-exports.txt now marks those lines unix, rust.cmake skips them on Windows, and a new export_list test checks the markers match the cfg(unix) shims (RED: markers {} vs 6 pipe shims, then GREEN). Original RED commit confirmed failing (todo!), head passes Tier 1/3; local gate (lint, rust-test, tier2-linux OFF/ON with test_pipe) passed and is stamped.

@zackees
zackees force-pushed the rust/pipe-port branch 5 times, most recently from e8ff82d to bf2c8e9 Compare October 10, 2026 18:31
@zackees

zackees commented Oct 10, 2026

Copy link
Copy Markdown
Member

Rebased onto master after #59 (dstr, utf8 and bmem ports) and #105. Added b-commit 'Use the renamed dstr_vprintf in the pipe oracle': pipe_parity failed to link because the oracle's C-only dstr helpers are now named oracle_*. RED→GREEN, checked with soldr's cache disabled: pipe fails 15/15 at the RED commit; export_list fails 1/2 at e08b78a and passes 2/2 at e54944b; at head all tests pass. The local gate passes and is stamped.

chriscoveries and others added 7 commits October 10, 2026 12:29
Mirror every test_pipe.c assertion (args order, argf formatting,
verbatim spacing, read/write modes, exit codes incl. the (char)255
quirk, missing binary, null command) against todo!() stubs in the new
safe core rust/obs-util/src/pipe.rs. All 15 tests fail.

Refs #44
Safe core in rust/obs-util/src/pipe.rs with a thin C ABI shim: an
owned null-terminated Args vector, and Unix process pipes spawned
through std::process::Command with CLOEXEC fds, an always-captured
stderr, streams closed before reap, and the exit status cast through
the platform char (255 becomes -1 where char is signed). A signaled
child destroys to its pid, mirroring the waitpid fallthrough in C.

Stable Rust cannot define the variadic os_process_args_add_argf, so
util/pipe-variadic.c (ON-only, like base-variadic.c) formats with
vsnprintf and stores through the add_arg shim. The process shims are
Unix-only; pipe-windows.c stays in C. Both handles are opaque, so no
layout test is needed.

Tier 3 in rust/obs-util/tests/pipe_parity.rs covers random argv
(incl. NUL truncation), add_argf with real varargs on the oracle side,
a command table with stdout/stderr/exit codes, create2, signaled
children (pid on both sides), dead-pipe writes (short count where
SIGPIPE is ignored; identical death under a C main), write
round-trips and chunked reads (concatenation only: scheduling owns
chunk boundaries). Dereferencing null args or a null command is C UB
and excluded; the shim stays null-safe. Mutating the read/write mode
check fails 4 parity tests, and breaking the signaled path fails the
signaled test. Unchanged test_pipe.c passes OFF and ON (Tier 2 log
to follow).

Refs #44
GCC 14 under -std=c11 hides fdopen, which broke the oracle build.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Windows keeps pipe-windows.c, so /EXPORT of the Rust pipe shims would
duplicate its dllexport symbols under the /WX linker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=121b0db4736fe22d036cea846dc7f66700e3a2a7 secs=15 lanes=lint:reused@286dc9998712,rust-test:reused@303f1f352d39,tier2-linux:run
Ci-Attestation: {"at":1791650888,"gate":"rust/all/fmt","host":"linux-x86_64","key":"286dc99987129d898f3cf2ef8b9959a49a3e150baeb5e253405c82e34c3df115","lane":"lint","parents":["befb21294ca9f9bc5fbd5008b8d02446d0aa2939"],"secs":null,"stamp":"addb5827f362fc62dda345dc3cfd2a88","tree":"121b0db4736fe22d036cea846dc7f66700e3a2a7","v":1,"via":"reused"}
Ci-Attestation: {"at":1791650888,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"286dc99987129d898f3cf2ef8b9959a49a3e150baeb5e253405c82e34c3df115","lane":"lint","parents":["befb21294ca9f9bc5fbd5008b8d02446d0aa2939"],"secs":null,"stamp":"fab492cd403d9b552ad4c6103b267a61","tree":"121b0db4736fe22d036cea846dc7f66700e3a2a7","v":1,"via":"reused"}
Ci-Attestation: {"at":1791650888,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"303f1f352d39be6f23a75b71fece4687683d7d2714ec002b6d7d9a51bb94883a","lane":"rust-test","parents":["befb21294ca9f9bc5fbd5008b8d02446d0aa2939"],"secs":null,"stamp":"69b772a9d15420e79b2d0f70feeee2c3","tree":"121b0db4736fe22d036cea846dc7f66700e3a2a7","v":1,"via":"reused"}
Ci-Attestation: {"at":1791651218,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"eff44df3cc81802d2a5b3942e83b7fea7b8754c3d0347e67c06f03b493dc504a","lane":"tier2-linux","parents":["befb21294ca9f9bc5fbd5008b8d02446d0aa2939"],"secs":14,"stamp":"0cf329e5460e40c8cca2abb5b4e9d5d4","tree":"121b0db4736fe22d036cea846dc7f66700e3a2a7","v":1,"via":"run"}
Windows clippy -D warnings failed on the unused imports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=25a723b3ab929c35bafcdfdfeda44b9e93b4939a secs=88 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791657080,"gate":"rust/all/fmt","host":"linux-x86_64","key":"73dae3ab6255247b125896bab439fa43b1fa1605e3b6bc6f2f1491665abc0722","lane":"lint","parents":["35b2cf42d627d57444f26bd91577130fe7b85e56"],"secs":22,"stamp":"20fb426068ca5d22fab71809fe3d7e04","tree":"25a723b3ab929c35bafcdfdfeda44b9e93b4939a","v":1,"via":"run"}
Ci-Attestation: {"at":1791657080,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"73dae3ab6255247b125896bab439fa43b1fa1605e3b6bc6f2f1491665abc0722","lane":"lint","parents":["35b2cf42d627d57444f26bd91577130fe7b85e56"],"secs":22,"stamp":"d36baa50eec285105d2bfb2f60c64f87","tree":"25a723b3ab929c35bafcdfdfeda44b9e93b4939a","v":1,"via":"run"}
Ci-Attestation: {"at":1791657080,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"2b3a5b281db9dddf1618778fe77ec527dfe47ae65d26ffac7ab9e2daea616aff","lane":"rust-test","parents":["35b2cf42d627d57444f26bd91577130fe7b85e56"],"secs":32,"stamp":"bce056ad3cbb66d073519eaa3cf61ede","tree":"25a723b3ab929c35bafcdfdfeda44b9e93b4939a","v":1,"via":"run"}
Ci-Attestation: {"at":1791657080,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"0cc01c1e60a70c54b19a21d07baa13bf014a206aa2a37fdb540e2e316cb2a3c1","lane":"tier2-linux","parents":["35b2cf42d627d57444f26bd91577130fe7b85e56"],"secs":34,"stamp":"89a5f5f55055aea443579808dc2ab545","tree":"25a723b3ab929c35bafcdfdfeda44b9e93b4939a","v":1,"via":"run"}
Since #59 landed the dstr port, the oracle's C-only dstr helpers are
renamed to oracle_* in dstr_libc.c, so pipe.c's call to dstr_vprintf no
longer resolved and pipe_parity failed to link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=1feca72c20789abbb89791580cdb0d6d746091d3 secs=127 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791660722,"gate":"rust/all/fmt","host":"linux-x86_64","key":"7e33d005d800274406aabfad568fc4355c94ef47e5e2a0415f628b093bc2b22c","lane":"lint","parents":["fd9ed9e4393a492bf351521c5cf1610ec7cd8860"],"secs":47,"stamp":"3d357aa2dcd3cef0c6b8800e44d6edb9","tree":"1feca72c20789abbb89791580cdb0d6d746091d3","v":1,"via":"run"}
Ci-Attestation: {"at":1791660722,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"7e33d005d800274406aabfad568fc4355c94ef47e5e2a0415f628b093bc2b22c","lane":"lint","parents":["fd9ed9e4393a492bf351521c5cf1610ec7cd8860"],"secs":47,"stamp":"c8254164df53398d569267971606c58e","tree":"1feca72c20789abbb89791580cdb0d6d746091d3","v":1,"via":"run"}
Ci-Attestation: {"at":1791660722,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"a81df521538d00f57f5e1c8d90b5c8a52408e5e21ee642b48ea6fab80291c43b","lane":"rust-test","parents":["fd9ed9e4393a492bf351521c5cf1610ec7cd8860"],"secs":27,"stamp":"1e5dad10cdf39dc0c658a566bdf9f6e6","tree":"1feca72c20789abbb89791580cdb0d6d746091d3","v":1,"via":"run"}
Ci-Attestation: {"at":1791660722,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"4a64da498f9cbfdb9fe79abbf81555054cecef871ad36e5165bd1ca9f9b82ed8","lane":"tier2-linux","parents":["fd9ed9e4393a492bf351521c5cf1610ec7cd8860"],"secs":53,"stamp":"1da11ade13b263bb075da985be911b60","tree":"1feca72c20789abbb89791580cdb0d6d746091d3","v":1,"via":"run"}
@zackees
zackees merged commit b6172a7 into obs-rust:master Oct 10, 2026
22 checks passed
swilk19 pushed a commit to swilk19/obs-studio that referenced this pull request Oct 10, 2026
Both are swapped out by ENABLE_RUST_LIBOBS (obs-rust#77, obs-rust#78) but had no row in
rust/README.md. The intentional differences come from their parity test
headers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Local-Gate: v1 tree=9bf357cc9b333ab587a9ef1a12a03c5e10401b49 secs=104 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791675815,"gate":"rust/all/fmt","host":"linux-x86_64","key":"8cf5e62ed81a4c59ed6b7033b8f8cbbf74d28306dd3a4d4626d241aabd83034a","lane":"lint","parents":["faaca71086cff4fed3c2d807d98cb98e8e109ab4"],"secs":18,"stamp":"f54bd4c098026f1f9d10d31c1973d641","tree":"9bf357cc9b333ab587a9ef1a12a03c5e10401b49","v":1,"via":"run"}
Ci-Attestation: {"at":1791675815,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"8cf5e62ed81a4c59ed6b7033b8f8cbbf74d28306dd3a4d4626d241aabd83034a","lane":"lint","parents":["faaca71086cff4fed3c2d807d98cb98e8e109ab4"],"secs":18,"stamp":"988410300c630644864eb4e5a8cae506","tree":"9bf357cc9b333ab587a9ef1a12a03c5e10401b49","v":1,"via":"run"}
Ci-Attestation: {"at":1791675815,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"41470548073c550943aa7b8d49f8768c2ca95be8f542e5c4b5ae60065d9c2dca","lane":"rust-test","parents":["faaca71086cff4fed3c2d807d98cb98e8e109ab4"],"secs":35,"stamp":"dc126abfc792a7b5644da0cf8bd58b2e","tree":"9bf357cc9b333ab587a9ef1a12a03c5e10401b49","v":1,"via":"run"}
Ci-Attestation: {"at":1791675815,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"ad50e2b36bd04a0536651de9bb040dca4d14bcb9e40d429d60ecfe1683cd071d","lane":"tier2-linux","parents":["faaca71086cff4fed3c2d807d98cb98e8e109ab4"],"secs":51,"stamp":"862b2575f5f1a0e16f41950eccc711bb","tree":"9bf357cc9b333ab587a9ef1a12a03c5e10401b49","v":1,"via":"run"}
@chriscoveries
chriscoveries deleted the rust/pipe-port branch October 11, 2026 02:18
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