fix(link): #5892 — keep perry_ffi test shims out of production ext archives#5911
Conversation
…chives perry-ext-http and perry-ext-http-server compiled their test_async_shims modules (synchronous perry_ffi_* stand-ins for unit-test linking) into the production staticlib archives: the mod declaration was missing the #[cfg(test)] gate that perry-ext-net already has. The shims' own comment says 'Test-only; never shipped.' — but they shipped. Those shims define the same #[no_mangle] C symbols as perry-stdlib's real perry-ffi async bridge, with catastrophically different semantics: perry_ffi_spawn_blocking_with_reactor/spawn_blocking run the closure inline (no runtime context, no pump/wait-driver registration) and perry_ffi_spawn_async is a no-op that silently drops the task. Whenever the linker resolves these from an ext archive instead of libperry_stdlib.a (single-pass archive scanning: the reference and the shim live in the same archive), the #5831 current-thread runtime is never driven: the wait-driver never registers, js_wait_for_event falls back to the 1 s condvar park, and any program with in-process server+client I/O parks forever. This is the cargo-test hang in issue_4903_listen_callback_deferred (#5892) that has blocked nightlies and release tags since #5831 merged; the auto-opt path was immune because strip-dedup (#5000/#5685) localizes duplicate wrapper globals. Gate both modules with #[cfg(test)], matching perry-ext-net. Validation on the hang-lab branch (debug/5892-hang-lab): ungated cargo-test loop hung on iteration 1 in three consecutive runs; with the gate, single-run repro + 6/6 cargo-test iterations clean (run 28669296187).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds ChangesTest compilation gating
Estimated code review effort: 1 (Trivial) | ~2 minutes Related issues: None of the changes address the linked issue ( Suggested labels: trivial, chore Suggested reviewers: None required given the trivial scope of this change. 🐰 A whisker-thin change, so small and neat, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Final lab results (runs 28669296187, 28671098729): with archives built by the lab's combined |
Fixes #5892.
Root cause
perry-ext-httpandperry-ext-http-servership theirtest_async_shimsmodules in production archives — themoddeclaration is missing the#[cfg(test)]gate that perry-ext-net already has. The shims define the same#[no_mangle]C symbols as perry-stdlib's real perry-ffi async bridge with catastrophically different semantics:perry_ffi_spawn_blocking_with_reactor/perry_ffi_spawn_blocking→ run the closure inline: no runtime context, noensure_pump_registered(), so the runtime: JS-loop-driven current-thread async runtime + wait-driver with gated fast-native-drive (supersedes #5779) #5831 wait-driver never registersperry_ffi_spawn_async→ no-op that silently drops the taskWhen the linker resolves these from an ext archive instead of
libperry_stdlib.a(single-pass archive scan; the referencing member and the shim member sit in the same archive), the current-thread runtime is never driven:js_wait_for_eventfalls back to the 1 s condvar park and any in-process server+client program parks forever. The auto-opt compile path is immune because strip-dedup (#5000/#5685) localizes duplicate wrapper globals — which is why only the cargo-test/debug-driver path hangs.Evidence (hang-lab,
debug/5892-hang-labbranch)Impact
Unblocks: nightly full-workspace cargo-test (red since ~Jun 21 from this + the pre-#5831 write_end flake family), release-tag Tests gates, and restores real async dispatch semantics to any natively-compiled binary whose link picked the shims (
spawn_asyncdropping tasks silently is not test-only behavior anyone wants in the field).Summary by CodeRabbit