fix(runtime): unify the three pthread stack-bounds extern declarations - #9776
fix(runtime): unify the three pthread stack-bounds extern declarations#9776proggeramlug wants to merge 2 commits into
Conversation
`perry-runtime` declared `pthread_getattr_np`, `pthread_attr_getstack` and
`pthread_attr_destroy` in three separate `extern "C"` blocks using two
different argument spellings. Declaring one symbol twice in a crate with
different signatures is `clashing_extern_declarations`, which `-D warnings`
denies, so the `warnings` job could not compile the crate at all:
error: `pthread_getattr_np` redeclared with a different signature
--> crates/perry-runtime/src/gc/roots.rs:761:9
::: crates/perry-runtime/src/error_stack_frames.rs:200:13
= note: expected `unsafe extern "C" fn(usize, *mut u8) -> i32`
found `unsafe extern "C" fn(usize, *mut [u64; 8]) -> i32`
= note: `-D clashing-extern-declarations` implied by `-D warnings`
error: could not compile `perry-runtime` (lib) due to 3 previous errors
`gc::roots::get_stack_bottom` has spelled the attr buffer `[u64; 8]` since
long before the break. The competing `*mut u8` spelling also predates it, in
`gc::roots::stack_maps::fp_chain`, but that module is gated to
`target_arch = "aarch64"`, so on CI's linux-x86_64 host the two never met.
1ebc65e (PerryTS#9486/PerryTS#9521) added a third copy in `error_stack_frames.rs` gated
only on `target_os = "linux"`; with no arch gate it collides with
`gc/roots.rs` on x86_64, and the crate stopped compiling under `-D warnings`.
All three blocks now use the `[u64; 8]` spelling, which additionally clears
the latent aarch64-linux collision between `fp_chain` and `gc/roots.rs`.
`[u64; 8]` is 64 bytes — at least the size of `pthread_attr_t` on every
supported glibc/musl target, and correctly aligned for it, which the
`[u8; 128]` buffer it replaces was not.
Unbreaks the `warnings` job on
https://github.com/PerryTS/perry/actions/runs/33926006467
Claude-Session: https://claude.ai/code/session_01YPfnmWZmSpSWpmnoXvH8z2
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe Linux pthread declarations now use a consistent ChangesLinux pthread stack binding updates
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change unifies Linux pthread stack-discovery bindings, restoring warning-free compilation and removing inconsistent extern declarations. No merge-blocking production risk is identified. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
|
Conflicts with merge train #9798, which just landed 19 PRs (including #9750's rework of |
|
Superseded — closing. This PR unifies the three pthread stack-bounds |
The break
maincannot compileperry-runtimeunder-D warnings, so thewarningsjob onhttps://github.com/PerryTS/perry/actions/runs/33926006467 (main at
12efed12220e) failswith
build failed, waiting for other jobs to finish:Same for
pthread_attr_getstackandpthread_attr_destroy.Root cause
perry-runtimedeclares these three libc functions in three separateextern "C"blocks, in two different spellings:
gc/roots.rs:757get_stack_bottom[u64; 8]target_os = "linux"gc/roots/stack_maps.rs:1788fp_chain::stack_top*mut u8target_os = "linux"andtarget_arch = "aarch64"error_stack_frames.rs:197stack_top_uncached*mut u8target_os = "linux"(no arch gate)The
*mut u8spelling is not new — but the only site that used it was insidemod fp_chain, which is gated totarget_arch = "aarch64". On CI's linux-x86_64host that module is
cfg'd out, so the two spellings never met and the lint never fired.Culprit:
1ebc65e87— "feat(runtime): real function names in Error stacks — frame-pointerwalk + the existing name registry (#9486) (#9521)" (2026-09-02). It added a third copy of
the block in
error_stack_frames.rsgated only ontarget_os = "linux". With no arch gateit collides with
gc/roots.rson x86_64, and the crate stopped compiling under-D warnings.This is macOS-invisible: every declaration involved is behind
cfg(target_os = "linux").The fix
All three blocks now use the
[u64; 8]spelling thatgc::roots::get_stack_bottom— theoldest and most-shipped of the three — has always used. This also clears the latent
aarch64-linux collision between
fp_chainandgc/roots.rs, which would have broken thattarget the moment anyone built it with
-D warnings.[u64; 8]is 64 bytes: at least the size ofpthread_attr_ton every supported glibc/musltarget (56 bytes on both), and correctly aligned for it — which the
[u8; 128]buffer itreplaces, with alignment 1, was not. No behavioural change otherwise; all three functions
compute the same stack-high address they did before.
Verification
redeclared with a different signatureerrors under-D warnings; unified,rustcexits 0.
RUSTFLAGS="-D warnings" cargo check -p perry-runtime --all-targetson a linux-x86_64host reproduces the 3 errors at
12efed12220eand passes with this commit.Not fixed here
mainis red for four further, independent reasons — none of them this compile error, andnone of them fixed by this PR. Detailed separately:
check— API-docs drift:Bun.connect/Bun.listenwere added to the API manifest by868787448("feat(bun): add TCP socket facades") without re-runningscripts/regen_api_docs.sh.ext-link(red since 2026-09-04) —js_bun_tcp_listencallsperry_ffi::run_pending,and
crates/perry-ext-http/src/test_async_shims.rshas noperry_ffi_run_pendingstub.Same culprit commit
868787448.cargo-test—commands::compile::build_cache::tests::codegen_env_vars_are_build_cache_inputs.gc-stress matrix (4/4)/gap-suite (2)— output mismatches intest_gap_repsel_gc_stress,test_gap_perfhooks_3088_3008_3010_3011andtest_gap_prop_plan_cache_invalidation.gc-stressandmain-gateare aggregator jobs (14s / 3s) and go green once theirdependencies do.
https://claude.ai/code/session_01YPfnmWZmSpSWpmnoXvH8z2
Summary by CodeRabbit