Skip to content

Commit 1c683a8

Browse files
Work around issue #102868 (#102982)
The relaxation of type layout check in #102810 exposed a bug in the type layout algorithm that doesn't correctly handle doing type layout in this situation (it doesn't match what CoreCLR VM computes). This restores the old behavior for ReadyToRun that just throws on this. The compiler will then stop precompiling the method and fall back to runtime JIT. Works around #102868 (the bug still exists, this is a valid situation that we should be able to precompile, we just won't).
1 parent 015e46e commit 1c683a8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunMetadataFieldLayoutAlgorithm.cs

+14
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,24 @@ protected override ComputedInstanceFieldLayout ComputeInstanceFieldLayout(Metada
818818
{
819819
if (type.IsExplicitLayout)
820820
{
821+
// Works around https://github.com/dotnet/runtime/issues/102868
822+
if (!type.IsValueType &&
823+
(type.MetadataBaseType is MetadataType baseType && baseType.IsSequentialLayout))
824+
{
825+
ThrowHelper.ThrowTypeLoadException(type);
826+
}
827+
821828
return ComputeExplicitFieldLayout(type, numInstanceFields);
822829
}
823830
else if (type.IsSequentialLayout && !type.ContainsGCPointers)
824831
{
832+
// Works around https://github.com/dotnet/runtime/issues/102868
833+
if (!type.IsValueType &&
834+
(type.MetadataBaseType is MetadataType baseType && baseType.IsExplicitLayout))
835+
{
836+
ThrowHelper.ThrowTypeLoadException(type);
837+
}
838+
825839
return ComputeSequentialFieldLayout(type, numInstanceFields);
826840
}
827841
else

0 commit comments

Comments
 (0)