Skip to content

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

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

structF2{publicdoublevalue;}[StructLayout(LayoutKind.Explicit)]structS{[FieldOffset(0)]publicdoublef1;[FieldOffset(3)]publicF2f2;[FieldOffset(8)]publicdoublef3;}

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

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions