Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Oct 9, 2025

Backport of #120552 to release/10.0

/cc @janvorli

Customer Impact

  • Customer reported
  • Found internally

There is a problem with RtlRestoreContext not restoring context during thread abort if that abort comes from injected APC callback on ARM64 and the processor supports SVE. In that case, the context provided by the APC callback can contain XSTATE and when we start walking stack from that context, we copy that context into the REGDISPLAY. The problem is that we copy the ContextFlags without changes, so if they contained CONTEXT_XSTATE flag, it is kept set even though the REGDISPLAY has only plain old CONTEXT without any XSTATE.
When we call RtlRestoreContext in the ResumeAfterCatch, it fails because the XSTATE is not valid and so it returns. That's unexpected and the runtime ends up crashing with an assert in debug/checked build and causing some unexpected behavior and random crashes in release builds.

Regression

  • Yes
  • No

Testing

CI tests - libraries tests contain controlled execution tests that started to fail on some CI runs, probably due to added machines with enabled SVE or upgraded Windows with enabled SVE.

Risk

Low, the fix just removes the CONTEXT_XSTATE from the copied context and makes it valid.

There is a problem with RtlRestoreContext not restoring context during
ThreadAbort if that abort comes from injected APC callback on ARM64 and
the processor supports SVE. In that case, the context provided by the
APC callback can contain XSTATE and when we start walking stack from
that context, we copy that context into the REGDISPLAY. The problem is
that we copy the ContextFlags without changes, so if they contained
CONTEXT_XSTATE flag, it is kept set even though the REGDISPLAY has only
plain old CONTEXT without any xstate.
When we call RtlRestoreContext in the ResumeAfterCatch, it fails because
the XSTATE is not valid and so it returns. That's unexpected and we end
up crashing with an assert.

The fix clears the CONTEXT_XSTATE in ResumableFrame::UpdateRegDisplay so
that the REGDISPLAY ContextFlags are validly representing the context.

Close #120437
@janvorli janvorli self-assigned this Oct 9, 2025
@janvorli janvorli added area-ExceptionHandling-coreclr Servicing-consider Issue for next servicing release review labels Oct 9, 2025
@JulieLeeMSFT
Copy link
Member

@tannergooding, @EgorBo, please review this backport PR.

@agocke agocke added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 10, 2025
@janvorli
Copy link
Member

The test failures are known issue #120577

@agocke
Copy link
Member

agocke commented Oct 14, 2025

/ba-g failures known

@agocke agocke merged commit 2567739 into release/10.0 Oct 14, 2025
102 of 107 checks passed
@agocke agocke deleted the backport/pr-120552-to-release/10.0 branch October 14, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants