Fix WASM exception propagation through native runtime#122908
Merged
janvorli merged 1 commit intodotnet:mainfrom Jan 6, 2026
Merged
Fix WASM exception propagation through native runtime#122908janvorli merged 1 commit intodotnet:mainfrom
janvorli merged 1 commit intodotnet:mainfrom
Conversation
This change fixes propagating managed exceptions into native frames on WASM. It ensures that the exception is ignored in the `UNINSTALL_MANAGED_EXCEPTION_DISPATCHER_EX` until it reaches the target frame. This is necessary because we cannot unwind the stack up to the target frame on WASM unlike other platforms.
Contributor
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes managed exception propagation through native runtime frames on WebAssembly (WASM). Since WASM lacks native stack unwinding support (unlike other platforms), the exception must continue propagating until it reaches the designated target frame. The fix adds target frame tracking to the exception object and modifies the exception dispatcher to check if the current frame is the target before catching the exception.
Key changes:
- Added target frame SP tracking to ensure exceptions propagate to the correct frame on WASM
- Removed obsolete
IsFirstPass()andSecondPassDone()methods from thePAL_SEHExceptionclass - Cleaned up exception handling macros by removing calls to the removed methods
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/vm/exceptmacros.h | Modified exception dispatcher macro to check target frame SP and conditionally rethrow exceptions that haven't reached their target frame |
| src/coreclr/vm/exceptionhandling.cpp | Updated call to PropagateExceptionThroughNativeFrames to pass the target SP for WASM platform |
| src/coreclr/vm/excep.h | Added default parameter targetSP = 0 to PropagateExceptionThroughNativeFrames function signature |
| src/coreclr/vm/excep.cpp | Implemented WASM-specific exception propagation logic with SetTargetFrame helper and PAL_TRY/PAL_EXCEPT block to set target frame SP |
| src/coreclr/pal/inc/pal.h | Added HasTargetFrame() helper method and removed obsolete IsFirstPass() and SecondPassDone() methods along with their usage in exception macros |
pavelsavara
reviewed
Jan 6, 2026
pavelsavara
approved these changes
Jan 6, 2026
Member
|
This PR fixes #122462 right ? |
Member
Author
Right |
This was referenced Jan 9, 2026
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.
This change fixes propagating managed exceptions into native frames on WASM. It ensures that the exception is ignored in the
UNINSTALL_MANAGED_EXCEPTION_DISPATCHER_EXuntil it reaches the target frame. This is necessary because we cannot unwind the stack up to the target frame on WASM unlike other platforms.I have also removed some obsolete bits from the
PAL_SEHExceptionclass.Close #122462