From eff6546c2e38f3eec9e2770819491165a570c1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Fri, 3 Dec 2021 14:43:21 -0500 Subject: [PATCH] Update overlapped field test to conflict on 32-bit arches (#62308) * Update overlapped field test to conflict on 32-bit arches Fixes https://github.com/dotnet/runtime/issues/62303 * [class-init] Setup fields of nested structs in layout check On AOT the field's class may not have been fully inited yet. Related to https://github.com/dotnet/runtime/issues/62311 --- src/mono/mono/metadata/class-init.c | 2 +- .../Loader/classloader/explicitlayout/NestedStructs/case04.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/metadata/class-init.c b/src/mono/mono/metadata/class-init.c index c53f4e5fe0b72..a7c333afb5eb8 100644 --- a/src/mono/mono/metadata/class-init.c +++ b/src/mono/mono/metadata/class-init.c @@ -1903,7 +1903,7 @@ validate_struct_fields_overlaps (guint8 *layout_check, int layout_size, MonoClas if (mono_type_is_struct (ftype)) { // recursively check the layout of the embedded struct MonoClass *embedded_class = mono_class_from_mono_type_internal (ftype); - g_assert (m_class_is_fields_inited (embedded_class)); + mono_class_setup_fields (embedded_class); const int embedded_fields_count = mono_class_get_field_count (embedded_class); int *embedded_offsets = g_new0 (int, embedded_fields_count); diff --git a/src/tests/Loader/classloader/explicitlayout/NestedStructs/case04.cs b/src/tests/Loader/classloader/explicitlayout/NestedStructs/case04.cs index 7e2cfc4475860..c89bea2ea3ba3 100644 --- a/src/tests/Loader/classloader/explicitlayout/NestedStructs/case04.cs +++ b/src/tests/Loader/classloader/explicitlayout/NestedStructs/case04.cs @@ -27,7 +27,7 @@ public struct SecondLevel [StructLayout(LayoutKind.Explicit)] public struct ThirdLevel { - [FieldOffset(6)] + [FieldOffset(2)] public short ConflictingValueTypeField; }