Skip to content

Conversation

@jkotas
Copy link
Member

@jkotas jkotas commented Jan 28, 2026

Reverts #123307

Copilot AI review requested due to automatic review settings January 28, 2026 01:41
@jkotas
Copy link
Member Author

jkotas commented Jan 28, 2026

@am11 @janvorli This is causing crashed all over the place, and it does not look like we have a fix ready. We should revert.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reverts #123307 by backing out the prior “new unwind plan” changes around JIT helpers / patchpoints, returning several helpers to older prolog/epilog and unwind mechanisms.

Changes:

  • Remove non-AMD64 ClrRestoreNonvolatileContextWorker implementations and their asm constants on ARM64/LoongArch64/RISC-V64.
  • Rework JIT_PatchpointWorkerWorkerWithPolicy to capture context + unwind via RtlCaptureContext/virtual unwind instead of building context from TransitionBlock.
  • Simplify marked JIT-helper detection/unwind logic and add interpreter-only resume-after-catch unwind entrypoint.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/coreclr/vm/threads.cpp Restricts ClrRestoreNonvolatileContextWorker usage to TARGET_AMD64 and falls back to RtlRestoreContext elsewhere.
src/coreclr/vm/riscv64/asmhelpers.S Removes ClrRestoreNonvolatileContextWorker; minor comment adjustment in JIT_Patchpoint.
src/coreclr/vm/riscv64/asmconstants.h Removes CONTEXT offset/flag constants that supported the removed restore worker.
src/coreclr/vm/loongarch64/asmhelpers.S Removes ClrRestoreNonvolatileContextWorker; minor comment adjustment in JIT_Patchpoint.
src/coreclr/vm/loongarch64/asmconstants.h Removes CONTEXT offset/flag constants that supported the removed restore worker.
src/coreclr/vm/jithelpers.cpp Reworks OSR patchpoint context capture/unwind and stack/frame restoration logic.
src/coreclr/vm/frames.h Removes OSR TransitionBlock-to-CONTEXT helper declaration.
src/coreclr/vm/exceptmacros.h Adds interpreter-only UnwindAndContinueResumeAfterCatch prototype.
src/coreclr/vm/excep.cpp Refactors marked JIT helper detection; updates unwind path; adds interpreter resume-after-catch implementation; adjusts TransitionBlock layout comment/offset.
src/coreclr/vm/arm64/asmmacros.h Removes POP_COOP_PINVOKE_FRAME_WITH_FLOATS_RETURN macro.
src/coreclr/vm/arm64/asmhelpers.asm Removes ClrRestoreNonvolatileContextWorker; minor comment adjustment in JIT_Patchpoint.
src/coreclr/vm/arm64/asmhelpers.S Removes ClrRestoreNonvolatileContextWorker; minor comment adjustment in JIT_Patchpoint.
src/coreclr/vm/arm64/asmconstants.h Removes CONTEXT offset/flag constants that supported the removed restore worker.
src/coreclr/vm/amd64/AsmMacros.inc Changes PUSH_COOP_PINVOKE_FRAME_WITH_FLOATS layout/size and removes the corresponding “return” epilog macro.
src/coreclr/vm/amd64/AsmHelpers.asm Switches JIT_Patchpoint to PROLOG_WITH_TRANSITION_BLOCK/EPILOG_WITH_TRANSITION_BLOCK_RETURN.
src/coreclr/pal/inc/unixasmmacrosriscv64.inc Removes POP_COOP_PINVOKE_FRAME_WITH_FLOATS_RETURN macro.
src/coreclr/pal/inc/unixasmmacrosloongarch64.inc Removes POP_COOP_PINVOKE_FRAME_WITH_FLOATS_RETURN macro.
src/coreclr/pal/inc/unixasmmacrosarm64.inc Removes POP_COOP_PINVOKE_FRAME_WITH_FLOATS_RETURN macro.

Comment on lines +1672 to +1675
// Remember original method FP and SP because new method will inherit them.
UINT_PTR currentSP = GetSP(pFrameContext);
UINT_PTR currentFP = GetFP(pFrameContext);

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

currentFP is captured from the original managed frame, but it is only written back into the context on TARGET_AMD64 (pFrameContext->Rbp = currentFP). On other architectures (e.g., ARM64/LoongArch64/RISC-V64) the context is left with the FP value produced by the unwind to the caller frame, which can break OSR since the OSR method is supposed to inherit the original method’s frame pointer. Consider restoring the frame pointer for all architectures (e.g., via the existing SetFP helper or per-arch FP field) after the caller unwind, in the same way SP is restored.

Copilot uses AI. Check for mistakes.
Comment on lines +5485 to 5486
#define CHECK_RANGE(name) \
if (GetEEFuncEntryPoint(name) <= uControlPc && uControlPc < GetEEFuncEntryPoint(name##_End)) return true;
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

CHECK_RANGE is defined as a preprocessor macro inside IsIPInMarkedJitHelper but never undefined. Because macros are file-scoped, this leaks the macro name into the rest of excep.cpp and can cause collisions or surprising substitutions later. Add a corresponding #undef CHECK_RANGE after the last use (before leaving the #ifndef FEATURE_PORTABLE_HELPERS block).

Copilot uses AI. Check for mistakes.
Comment on lines +5635 to +5639
PCODE ControlPCPostAdjustment = GetIP(pContext) - STACKWALK_CONTROLPC_ADJUST_OFFSET;

// Now we save the address back into the context so that it gets used
// as the faulting address.
SetIP(pContext, ControlPCPostAdjustment);
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The indentation of this block is inconsistent with surrounding code (these lines are indented less than the surrounding #if body), which makes the control flow harder to scan. Re-indent to match the prevailing indentation in this function.

Copilot uses AI. Check for mistakes.
@janvorli
Copy link
Member

Makes sense, let's revert and bring it back once the issue is sorted out.

@am11
Copy link
Member

am11 commented Jan 28, 2026

Fine by me. There is no clear repro. That DotnetFuzzing is also not reproducing it for me (that app doesn't find download directory; application issue..).

@jkotas jkotas merged commit 7b4be60 into main Jan 28, 2026
84 of 103 checks passed
@jkotas jkotas deleted the revert-123307-feature/deterministic-unwinding branch January 28, 2026 04:09
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.

4 participants