-
-
Notifications
You must be signed in to change notification settings - Fork 151
gc: decode ELF stack maps, and make the compact-map refusal say why (#7321) #7331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+660
−77
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fcc0d2c
gc: name the reason a stack map could not be compacted (#7321)
196baf1
gc: decode ELF stack maps (.word/.hword/.xword) and verify the re-encode
4f3b72e
ci: widen the x86-64 statepoint diagnostic to every probe
f4b2f5e
changelog: 7331 ELF stack-map word width
68bbbaa
gc: match the x86 arch family on the triple's arch field, not a prefix
ea7b489
gc: record why the aarch64 base-tag naming is not #7321's cause
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| The compact-map rewriter could not read the stack maps **ELF** backends emit, | ||
| because `.word` is not a fixed size. | ||
|
|
||
| LLVM chooses each field's spelling per target through | ||
| `MCAsmInfo::Data32bitsDirective`, and the AArch64 **ELF** backend chooses | ||
| `.word`. GNU `as` defines `.word` as the target's natural machine word — 4 bytes | ||
| on AArch64, ARM, PowerPC, MIPS, SPARC and RISC-V, but **2 on x86**. The rewriter | ||
| carried one fixed table (`".long" | ".word" => 4`) written against the | ||
| Mach-O/AArch64 spelling it was developed on, so an `aarch64-unknown-linux-gnu` | ||
| map — where every 32-bit field is `.word`, every 16-bit field `.hword` and every | ||
| 64-bit field `.xword` — was read at the wrong widths. The width is load-bearing | ||
| for the whole block: two bytes of drift per field relocates every root after it. | ||
|
|
||
| `.word` is now resolved against the target, and the other spellings an | ||
| `MCAsmInfo` can pick (`.1byte`/`.2byte`/`.4byte`/`.8byte`/`.dc.*`) are handled. | ||
|
|
||
| A directive inside the block whose width is not modelled is now a **refusal that | ||
| names it**, rather than being skipped. Skipping was the unsound branch: the | ||
| block is decoded by structural offset, so one ignored directive that emits bytes | ||
| shifts everything after it, and the decode then either fails somewhere unrelated | ||
| or succeeds against the wrong bytes. Naming it is what turned an opaque refusal | ||
| into a one-line diagnosis. | ||
|
|
||
| Every refusal now carries a reason — which directive, which record, which byte | ||
| offset, whether the per-function record counts disagreed with the header — and | ||
| the target. Previously every parse failure collapsed to `None`, so the message | ||
| could only repeat that it had failed, which is why #7321 took an issue to | ||
| localise. | ||
|
|
||
| The re-encode is now verified against the map it came from, on every target: | ||
| `verify_roundtrip` decodes the emitted varint stream exactly as | ||
| `perry-runtime`'s `parse_gc_map` does and asserts it reproduces every record's | ||
| live set. Unlike `PERRY_STACKMAP_WALKER=verify` this needs no | ||
| architecture-specific stack walker, so it holds where that check cannot run, and | ||
| it is sabotage-tested (dropped root, relocated root, truncation, trailing bytes) | ||
| so a pass means the detector works rather than that nothing was tried. | ||
|
|
||
| Also fixes an aarch64-ELF link failure the above uncovered: `eh_walker`'s | ||
| `global_asm!` defined `perry_eh_capture_context` / `perry_eh_install_context` | ||
| with Mach-O's leading underscore unconditionally under | ||
| `target_arch = "aarch64"`, so on aarch64 ELF the definitions and the | ||
| `extern "C"` declarations were different symbols and `perry-runtime` could not | ||
| link at all. | ||
|
|
||
| This does **not** yet close #7321. The defect is an ELF defect but specifically | ||
| an AArch64-ELF one; x86 ELF spells these fields `.byte`/`.short`/`.long`/`.quad`, | ||
| which the old table already handled, and the x86-64 refusal could not be | ||
| reproduced under Apple clang 21, Homebrew clang 19/20/22 or Ubuntu clang 18, | ||
| across twelve `-march` settings, from either host, over all nine probes. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Make
x86-diagnosea checked fan-in arm.gc-native-roots-completedoes not depend onx86-diagnose. A diagnostic-job failure can therefore leave the documented required context green.The loop also has no final assertion that it matched a probe and captured a refused stack-map block. Track both counts and fail when either count is zero. Add
x86-diagnoseto the fan-inneedslist and result checks.Proposed fix
As per coding guidelines, “A CI gate must … assert that the behavior it measures actually executed.”
🤖 Prompt for AI Agents
Source: Coding guidelines