Fix bugs in preinitialization - #134173
Merged
Merged
Conversation
Convert typed stores to the declared storage representation before copying, preserving neighboring fields for float and small enum values. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 146b627f-9730-4109-8207-b9051d53c8bc
Include managed byrefs when interpreting IsReferenceOrContainsReferences and cover direct, nested, and reference-free ref structs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 146b627f-9730-4109-8207-b9051d53c8bc
Clone duplicated value entries so mutations of by-value parameters cannot affect values retained by the caller. Preserve object and managed-reference aliases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 146b627f-9730-4109-8207-b9051d53c8bc Copilot-Session: 276f3a1-3afa-4c25-b46b-f3aaf3b4c748
Update existing span locations on assignment so retained local and parameter references observe the new view. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 146b627f-9730-4109-8207-b9051d53c8bc
Reuse cached field storage for CreateSpan so repeated views of the same RVA bytes preserve managed-reference identity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 146b627f-9730-4109-8207-b9051d53c8bc
Prevent boxed value types with GC references from being serialized into the frozen region. Cover direct and nested references, mutation and GC survival, and continued preinitialization of reference-free boxes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e4c62ea8-1ba5-4420-8451-e3a104e9a587
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Copilot stopped reviewing on behalf of
MichalStrehovsky due to an error
September 18, 2026 05:26
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Pull request overview
This PR expands NativeAOT preinitialization smoke testing and updates the AOT type preinitialization scanner/modeling to better handle additional IL patterns (boxed value types, typed stores, span aliasing/assignment, and byref-containing types).
Changes:
- Add multiple new preinitialization smoke tests covering boxed value types, typed stores,
IsReferenceOrContainsReferences<T>(), duplicate call argument behavior, span assignment aliasing, and RVA span identity. - Adjust IL scanning/modeling in
TypePreinitfordup, typed stores (stind*/stobj), andIsReferenceOrContainsReferences<T>()to account for byrefs and improve correctness. - Extend span modeling to support assignment between span values.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tests/nativeaot/SmokeTests/Preinitialization/Preinitialization.cs | Adds new smoke test cases to validate additional preinit scenarios and regression coverage for the compiler changes. |
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs | Updates the preinit IL scanner to handle dup cloning, reject stobj of GC-pointer-containing structs, include byref-containing types in IsReferenceOrContainsReferences, and make span values assignable. |
This was referenced Sep 18, 2026
Member
Author
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
jkotas
approved these changes
Sep 18, 2026
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same as #125947 and #128973, but this time asked GPT-6 Astra to find and fix bugs. The product changes are tiny, most of this is tests. The tests were failing without the fixes.