Fix NativeAOT thread-static debug info - #133109
Merged
max-charlamb merged 1 commit intoSep 3, 2026
Merged
max-charlamb merged 1 commit into
max-charlamb merged 1 commit into
Conversation
Treat thread-static, GC-static, and non-GC-static fields as mutually exclusive storage categories when emitting debug types. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 32bd0ba5-1c4a-4c99-bdd4-969279117e18
|
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 |
max-charlamb
marked this pull request as ready for review
September 2, 2026 17:00
max-charlamb
requested review from
VSadov and
jkotas
and
a lite review from Copilot
September 2, 2026 17:00
|
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
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, matches the existing static storage categorization logic in the same method, and resolves the confirmed conditional misclassification without introducing new API surface.
Pull request overview
Adjusts NativeAOT debug type emission for static fields so thread-static fields aren’t incorrectly filtered out when HasGCStaticBase also reports true, improving PDB/UDA fidelity for types with thread statics.
Changes:
- Makes the thread-static vs GC-static storage checks mutually exclusive by converting the GC-static check into an
else if. - Ensures thread-static fields are preserved even when a separate ordinary GC-static base isn’t generated for the owning type.
File summaries
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UserDefinedTypeDescriptor.cs | Fixes the static-field filtering logic to avoid dropping thread-static fields during debug type emission. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
jkotas
approved these changes
Sep 2, 2026
VSadov
approved these changes
Sep 2, 2026
max-charlamb
enabled auto-merge (squash)
September 2, 2026 20:11
Member
Author
|
/ba-g Helix Monitor failure |
Member
Author
|
/backport to release/11.0 |
max-charlamb
deleted the
max-charlamb/nativeaot-thread-static-debug-info
branch
September 3, 2026 02:14
Contributor
|
Started backporting to |
4 tasks
3 tasks
steveisok
pushed a commit
that referenced
this pull request
Sep 8, 2026
Backport of #133109 to release/11.0 /cc @max-charlamb ## Customer Impact - [ ] Customer reported - [ ] Found internally [Select one or both of the boxes. Describe how this issue impacts customers, citing the expected and actual behaviors and scope of the issue. If customer-reported, provide the issue number.] ## Regression - [ ] Yes - [ ] No [If yes, specify when the regression was introduced. Provide the PR or commit if known.] ## Testing [How was the fix verified? How was the issue missed previously? What tests were added?] ## Risk [High/Medium/Low. Justify the indication by mentioning how risks were measured and addressed.] **IMPORTANT**: If this backport is for a servicing release, please verify that: - For .NET 8 and .NET 9: The PR target branch is `release/X.0-staging`, not `release/X.0`. - For .NET 10+: The PR target branch is `release/X.0` (no `-staging` suffix). ## Package authoring no longer needed in .NET 9 **IMPORTANT**: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version. Keep in mind that we still need package authoring in .NET 8 and older versions. Co-authored-by: Max Charlamb <44248479+max-charlamb@users.noreply.github.com> Co-authored-by: Max Charlamb <maxcharlamb@microsoft.com> Copilot-Session: 32bd0ba5-1c4a-4c99-bdd4-969279117e18
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.
Summary
Problem
FieldDesc.HasGCStaticBasereturnstruefor NativeAOT thread-static fields. The debug type writer first accepted a thread-static field based onHasThreadStaticBase, but then independently tested the same field as an ordinary GC-static field:This dropped all thread-static fields from types that had no separately generated GC-static base. An example is the
AsyncDispatcherInforef struct:The index symbol was emitted because the type had thread-static storage, but the PDB omitted the typed parent member, thread-static storage UDT, helper UDT, and
t_currentfield offset.The fix makes the three storage categories mutually exclusive by changing the second test to
else if.CDB validation
I built a small runtime-async NativeAOT application that roots
AsyncDispatcherInfoand inspected its Windows PDB with CDB.Before the fix, the index existed only as an untyped symbol. The parent type had no
__THREADSTATICINDEX, and the thread-static storage type did not exist:After the fix, the parent UDT has a typed
__THREADSTATICINDEX, the storage UDT containst_currentat offset+0x008, and the helper UDT is present:Testing
Note
This PR description was generated with GitHub Copilot.