Repository navigation
[Interpreter] Install the resume-after-catch handler in ThrowControlForThread - #135533
Draft
pcshrosbree wants to merge 2 commits into
Draft
pcshrosbree wants to merge 2 commits into
pcshrosbree wants to merge 2 commits into
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli |
pcshrosbree
force-pushed
the
interp-abort-throw-control
branch
from
October 16, 2026 19:44
45a66f6 to
bc3b55a
Compare
This was referenced Oct 16, 2026
Closed
When compiled code raises a thread abort again at the end of a catch handler and an interpreted frame catches it, the ResumeAfterCatchException that resumes that frame ran into the managed frames ThrowControlForThread was redirected from. Install the handler there, as IL_Throw and HandleManagedFault do. On Windows x64 with shadow stacks, the frame of a redirected thread was interrupted rather than stopped at a call and its recorded SSP is exact, so tell the rethrow not to search for a more precise one. Enable ControlledExecutionTests.CancelItselfOutsideOfTryCatchFinally again and add the scenario to the GitHub_135463 regression test. Fixes dotnet#135532
The previous commit enables this test again. Since dotnet#135915 removed the class-level IsMultithreadingSupported condition from ControlledExecutionTests, the test now also runs on single-threaded browser-wasm CoreCLR. There, with the default ReadyToRun CoreLib, an action that cancels itself still leaves the abort pending at the end of CancellationTokenSource's ReadyToRun catch (dotnet#135914). Checked runtimes assert there. Skip the test on browser CoreCLR until dotnet#135914 is fixed.
pcshrosbree
force-pushed
the
interp-abort-throw-control
branch
from
October 19, 2026 21:44
bc3b55a to
5b1e6ec
Compare
This was referenced Oct 20, 2026
This branch has not been deployed
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.
Fixes #135532.
Rebased onto main now that #135939 is in. The first commit is the fix. The second skips
CancelItselfOutsideOfTryCatchFinallyon browser CoreCLR. Since #135915 removed the class-level multithreading requirement fromControlledExecutionTests, this test would otherwise also run on single-threaded browser-wasm, where #135914 still applies. The PR stays a draft until CI has run on the rebased commits.When compiled code raises a thread abort again at the end of a catch handler, it does so through
ThrowControlForThread. Before this change, when an interpreted frame further up caught the abort, theResumeAfterCatchExceptionused to resume that frame encountered the managed frames present when the thread was redirected. NowThrowControlForThreadinstalls the resume-after-catch handler, likeIL_ThrowandHandleManagedFault.On Windows x64 with shadow stacks, the handler's rethrow searched for a "precise" SSP on the assumption that the slot below the SSP holds a return address in the context's frame. A redirected thread's frame was interrupted rather than stopped at a call, and its recorded SSP is exact already, so the search moved it past the correct position. The new
INSTALL_RESUME_AFTER_CATCH_HANDLER_WITH_INTERRUPTED_CONTEXTmarks the context as interrupted, so thatRethrowResumeAfterCatchExceptionSkipManagedFramesuses the recorded SSP without searching for another one. The same mismatch caused #135530, fixed by #135531.Tests: a
CancelItselfscenario insrc/tests/Regressions/coreclr/GitHub_135463(the action cancels its own token), andControlledExecutionTests.CancelItselfOutsideOfTryCatchFinallyenabled again, except on browser CoreCLR.The new scenario was tested before the rebase, with this PR stacked on #135939's head (Checked builds; linux-x64, osx-arm64, windows-x64 with CET enabled). The rebase applied without conflicts and did not change the first commit's diff.
DOTNET_InterpMode=1, with and withoutTieredCompilation=0ResumeAfterCatchException; windows: assertDOTNET_InterpMode2 and 3Additional validation, on the same builds:
TieredCompilation=0,JITMinOpts,JitStress1 and 2,ReadyToRun=0, andGCStress0x3 and 0xC on all three platforms. ItsTestEnclosingTryis skipped under the JIT, as in [Interpreter] Raise a pending thread abort again at the resume point after a catch #135939.ControlledExecutionTestspass when run as a class in one process, andCancelItselfOutsideOfTryCatchFinallyalso passes when run alone in its own process. Both runs pass on all three platforms under the JIT andDOTNET_InterpMode1, 2 and 3.CancelItselfOutsideOfTryCatchFinallyfails under mode 1: it terminates withResumeAfterCatchExceptionon linux-x64 and osx-arm64, and fails a Checked consistency check on windows-x64.*(ULONG64*)targetSSP == pContext->RipinExecuteFunctionBelowContext.Note
This PR was prepared with AI assistance (Anthropic Claude, checked by OpenAI Codex) at my request. I reviewed it before posting it.