Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Correctly handle HFA structs when crossgen'd on Arm64 #80881

Merged
merged 1 commit into from
Feb 8, 2023

Conversation

trylek
Copy link
Member

@trylek trylek commented Jan 19, 2023

Description:

This change puts HFA calculation in Crossgen2 in sync with native CoreCLR runtime for value types with explicit layout. Previously Crossgen2 had a shortcut in the routine deciding that structs with explicit layouts are never marked as HFA that disagreed with the CoreCLR runtime; consequently, on arm64, Crossgen2 disagreed with the runtime on whether or not a function returning such a type should allocate the stack slot for return value, basically messing up the calling convention and GC refmap, resulting in various random AVs and corruptions. This was first observed by an internal customer in WPF apps where MilRectD is the type in question, later JanK filed the issue 79327 for the same problem.

Customer impact:

Random runtime crashes on arm64.

Regression:

Nope, I believe the incomplete implementation was the original one, this change just "improves it" by putting it in better sync with the native runtime. I have also added a code comment mentioning that these two need to be kept in sync.

Risk:

Low - the error in the previous implementation is obvious, R2RDump and my new runtime diagnostics clearly show the GC refmap mismatch caused by this problem and its fixing after applying the Crossgen2 fix.

Link to issue:

Link to PR against main:

Publishing impact:

In the particular case of the WPF app the problem was in the PresentationCore.dll assembly. The assembly (or rather the entire WPF) need to be recompiled with Crossgen2 with the fix applied for this to take effect. For now I assume that is an automated part of the servicing process.

Thanks

Tomas

Description:

This change puts HFA calculation in Crossgen2 in sync with native
CoreCLR runtime for value types with explicit layout. Previously
Crossgen2 had a shortcut in the routine deciding that structs with
explicit layouts are never marked as HFA that disagreed with
the CoreCLR runtime; consequently, on arm64, Crossgen2 disagreed
with the runtime on whether or not a function returning such a type
should allocate the stack slot for return value, basically
messing up the calling convention and GC refmap, resulting in various
random AVs and corruptions. This was first observed by an internal
customer in WPF apps where MilRectD is the type in question, later
JanK filed the issue 79327 for the same problem.

Customer impact:

Random runtime crashes on arm64.

Regression:

Nope, I believe the incomplete implementation was the original one,
this change just "improves it" by putting it in better sync with
the native runtime. I have also added a code comment mentioning
that these two need to be kept in sync.

Risk:

Low - the error in the previous implementation is obvious, R2RDump
and my new runtime diagnostics clearly show the GC refmap mismatch
caused by this problem and its fixing after applying the Crossgen2 fix.

Link to issue:

Link to PR against main:

Publishing impact:

In the particular case of the WPF app the problem was in
the PresentationCore.dll assembly. The assembly (or rather the entire WPF)
need to be recompiled with Crossgen2 with the fix applied for this to
take effect. For now I assume that is an automated part of the servicing
process.

Thanks

Tomas
@ghost ghost assigned trylek Jan 19, 2023
@jeffschwMSFT jeffschwMSFT added the Servicing-consider Issue for next servicing release review label Jan 19, 2023
@jeffschwMSFT jeffschwMSFT added this to the 7.0.x milestone Jan 19, 2023
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

approved. we will take for consideration in 7.0.x

@jeffschwMSFT jeffschwMSFT changed the title Manual .NET 7 backport of #80218 fixing #79327 [release/7.0] Correctly handle HFA structs when crossgen'd on Arm64 Jan 20, 2023
@rbhanda rbhanda added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jan 24, 2023
@rbhanda rbhanda modified the milestones: 7.0.x, 7.0.4 Jan 24, 2023
@carlossanlop
Copy link
Member

Some ARM64 helix queues in 7.0 were not being found. I merged a couple of PRs to update them to use the existing ones. So I'm closing and reopening this PR since it hit arm64 failures and it needs the coverage in that architecture.

@carlossanlop carlossanlop reopened this Feb 8, 2023
@carlossanlop
Copy link
Member

Approved by Tactics for 7.0.4.
Signed off by area owner.
No OOB changes needed.
The CI failures are known and unrelated #81619, #81391 and #81544, and we're expecting them to get fixed with the merged PR #81712
Ready to merge. :shipit:

@carlossanlop carlossanlop merged commit d31ff20 into dotnet:release/7.0 Feb 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 11, 2023
@trylek trylek deleted the 80128-net7port branch May 10, 2023 19:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-crossgen2-coreclr Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants