Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions changelog.d/8316-native-stack-scan-windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Fixed

- **`perry-runtime` failed to compile for `*-pc-windows-msvc`.**
`gc::native_stack_scan::resolve_symbol` reached `libc::dladdr` and
`libc::Dl_info` unconditionally. Both are POSIX-only, so the crate did not
build on Windows at all — which is why the `native-roots-rs4gc
(windows-latest, x86-64, PE)` arm of `gc-native-roots` failed in its **build**
step rather than in a probe, taking `gc-native-roots-complete` red with it.

The two `pthread_get_stack*_np` calls in the same file were already inside a
`#[cfg(target_os = "macos")]` block; `resolve_symbol` was the only unguarded
POSIX use. It is now `#[cfg(unix)]`, with a `#[cfg(not(unix))]` arm that
reports the bare address. The scan is a debug-only diagnostic
(`PERRY_GC_SCAN_NATIVE_STACK=1`), so the non-POSIX arm degrades symbolication
instead of pulling in a platform symbolizer.

`resolve_symbol`'s callers live in the ungated `run_native_stack_scan`, so the
new arm is reachable on Windows and does not trip `dead_code` under
`-D warnings` — the failure mode of #8306, where a fix applied to only one
host's `cfg` arm could not be seen by the macOS lint run.
14 changes: 14 additions & 0 deletions crates/perry-runtime/src/gc/native_stack_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ fn walk_frame_pointers() -> Vec<FrameInfo> {
}

/// Resolve a code address to a symbol name using `dladdr`.
///
/// `dladdr`/`Dl_info` are POSIX-only. They were reached unconditionally, so
/// `perry-runtime` failed to COMPILE for `*-pc-windows-msvc` — which is why the
/// `native-roots-rs4gc (windows-latest)` arm of `gc-native-roots` died in its
/// build step rather than in a probe. This diagnostic is debug-only
/// (`PERRY_GC_SCAN_NATIVE_STACK=1`), so the non-POSIX arm degrades to the bare
/// address rather than pulling in a platform symbolizer.
#[cfg(unix)]
fn resolve_symbol(addr: usize) -> String {
unsafe {
let mut info: libc::Dl_info = std::mem::zeroed();
Expand All @@ -311,6 +319,12 @@ fn resolve_symbol(addr: usize) -> String {
}
}

/// No `dladdr` off POSIX: report the bare address.
#[cfg(not(unix))]
fn resolve_symbol(addr: usize) -> String {
format!("0x{addr:x} (symbolication unavailable on this target)")
}

#[derive(Clone, Copy)]
struct StaleStackSlot {
stack_addr: usize,
Expand Down
Loading