Skip to content

Conversation

@github-actions
Copy link
Contributor

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

Backport of #120300 to release/10.0

/cc @janvorli

Customer Impact

  • Customer reported
  • Found internally

The issue #118564 causes random and hard to figure out floating point values miscalculations on Windows x64 when JIT uses non-volatile XMM registers across an exception handling code. When a hardware exception (e.g. a NullReferenceException) is thrown and handled, resuming after catch doesn't restore the non-volatile XMM registers, because the CONTEXT was marked as not having any floating point state.

Regression

  • Yes, it was introduced with the new EH, enabled by default in .NET 9
  • No

Testing

Repro test provided by @EgorBo, coreclr pri1 and libraries tests.

Risk

Low.

The CopyOSContext was skipping floating point registers on amd64. There
was an obsolete comment that on some older Windows, the vector registers
are not present in the context. I've found to be a problem when porting
nativeAOT EH to CoreCLR and to make the context flags correct, I've
removed the CONTEXT_FLOATING_POINT from the ContextFlags. But it now
turned out that it prevents EH from correctly restoring non-volatile
floating point registers after a catch. Since he ContextFlags don't
contain the CONTEXT_FLOATING_POINT, the floating point registers were
not restored during the resume.

This change fixes it by removing the amd64 specific handling and always
copying the whole CONTEXT structure. It just masks off the
CONTEXT_XSTATE, as the XSTATE is stored out of the basic CONTEXT.

Close #118564
@janvorli janvorli self-assigned this Oct 2, 2025
@janvorli janvorli requested a review from jkotas October 2, 2025 15:34
@janvorli janvorli added area-ExceptionHandling-coreclr Servicing-consider Issue for next servicing release review labels Oct 2, 2025
@JulieLeeMSFT JulieLeeMSFT added this to the 10.0.0 milestone Oct 2, 2025
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Oct 2, 2025
@agocke agocke merged commit 1e7adf6 into release/10.0 Oct 6, 2025
104 of 107 checks passed
@agocke agocke deleted the backport/pr-120300-to-release/10.0 branch October 6, 2025 18:38
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants