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.

Related to #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
Copilot finished reviewing on behalf of jkotas November 20, 2025 23:54
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.

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
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.

1 participant