[wasm][coreclr] Fix unhandled exceptions#121817
Merged
radekdoulik merged 5 commits intodotnet:mainfrom Nov 25, 2025
Merged
Conversation
Developed with Jan Vorlicek Make sure the return address is set in transition block when going through `ExecuteInterpretedMethodWithArgs`, so that `SfiNextWorker` gets the address. Fill missing pieces around context. Fix few asserts and offsets. Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Member
Author
|
Example output of |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes unhandled exception handling in the WebAssembly (WASM) implementation of CoreCLR. The primary goal is to ensure proper stack walking by setting return addresses in transition blocks and implementing missing context handling functionality for WASM.
Key changes:
- Added
callerIpparameter throughout the call chain to track return addresses for proper stack unwinding - Implemented
TransitionFrame::UpdateRegDisplay_Implto populate register display during stack walks - Fixed WASM context accessor functions to use interpreter fields instead of asserting/failing
- Corrected offset constants for WASM's CONTEXT structure fields
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/wasm/helpers.cpp | Implemented TransitionFrame::UpdateRegDisplay_Impl to set InterpreterIP/SP and initialized CallDescrWorkerInternalReturnAddressOffset |
| src/coreclr/vm/wasm/callhelpers-reverse.cpp | Added callerIp parameter to ExecuteInterpretedMethodFromUnmanaged calls |
| src/coreclr/vm/wasm/calldescrworkerwasm.cpp | Added callerIp parameter to ExecuteInterpretedMethodWithArgs call |
| src/coreclr/vm/prestub.cpp | Updated function signatures and implementation to accept and use callerIp parameter |
| src/coreclr/vm/interpexec.h | Updated function declaration to include callerIp parameter |
| src/coreclr/vm/exceptionhandling.cpp | Added WASM-specific path to call PropagateExceptionThroughNativeFrames directly |
| src/coreclr/pal/src/include/pal/context.h | Implemented CONTEXTGetPC, CONTEXTSetPC, and CONTEXTGetFP for WASM using interpreter fields |
| src/coreclr/pal/src/exception/seh-unwind.cpp | Added conditional compilation to skip context capture for WASM |
| src/coreclr/pal/src/arch/wasm/stubs.cpp | Fixed assert syntax and changed RtlCaptureContext to zero memory instead of asserting |
| src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/AsmOffsets.cs | Corrected offset values for InterpreterIP and InterpreterFP and added static assertions |
jkotas
reviewed
Nov 19, 2025
src/coreclr/System.Private.CoreLib/src/System/Runtime/ExceptionServices/AsmOffsets.cs
Outdated
Show resolved
Hide resolved
AaronRobinsonMSFT
approved these changes
Nov 24, 2025
Member
AaronRobinsonMSFT
left a comment
There was a problem hiding this comment.
This all looks okay to me. I'm deferring to @radekdoulik and @janvorli that the logic and updates are appropriate.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Developed with Jan Vorlicek
Make sure the return address is set in transition block when going through
ExecuteInterpretedMethodWithArgs, so thatSfiNextWorkergets the address.Fill missing pieces around context.
Fix few asserts and offsets.