Repository navigation
[mono][aot] Fix recursive struct wrapper normalization - #135438
Open
pavelsavara wants to merge 1 commit into
Open
pavelsavara wants to merge 1 commit into
pavelsavara wants to merge 1 commit into
Conversation
get_wrapper_shared_vtype() normalizes each value type field while get_wrapper_shared_type_full() normalizes generic type arguments. A struct containing a generic struct instantiated over itself makes the two functions recurse until mono-aot-cross overflows its native stack. Track the value types currently being normalized. If a type is reached again, or an ever-growing generic shape reaches a bounded depth, keep the original type using the existing non-shared fallback. The regression test uses only the valid self-recursive shape. In particular, it does not reintroduce the mutually recursive generic value types from dotnet#135029 that caused TypeLoadException during test assembly loading. Fixes dotnet#132071 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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. |
pavelsavara
added a commit
that referenced
this pull request
Oct 8, 2026
Remove the mutually recursive generic value types added by the original test. CoreCLR rejects that metadata while loading System.Runtime.Tests, before test discovery, which caused #135348 across unrelated CI legs. Keep the valid self-recursive shape that reproduces the Mono AOT compiler stack overflow and make its helper types private. This matches the corrected test in #135438. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2 of 4 tasks
This branch has not been deployed
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
Reintroduces the Mono AOT wrapper-normalization fix from #135029 after its
revert in #135371, with a corrected regression test.
mono-aot-crossrecursively normalizes value-type fields and generic typearguments when it builds gsharedvt wrapper signatures. A valid type such as:
makes
get_wrapper_shared_vtype()andget_wrapper_shared_type_full()calleach other until the native stack overflows.
The fix carries a stack-allocated chain of value types currently being
normalized. Re-entering a type, or reaching the bounded depth for a generic
shape that grows at every level, uses the existing "keep the original type"
fallback.
What changed since #135029
The original product fix was not the source of the cross-platform CI failures.
The original test also declared mutually recursive generic value types:
CoreCLR rejects that metadata with
TypeLoadExceptionwhile loadingSystem.Runtime.Tests, before xUnit test discovery. This caused #135348 onWASI, Firefox, Android, and iOS.
This PR removes that invalid mutual shape. The test uses only the valid
self-recursive shape that reproduces the Mono AOT compiler failure. Its helper
types are private.
Validation
.\build.cmd -bl -os browser -subset mono+libs -c Debug /p:RuntimeFlavor=Monomono-aot-crosscompiling the exact modifiedSystem.Runtime.Tests.dll0xC00000FDnative stack overflow, as expected.mono-aot-crosscompiling the same assemblySystem.Tests.ValueTypeTestsSystem.Tests.ValueTypeTestsaot-instances.dllpassed (14,712/14,747 methods compiled).TypeLoadExceptionreportedby [ci-scan] Test failure: System.Runtime.Tests TypeLoadException for StructWithMutualGenericFieldA #135348.
Resolves #132071
Note
This PR description was drafted with GitHub Copilot.