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/9.0] Fix a case in MethodImpl overriding which wasn't handled as expected in ilc.exe for native aot #107409

Merged
merged 6 commits into from
Sep 5, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 5, 2024

Backport of #106716 to release/9.0

/cc @davidwrighton

Customer Impact

  • Customer reported
  • Found internally

This bug was found when people internally and externally began using the covariant returns feature which makes use of MethodImpl metadata records for overrides on virtual methods in ways that are not done with the C# compiler under any other circumstance.

Regression

  • Yes
  • No

This is not a regression, but merely a newly important bug, which has become important as customers have started using covariant methods.

Testing

The existing testbed for covariant returns would have caught this issue, but it was not supported on NativeAOT, as it mingled tests which tested the TypeLoadException throwing paths and the normal execution paths. This fix was tested by changing the splitting the tests into tests which throw and tests which test correct behavior. In addition, a unit test specific to this issue was added to the type system unit test suite, and the most critical of the newly enabled tests was added to the type system unit test suite.

Risk

Medium. The virtual method resolution algorithm in the managed type system is notoriously complex, and used in crossgen2 as well as native aot. The fix taken was minimal, and did not attempt to address all possible issues in MethodImpl resolution, but instead was limited to ensuring that the code patterns generated by the C# compiler worked correctly. The medium level of risk is what caused the fairly extensive test effort put in as part of this change.

…in ilc.exe for native aot - This was causing real C# applications to fail to behave correctly on NativeAOT builds - Enable testing for covariant byref returns on nativeaot (split testing up so that the tests do not expect TypeLoadException, which NativeAOT doesn't reliably generate) - Fix implementation of SynthesizedPgoIncompatible project file flag for test script generation - Put copy of attributetesting.il test into the managed type system unit test suite - Add regression test of issue noted in #96175 into managed type system unit test suite - Update workflow documentation to include a better path to finding details on how to run CoreCLR and Libraries tests for Native AOT

Fixes #96175
Copy link
Contributor

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

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. please get a code review. we can merge when ready

@jeffschwMSFT jeffschwMSFT added the Servicing-approved Approved for servicing release label Sep 5, 2024
@jeffschwMSFT jeffschwMSFT added this to the 9.0.0 milestone Sep 5, 2024
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM. I'll keep an eye on CI

@jeffschwMSFT jeffschwMSFT merged commit 24889f9 into release/9.0 Sep 5, 2024
11 of 17 checks passed
@MichalStrehovsky MichalStrehovsky deleted the backport/pr-106716-to-release/9.0 branch September 5, 2024 21:38
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-NativeAOT-coreclr Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants