Skip to content

Conversation

@jkotas
Copy link
Member

@jkotas jkotas commented Nov 20, 2025

ResolveTokenToTypeDefThrowing can return FALSE in some situations when the token cannot be resolved. The calling code has to deal with the situation gracefully since the [out] arguments are not initialized in that case.

Regressions introduced by #114675 (method.cpp) and #118413 (methodtablebuilder.cpp)

Fixes #121791

Copilot AI review requested due to automatic review settings November 20, 2025 23:52
@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 Nov 20, 2025
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 improper handling of ClassLoader::ResolveTokenToTypeDefThrowing return values. The function can return FALSE when a token cannot be resolved, and in such cases, the out parameters are not initialized. The fix ensures that calling code checks the return value before using the out parameters.

  • Added return value checks in three locations where ResolveTokenToTypeDefThrowing was previously called without checking its result
  • Updated logic to gracefully handle resolution failures with appropriate fallback behavior

Reviewed Changes

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

File Description
src/coreclr/vm/methodtablebuilder.cpp Added return value check at line 3875 with fallback to ELEMENT_TYPE_VALUETYPE, and wrapped code at line 3914 to only use resolved values when resolution succeeds
src/coreclr/vm/method.cpp Added return value check at line 2318 to prevent use of uninitialized out parameters in IsTypeDefOrRefImplementedInSystemModule

@jkotas jkotas 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 Nov 21, 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.

@jkotas jkotas force-pushed the issue-121791 branch 2 times, most recently from c5bb40c to e56b25d Compare November 22, 2025 06:31
@jkotas
Copy link
Member Author

jkotas commented Nov 24, 2025

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

ResolveTokenToTypeDefThrowing can return FALSE in some situations when the token cannot be resolved. The calling code has to deal with the situation gracefully since the [out] arguments are not initialized in that case.

Fixes dotnet#121791
@jkotas
Copy link
Member Author

jkotas commented Nov 24, 2025

/azp run runtime-nativeaot-outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@jkotas
Copy link
Member Author

jkotas commented Nov 25, 2025

/backport to release/10.0

@github-actions
Copy link
Contributor

Started backporting to release/10.0 (link to workflow run)

@jkotas
Copy link
Member Author

jkotas commented Nov 26, 2025

/ba-g osx infra is down. The change passed CI before.

@jkotas jkotas merged commit e207ac1 into dotnet:main Nov 26, 2025
85 of 99 checks passed
@jkotas jkotas deleted the issue-121791 branch November 26, 2025 01:22
jkotas added a commit that referenced this pull request Dec 4, 2025
…ng return values (#121968)

Backport of #121864 to release/10.0

/cc @jkotas

## Customer Impact

- [x] Customer reported
- [ ] Found internally

Customer observed crash in NUnit project after upgrading to .NET 10. The
bug is triggered by a static field that:
- The type of the field must be a struct type
- The struct type lives in external assembly.
- The external assembly exists, but the struct type is missing in that
assembly.

The fix is the add missing error handling in a few places.

## Regression

- [x] Yes
- [ ] No

Regressions introduced by #114675 (runtime async feature) and #118413
(type loading perf work)

## Testing

Targeted repro, distilled to a test

## Risk

Low. The fix is just an extra error handling.

---------

Co-authored-by: Jan Kotas <[email protected]>
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.

NET10: ExecutionEngineException when calling Assembly.GetTypes()

2 participants