Repository navigation
fix null dereference in LoadConstraints for generic types - #136826
Merged
Merged
Conversation
pMT is only set for generic methods, so for a generic type both bad format throws in TypeVarTypeDesc::LoadConstraints dereferenced null. They now use the type's own token when pMT is null. Fixes dotnet#92566
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This was referenced Nov 2, 2026
jkotas
reviewed
Nov 2, 2026
Member
|
/azp run runtime-coreclr outerloop |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the null-dereference fix and accompanying malformed-metadata regression test.
No open issues 🎉
What changed in this PR
This PR addresses #92566 by preventing null dereferences in CoreCLR’s generic-type constraint loading when reporting malformed metadata.
Changes:
- Use the type’s own token in both bad-format error paths when
pMTis null. - Add an IL regression test expecting
TypeLoadExceptionfor a nonexistent constraint TypeSpec token. - Configure the test for process isolation and exclude incompatible NativeAOT and IL round-trip runs.
| File | Description |
|---|---|
src/tests/Loader/classloader/regressions/GitHub_92566/GitHub_92566.ilproj |
Configures the regression test and its compatibility exclusions. |
src/tests/Loader/classloader/regressions/GitHub_92566/GitHub_92566.il |
Tests invalid constraint metadata produces TypeLoadException. |
src/coreclr/vm/typedesc.cpp |
Guards both error-reporting paths against a null pMT. |
Review effort: Balanced
Member
|
/ba-g known outer loop failures |
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.
fixes #92566
pMT is only set for generic methods, so for a generic type both bad format throws in TypeVarTypeDesc::LoadConstraints dereferenced null. they now use the type's own token when pMT is null.
the new test gives a generic type a constraint pointing to a typespec token that does not exist. on main it segfaults, now it throws TypeLoadException. Loader/classloader regressions 115/115 and generics 217/217 pass.