-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoreCLR runtime seems to have a subtle bug in HFA flag calculation #80393
Comments
It seems that discrepancy between JIT and Crossgen2 was introduced by dotnet/coreclr#22041. @jkoritzinsky, is that an oversight that JIT allows non-aligned wrapped floats/doubles for HFA? Also, why does the code require having a field with offset 0 while having a gap at, say, 8 is fine? |
Yes this is an oversight in the CoreCLR implementation. The CoreCLR implementation should check that the nested value type is aligned at the same alignment as the other fields and as it's HFA type requires. The main reason behind the check for offset 0 is to ensure that we're consistent on what we define a gap at 0 bytes to be. We treat a gap at 0 bytes as though we have an array of |
@trylek @jkoritzinsky is this something we plan on fixing in 8? Doesnt look like a regression. |
I think at this point, we should fix this in .NET 9. |
ComputeHomogeneousAggregateCharacteristic looks correct to me in main, I guess someone fixed it? Or am I misunderstanding the problem? if (field.Offset.IsIndeterminate || field.Offset.AsInt % haElementSize != 0)
{
return NotHA;
} |
From looking into fixing this, I'm left wondering whether Do we have an example of real C being p/invoke'd via explicit layout in this way? Obviously it's good for every part of CoreCLR to agree on whether |
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
, theswitch case
forELEMENT_TYPE_VALUETYPE
seems to be missing the alignment check, so that it looks likewould 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.The text was updated successfully, but these errors were encountered: