Skip to content

Fix bugs in preinitialization - #134173

Merged
MichalStrehovsky merged 6 commits into
dotnet:mainfrom
MichalStrehovsky:preinitbugs
Sep 24, 2026
Merged

MichalStrehovsky merged 6 commits into
dotnet:mainfrom
MichalStrehovsky:preinitbugs

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

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.

MichalStrehovsky and others added 6 commits September 18, 2026 12:35
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

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copilot stopped reviewing on behalf of MichalStrehovsky due to an error September 18, 2026 05:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 TypePreinit for dup, typed stores (stind*/stobj), and IsReferenceOrContainsReferences<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.

Comment thread src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs
Comment thread src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

/ba-g the networking failure was presumably fixed in #134414. the other one in #134181.

@MichalStrehovsky
MichalStrehovsky enabled auto-merge (squash) September 24, 2026 14:03
@MichalStrehovsky
MichalStrehovsky merged commit 0a6f3e5 into dotnet:main Sep 24, 2026
147 of 151 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants