libtest runs each test on a thread with the default 2 MiB stack. In a debug
build, Device::new() materialises ~301 KiB of struct literals on the stack,
and postcard::from_bytes::<Device> rebuilds the whole value on the stack, so
any Device-constructing unit test (netplay savestate round trips etc.) peaks
at several times that and aborts the ENTIRE test binary with a stack
overflow, taking every other test down with it.
Fix, both layers:
- src/test_util.rs: with_big_stack() runs a test body on an explicitly sized
8 MiB thread (the budget the project already standardises on in
.cargo/config.toml). Regression test: a device serialise/restore/clone
round trip measured to overflow the 2 MiB libtest thread (SIGABRT) and
pass at 8 MiB, plus a size_of::<Device>() < 700 KiB tripwire.
- scripts/gate.sh: export RUST_MIN_STACK=8388608 around step 3 so the
documented gate also covers Device-constructing tests that are not yet
wrapped (the netplay cluster's !15/!18 tests land after this fix).
Verified: cargo test --lib bare (no env) -> 1 passed; full gate -> GATE_OK
with step 3 reporting 1 passed (was 0 on main).
Review findings addressed (PR #17 bounce):
1. gate.sh put the provisioned cmake/ninja on PATH but never added their
OWN lib root to LD_LIBRARY_PATH, so cmake died with exit 127
(librhash.so.0 / libuv.so.1 / libjsoncpp.so.25 not found) and cmake-rs
misreported 'is cmake not installed?'. The LLVM_BIN2 block now exports
LD_LIBRARY_PATH=~/local-tools/root/usr/lib/x86_64-linux-gnu (same
append pattern as the other two roots; final value carries all three).
2. The gate was compile-only. It now runs three steps: cargo check
--all-targets (type-check), cargo test --no-run (LINK every test
binary), cargo test --lib (EXECUTE headless lib unit tests).
3. docs/build-gate.md: prerequisites list the provisioned cmake's
shared-lib root, the test-execution decision record, and the new
troubleshooting entry.
Verified on the review box: cold full gate exits 0 (GATE_OK), step 1
check then 11m52s test-link codegen then 'running 0 tests / ok' (main has
no #[test] fns yet; the inbound netplay PRs add ~38); warm re-run 5.6s.
Two blockers fixed in .cargo/config.toml plus a documented gate script:
- target-cpu=x86-64-v3 (AVX2-only) is now opt-in — the default build is
portable; on Sandy Bridge (x86-64-v2) it miscompiled build scripts
(num-traits SIGABRT, 648518346341351440-byte allocation).
- AR=llvm-ar dropped (GNU ar is fine); CC=clang/CXX=clang++ retained
because build.rs needs clang for -flto=thin, resolved via PATH.
scripts/gate.sh records the review-box command: init submodules, wire the
user-local LLVM-18 / pkgconf / fontconfig-X11 roots (no sudo available),
then cargo check --all-targets. docs/build-gate.md explains the failure
modes. Verified: ./scripts/gate.sh exits 0 end-to-end on this box.