Skip to content

Commit

Permalink
Fix reporting GC fields from base types (dotnet#111011)
Browse files Browse the repository at this point in the history
Fixes dotnet#110836.

When we extended managed CorInfoImpl to support object stack allocation in dotnet#104411, there was one more spot that assumed valuetypes only in `GatherClassGCLayout` that we missed. This resulted in not reporting any GC pointers in base types.
  • Loading branch information
MichalStrehovsky authored Jan 2, 2025
1 parent 511d266 commit 1303e42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2377,10 +2377,10 @@ class ICorStaticInfo
bool fDoubleAlignHint = false
) = 0;

// This is only called for Value classes. It returns a boolean array
// in representing of 'cls' from a GC perspective. The class is
// assumed to be an array of machine words
// (of length // getClassSize(cls) / TARGET_POINTER_SIZE),
// Returns a boolean array representing 'cls' from a GC perspective.
// The class is assumed to be an array of machine words
// (of length getClassSize(cls) / TARGET_POINTER_SIZE for value classes
// and getHeapClassSize(cls) / TARGET_POINTER_SIZE for reference types),
// 'gcPtrs' is a pointer to an array of uint8_ts of this length.
// getClassGClayout fills in this array so that gcPtrs[i] is set
// to one of the CorInfoGCType values which is the GC type of
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,10 @@ private int MarkGcField(byte* gcPtrs, CorInfoGCType gcType)
private int GatherClassGCLayout(MetadataType type, byte* gcPtrs)
{
int result = 0;

if (type.MetadataBaseType is { ContainsGCPointers: true } baseType)
result += GatherClassGCLayout(baseType, gcPtrs);

bool isInlineArray = type.IsInlineArray;

foreach (var field in type.GetFields())
Expand Down

0 comments on commit 1303e42

Please sign in to comment.