Skip to content

Allow type loading when merging array types#122121

Merged
AndyAyersMS merged 3 commits intodotnet:mainfrom
AndyAyersMS:Fix120903
Dec 3, 2025
Merged

Allow type loading when merging array types#122121
AndyAyersMS merged 3 commits intodotnet:mainfrom
AndyAyersMS:Fix120903

Conversation

@AndyAyersMS
Copy link
Member

If the runtime is merging two array types, the merged type may be one that is not yet loaded. Allow the runtime to load the type.

Fixes #120903.

If the runtime is merging two array types, the merged type may be
one that is not yet loaded. Allow the runtime to load the type.

Fixes dotnet#120903.
Copilot AI review requested due to automatic review settings December 2, 2025 21:47
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 2, 2025
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks

@AndyAyersMS
Copy link
Member Author

@jkotas PTAL
cc @dotnet/jit-contrib

Seems like this is the first test I've added to the regression part of the tree since we merged #121078.

It wasn't obvious to me how to decide which csproj should be updated. Also we have been burned by this kind of "need to explicitly include" logic before and ended up with tests that never got built or run.

@kg
Copy link
Member

kg commented Dec 2, 2025

LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #120903 by allowing the runtime to load array types when merging them. Previously, the runtime would forbid type loading during array type merging, which could cause issues when the merged type had not yet been loaded.

Key Changes

  • Removed loader restrictions in MergeArrayTypeHandlesToCommonParent to allow type loading during array type merging
  • Added a regression test demonstrating the scenario where array type merging requires loading a new type

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/coreclr/vm/typehandle.cpp Simplified MergeArrayTypeHandlesToCommonParent by removing the ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE() block and ClassLoader::DontLoadTypes flag, allowing type loading when needed
src/tests/JIT/Regression/JitBlue/Runtime_120903/Runtime_120903.cs Added regression test that exercises array type merging with Unsafe.As casting between related array types
src/tests/JIT/Regression/Regression_ro_1.csproj Added new test file to the build (though placement is out of order)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@AndyAyersMS AndyAyersMS added area-VM-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Dec 2, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[libraries-pgo] VM assert failure !result.IsNull() in TypeHandle::MergeArrayTypeHandlesToCommonParent called from CEEInfo::isMoreSpecificType

3 participants