Skip to content

Redo resume after catch for interpreter via native EH#129433

Merged
janvorli merged 2 commits into
dotnet:mainfrom
janvorli:redo-resume-after-catch-via-native-eh
Jun 16, 2026
Merged

Redo resume after catch for interpreter via native EH#129433
janvorli merged 2 commits into
dotnet:mainfrom
janvorli:redo-resume-after-catch-via-native-eh

Conversation

@janvorli

@janvorli janvorli commented Jun 15, 2026

Copy link
Copy Markdown
Member

This change redoes the reverted change and adds fix for the problem that
we were hitting in the ControlledExecutionTests.

The problem was that when we call DispatchManagedException from the ProcessCLRException, the added (correct) popping of frames removed frame that GC would use as a starting point. So if GC happened, it would skip a bunch of managed frames and cause the issue that the ControlledExecutionTests would hit.

Before my previously reverted change, there were explicit frames that were stale, but still sufficient for providing GC with a starting point.

The proper fix is to keep the explicit frames removal, but add ResumableFrame pointing to the managed frame for which the ProcessCLRException was called. That will enable GC to properly start walking stack.

Close #129270

janvorli added 2 commits June 15, 2026 15:01
This change redoes the reverted change and adds fix for the problem that
we were hitting in the ControlledExecutionTests.

Close dotnet#129270
@janvorli janvorli self-assigned this Jun 15, 2026
Copilot AI review requested due to automatic review settings June 15, 2026 17:46
@janvorli janvorli requested a review from BrzVlad as a code owner June 15, 2026 17:46
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reintroduces “resume after catch” support for the CoreCLR interpreter by routing it through native exception handling across native↔managed boundaries, addressing the fatal AccessViolation failures seen in System.Runtime.Tests.ControlledExecutionTests.

Changes:

  • Adds/threads a ResumeAfterCatchException handling layer at multiple native↔managed boundaries (QCall, prestub, virtual dispatch stubs, alloc/throw helpers, P/Invoke import worker, etc.).
  • Simplifies interpreter ResumeAfterCatch to throw a marker exception and adds logic to rethrow it from an appropriate native context (skipping managed frames) for correct resumption.
  • Cleans up interpreter frame plumbing (removes saved SP field/uses, adds defensive m_Next != NULL checks) and aligns UM entry prestub unwind metadata (NoHandler).

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/coreclr/vm/wasm/helpers.cpp Adds defensive null-check when detecting/using the next interpreter frame.
src/coreclr/vm/virtualcallstub.cpp Installs/uninstalls resume-after-catch handling around stub dispatch workers.
src/coreclr/vm/threadsuspend.cpp Adds resume-after-catch handling to suspension/dispatch path.
src/coreclr/vm/threads.cpp Adds resume-after-catch handling around interpreter context initialization; relaxes throwable-handle assumptions.
src/coreclr/vm/riscv64/asmhelpers.S Switches UM entry prestub unwind handler annotation to NoHandler.
src/coreclr/vm/qcall.h Wraps QCall boundary in resume-after-catch handler.
src/coreclr/vm/prestub.cpp Wraps prestub worker + interpreted entry execution with resume-after-catch handling; adjusts exception catch behavior.
src/coreclr/vm/loongarch64/asmhelpers.S Switches UM entry prestub unwind handler annotation to NoHandler.
src/coreclr/vm/jithelpers.cpp Adds resume-after-catch handling for throw/rethrow helpers and patchpoint helpers.
src/coreclr/vm/interpexec.h Removes now-stale comment tied to deleted “lowest SP” tracking.
src/coreclr/vm/interpexec.cpp Removes lowest-SP tracking; adds resume context plumbing + rethrow workaround path for resume-after-catch.
src/coreclr/vm/i386/umthunkstub.S Switches UM entry prestub unwind handler annotation to NoHandler.
src/coreclr/vm/gchelpers.cpp Wraps GC allocation helpers and failed-allocation helper with resume-after-catch handling.
src/coreclr/vm/frames.h Removes interpreter-frame saved SP storage (no longer used).
src/coreclr/vm/frames.cpp Removes dependency on interpreter saved SP when updating FP registers; adds null check in interpreter detection.
src/coreclr/vm/exceptmacros.h Introduces resume-after-catch install/uninstall macros used across the VM.
src/coreclr/vm/exceptionhandling.h Declares resume-after-catch rethrow helper for skipping managed frames.
src/coreclr/vm/exceptionhandling.cpp Adds resume-after-catch handling to managed exception dispatch paths; implements rethrow helpers; adds SSP assert in context execution helper.
src/coreclr/vm/excep.cpp Adds resume-after-catch handling for managed-fault path; removes old resume-after-catch unwind helper.
src/coreclr/vm/eetwain.cpp Simplifies interpreter ResumeAfterCatch to just throw the marker exception.
src/coreclr/vm/dllimport.cpp Wraps P/Invoke import worker and calli IL-stub generation with resume-after-catch handling.
src/coreclr/vm/arm64/stubs.cpp Adds defensive null-check when detecting/using the next interpreter frame.
src/coreclr/vm/arm64/asmhelpers.S Switches UM entry prestub unwind handler annotation to NoHandler.
src/coreclr/vm/amd64/umthunkstub.S Switches UM entry prestub unwind handler annotation to NoHandler.
src/coreclr/vm/amd64/cgenamd64.cpp Adds defensive null-check when detecting/using the next interpreter frame.

Comment thread src/coreclr/vm/exceptmacros.h
Comment thread src/coreclr/vm/exceptmacros.h
Comment thread src/coreclr/vm/exceptmacros.h
Comment thread src/coreclr/vm/exceptmacros.h
@janvorli janvorli requested a review from jkotas June 15, 2026 18:07

@jkotas jkotas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@janvorli

Copy link
Copy Markdown
Member Author

/ba-g there are many WASM failures that seem to be happening on multiple PRs.

@janvorli janvorli merged commit 4b211ba into dotnet:main Jun 16, 2026
133 of 141 checks passed
@janvorli janvorli deleted the redo-resume-after-catch-via-native-eh branch June 16, 2026 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System.Runtime.Tests.ControlledExecutionTests failing with fatal error

3 participants