Skip to content

Bug regarding inheritance in classes with explicit layout #53542

Closed
@trylek

Description

@trylek

Not fixing this for .NET 6 as we decided it's too risky to change runtime layouts now, it would also require bumping up the readytorun major version, but it's a bug nonetheless. For an explicit layout class with a base class, we place its fields as if the base class was twice its actual instance size. This is because we first take the base class instance size into account when calculating the layout itself in

UINT32 cbCurOffset = parentSize;

and we add the parent class size a second time in MethodTableBuilder::HandleExplicitLayout in

S_UINT32 dwInstanceSliceOffset = S_UINT32(HasParent() ? GetParentMethodTable()->GetNumInstanceFieldBytes() : 0);

and

HRESULT hr = pTempFD->SetOffset(pTempFD->GetOffset_NoLogging() + dwInstanceSliceOffset.Value());

/cc @dotnet/crossgen-contrib, @dotnet/dotnet-coreclr

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions