Skip to content

Conversation

@jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Oct 15, 2025

Customer Impact

  • Customer reported
  • Found internally

The JIT corrupts return values from x64 Swift reverse pinvokes when 4 registers are used to return in if the method simultaneously uses unsafe value types that induce a GS cookie check.

Regression

  • Yes
  • No

Introduced by #119864.

Testing

Internal stress testing (that forces GS cookie check) caught this in our existing Swift tests.

Risk

Low. Change only affects Swift reverse pinvokes with GS cookie checks.

Swift returns values in r8, so it cannot be used for the cookie check.
Switch it to r9,r10 instead.
Copilot AI review requested due to automatic review settings October 15, 2025 11:40
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 15, 2025
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

This PR fixes a regression in the JIT compiler where return values from Swift reverse pinvokes were corrupted when 4 registers were used for return values and the method required a GS (Guard Stack) cookie check. The fix changes the registers used for GS cookie checks in Swift calling convention from R8/R9 to R9/R10, avoiding conflicts with Swift return value registers.

  • Updates register allocation for GS cookie checks in Swift calling convention
  • Prevents corruption of Swift reverse pinvoke return values when using unsafe code

@dotnet-policy-service
Copy link
Contributor

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

@jakobbotsch jakobbotsch requested review from a team and VSadov October 15, 2025 11:50
@JulieLeeMSFT JulieLeeMSFT added the Servicing-consider Issue for next servicing release review label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI Servicing-consider Issue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants