Fix stackwalking handling of FP on Wasm in R2R code#130010
Open
davidwrighton wants to merge 3 commits into
Open
Fix stackwalking handling of FP on Wasm in R2R code#130010davidwrighton wants to merge 3 commits into
davidwrighton wants to merge 3 commits into
Conversation
Add setting of the various InstructionSets so that R2R code is used Adjust CLRTest.CrossGen.targets to specify the JitWasmNyi flags so that tests generally pass
Contributor
There was a problem hiding this comment.
Pull request overview
Updates CoreCLR Wasm stack unwinding / stackwalking to reliably recover and propagate a frame pointer in R2R scenarios, and adjusts test CrossGen2 invocation to treat certain Wasm NYIs as R2R-unsupported so the existing test suite can run with Wasm R2R enabled.
Changes:
- Populate
InterpreterFPfrom the current stack pointer for Wasm stackwalking (transition frames + unwind paths + software exception frames). - Mark Wasm instruction sets as available for compilation so R2R code paths are selected.
- Add Wasm-specific CrossGen2
--codegenoptflags in CLRTest script generation to reduce NYI-related test failures.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tests/Common/CLRTest.CrossGen.targets | Adds Wasm-only CrossGen2 --codegenopt flags to treat NYIs as R2R-unsupported during test compilation. |
| src/coreclr/vm/wasm/helpers.cpp | Recovers and sets InterpreterFP in transition frame regdisplay updates; also propagates FP during virtual unwind. |
| src/coreclr/vm/excep.cpp | Sets InterpreterFP for Wasm SoftwareExceptionFrame from the transition block stack pointer. |
| src/coreclr/vm/codeman.cpp | Sets Wasm instruction set flags in EEJitManager::SetCpuInfo to enable R2R selection/usage. |
Comment on lines
529
to
533
| pRD->pCurrentContext->InterpreterIP = GetReturnAddress(); | ||
| pRD->pCurrentContext->InterpreterSP = GetSP(); | ||
| // Recover the frame pointer so GC-info readers can locate frame slots. | ||
| pRD->pCurrentContext->InterpreterFP = GetWasmFramePointerFromStackPointer(GetSP()); | ||
|
|
AndyAyersMS
approved these changes
Jun 30, 2026
The R2R FP stackwalking change started decoding the frame pointer from TransitionFrame::GetSP() unconditionally. For transitions out of interpreted code GetSP() returns the address just past the TransitionBlock (the outgoing argument area) rather than a real R2R stack pointer, so feeding it into GetWasmFramePointerFromStackPointer followed a garbage chained pointer and trapped with 'memory access out of bounds' during exception dispatch. Only decode InterpreterFP when the TransitionBlock records a trusted R2R stack pointer (both m_ReturnAddress and m_StackPointer set), mirroring the trusted-SP condition in TransitionFrame::GetSP. Otherwise leave it 0, which restores the previous safe behavior for interpreter transitions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tsAndAssociatedIssues
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This fixes the behavior of Generic Context lookups (and thus pairs with the JIT changes in #130000 to fix some tests)
Add setting of the various InstructionSets so that R2R code is used
Adjust CLRTest.CrossGen.targets to specify the JitWasmNyi flags so that tests generally pass