Repository navigation
obs-c-oracle: Compile platform.c instead of host copies - #1094
Conversation
|
Merge queue triage: the queue dropped this PR at 19:53 UTC. Your branch is not at fault. #978 merged at 17:32, after this PR's CI ran. It groups each crate's Fix: rebase onto |
9f2504a to
e5f4b89
Compare
|
Maintainer push: I've made the binary-cap fix on your branch so this can merge. I rebased onto master ( Checked locally:
I'll queue it once CI is green. |
e5f4b89 to
b1b857c
Compare
|
Second maintainer push: the merge queue failed this PR in Fast Gate with I rebased onto master ( Checked locally: |
|
Part one of the speed up refactor has gone in. C code is amalgamated and relies on one single PCH Part two, going in now, is rust optimization:
You are going to have to rebase, but it's worth it! |
b1b857c to
aabf644
Compare
aabf644 to
fb63a70
Compare
|
Third maintainer push, correcting my first one. Moving In the RED commit I moved it to Checked locally: |
Since obs-rust#1094 the dstr-libc oracle took os_utf8_to_wcs_ptr and os_mbs_to_utf8_ptr from oracle/platform.c, which allocates with oracle_bmalloc, while dstr-libc.c frees the wide string with bfree and keeps the UTF-8 string as a dstr's array, both obs-util's allocator. Every oracle_dstr_to_upper/to_lower freed an oracle_bmalloc block with bfree: the counters drift apart (-4 / +4 after util's dstr/to_upper benches in --test mode) and the two allocators are only compatible by accident. Define the two helpers in oracle/dstr_libc.c as their util/platform-conversions.c.h bodies around oracle/platform.c's conversions, allocating with bmalloc. A full port_comparison --test run now completes. Fixes obs-rust#2154
…#2159) * obs-c-oracle: Check each port_comparison module frees its fixtures util's bmem/count pair compares obs-util's bnum_allocs() with the C bmem oracle's counter, so any earlier module whose fixtures allocate through the shared bmalloc and don't free it fails that pair instead (obs-rust#2154: 16 vs 0 on a full run). comparisons() now runs each module through module(), which checks both counters are where they were before the module ran, so a leak names its module. On master it fails at source_profiler: 16 Rust-side allocations live. The module list becomes a sorted modules![...] list, one per line, and ci/test_sorted_shared_lists.py reads it there. Refs obs-rust#2154 * obs-c-oracle: Free the source profiler bench's sources source_profiler's bench made its 16 C sources with oracle_sp_source_new(), a bzalloc through obs-util's shared bmalloc, and left them live. They were the 16 Rust-side allocations that made util's bmem/count pair (16 vs 0) panic on a full port_comparison run. Free them with oracle_sp_source_free() after the closing oracle_sp_reset(), which has already dropped the profiler's entries for them. Refs obs-rust#2154 * obs-c-oracle: Allocate dstr-libc's conversions with the libobs bmalloc Since obs-rust#1094 the dstr-libc oracle took os_utf8_to_wcs_ptr and os_mbs_to_utf8_ptr from oracle/platform.c, which allocates with oracle_bmalloc, while dstr-libc.c frees the wide string with bfree and keeps the UTF-8 string as a dstr's array, both obs-util's allocator. Every oracle_dstr_to_upper/to_lower freed an oracle_bmalloc block with bfree: the counters drift apart (-4 / +4 after util's dstr/to_upper benches in --test mode) and the two allocators are only compatible by accident. Define the two helpers in oracle/dstr_libc.c as their util/platform-conversions.c.h bodies around oracle/platform.c's conversions, allocating with bmalloc. A full port_comparison --test run now completes. Fixes obs-rust#2154
Problem
The Rust C oracle used for parity tests had empty breakpoint and OOM stand-ins plus copied platform helpers. Tests could therefore agree with the oracle while the corresponding libobs C path behaved differently. This change addresses the
util/platform.chelpers and the breakpoint/OOM test behavior; it does not complete the broader stand-in audit tracked in #145. Refs #145.Root cause
At tested upstream base
fb3910360f8b165c2d8ded0819bc59455fe9b3d8,rust/obs-c-oracle/oracle/test_stubs.c:18-40defines empty weakos_breakpointandos_oomhandlers. The zero-size and allocation-failure paths inlibobs/util/bmem.c:101-134call these handlers. The weak handlers return without printing the expected marker or raising theSIGTRAPused by libobs;bmem.cthen reachesbcrash, so the child still terminates but the RED tests fail because the marker is absent. Hand-copied platform helpers in the oracle can also drift fromutil/platform.c.Fix
Compile the real
util/platform.cin the oracle with its exports renamed tooracle_*, route oracle calls to those symbols, and remove the copied helpers. Test-only breakpoint and OOM handlers print a marker and abort so forked tests can observe those paths. Windows plain-name forwarders preserve the Rust FFI symbols while calling the renamed C implementations.For MinGW cross-link builds, which exclude
platform-windows.c, link-only stubs provide the remaining oracle symbols that source would otherwise define. The Windows behavioral oracle tests are MSVC-only.Keeping the helper copies would retain the drift risk; linking unrenamed exports would collide with the Rust implementation in parity tests.
Evidence
Tested base: upstream
fb3910360f8b165c2d8ded0819bc59455fe9b3d8.03febcf1a076d4e7de873bf5418ac01237b0fda9(tree identical to tested RED4c32e7a409af81111daaf4f0ee1b49edc3c3a6fb): fork Pull run 38888966646 failedobs-util --test platform_oracleas intended. Three cases failed because the child did not print the expected marker:oracle_bmalloc_zero_dies_loudly,oracle_brealloc_zero_dies_loudly, andoracle_bmalloc_oom_dies_loudly. Output:test result: FAILED. 2 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.19s. The child still terminated in thebmem.cerror path; RED caught the missing marker. The run was cancelled after this focused result to stop unrelated platform builds.9f2504a3fa8acd561843ef7dad0dbccca5b6e139(tree identical to tested GREEN4b8346044defe5dcb97975dfa947533b5a3b48c9): in exact-head fork Pull run 38898555908,platform_oracle.rsreportedtest result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s. The full CI run passed on this exact head (27 jobs succeeded, 0 failed, 3 skipped).uv run python -m unittest ci/test_oracle_standins.py(2 tests).git merge-tree --write-tree upstream/master HEADagainst upstream2dae7366609405b552965e428b926dfc61394591exited successfully and returnedca0f50dc63a8f4474611759041398f4c41e520c5.Compatibility & risk
No public API or ABI changes. The change is confined to test infrastructure: the C oracle and its helpers, Rust regression tests, and the stand-in drift checker. The fork-based regression tests run on Unix; Pull CI also checks supported platform builds, including the Windows FFI links.
Status
Ready for review.
How this was tested
obs-util --test platform_oraclefails on linear-history RED03febcf1a076d4e7de873bf5418ac01237b0fda9and passes on linear-history GREEN9f2504a3fa8acd561843ef7dad0dbccca5b6e139; their trees are identical to the commits used for the cited RED/GREEN runs. No local Cargo test was run.9f2504a3fa8acd561843ef7dad0dbccca5b6e139(27 jobs succeeded, 0 failed, 3 skipped).Thank you to the obs-rust maintainers and contributors for building this project in the open. In the American spirit of free expression and individual independence, and with the principle of judging contributions on their merit alone, this PR is a small piece of what independent people can build when they come together.