Skip to content

CoreCLR runtime seems to have a subtle bug in HFA flag calculation #80393

@trylek

Description

@trylek

While working on the issue

#80218

based on Anton's PR feedback I noticed what looks like a CoreCLR runtime bug w.r.t. HFA calculation: in the routine EEClass::CheckForHFA, the switch case for ELEMENT_TYPE_VALUETYPE seems to be missing the alignment check, so that it looks like

struct F2
{
    public double value;
}

[StructLayout(LayoutKind.Explicit)]
struct S
{
    [FieldOffset(0)] public double f1;
    [FieldOffset(3)] public F2 f2;
    [FieldOffset(8)] public double f3;
}

would be erroneously identified as HFA-eligible. /cc @jkotas and @janvorli to confirm whether I'm not just misreading the code, otherwise I guess it is worth fixing in .NET 8.

Note: If JIT logic is fixed, please also fix the corresponding managed ComputeHomogeneousAggregateCharacteristic function in MetadataFieldLayoutAlgorithm.cs.

Metadata

Metadata

Assignees

Labels

area-TypeSystem-coreclrin-prThere is an active PR which will close this issue when it is merged

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions