Skip to content

Conversation

@janvorli
Copy link
Member

There was a mistake in the implementation that prevented it from working correctly in some cases. The return value of the getClassSize() is not a number of slots filled in the array, but a number of GC references in the array. So if there were e.g. three slots and there was one GC reference in the second slot, the DoesValueTypeContainGCRefs returned false.

There was a mistake in the implementation that prevented it from working
correctly in some cases. The return value of the getClassSize() is not a
number of slots filled in the array, but a number of GC references in
the array. So if there were e.g. three slots and there was one GC
reference in the second slot, the DoesValueTypeContainGCRefs returned
false.
@janvorli janvorli added this to the 11.0.0 milestone Nov 20, 2025
@janvorli janvorli self-assigned this Nov 20, 2025
Copilot AI review requested due to automatic review settings November 20, 2025 16:11
@janvorli janvorli requested review from BrzVlad and kg as code owners November 20, 2025 16:11
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @janvorli, @kg
See info in area-owners.md if you want to be subscribed.

Copilot finished reviewing on behalf of janvorli November 20, 2025 16:13
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 a critical bug in the DoesValueTypeContainGCRefs function in the CoreCLR interpreter. The function incorrectly interpreted the return value of getClassGClayout(), treating it as the number of slots to iterate through, when it actually represents the total count of GC references found in the type.

  • Corrected the logic by directly using the return value of getClassGClayout() to determine if GC references exist
  • Renamed the variable from numSlots to numGCRefs to accurately reflect its meaning
  • Simplified the implementation by removing the unnecessary loop

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.

4 participants