From 5dffc010f0746a5d9e0ee95ee9504fbbb1b6cee1 Mon Sep 17 00:00:00 2001 From: Jeremi Kurdek <59935235+jkurdek@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:12:51 +0200 Subject: [PATCH] Fix lowering support for inline arrays (#107744) --- src/mono/mono/metadata/marshal.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/metadata/marshal.c b/src/mono/mono/metadata/marshal.c index d0e0b2327907c..0ad51eae802a9 100644 --- a/src/mono/mono/metadata/marshal.c +++ b/src/mono/mono/metadata/marshal.c @@ -6798,11 +6798,15 @@ static void record_struct_field_physical_lowering (guint8* lowered_bytes, MonoTy static void record_inlinearray_struct_physical_lowering (guint8* lowered_bytes, MonoClass* klass, guint32 offset) { + int align; + int type_offset = MONO_ABI_SIZEOF (MonoObject); + // Get the first field and record its physical lowering N times - MonoClassField* field = mono_class_get_fields_internal (klass, NULL); + gpointer iter = NULL; + MonoClassField* field = mono_class_get_fields_internal (klass, &iter); MonoType* fieldType = field->type; for (int i = 0; i < m_class_inlinearray_value(klass); ++i) { - record_struct_field_physical_lowering(lowered_bytes, fieldType, offset + m_field_get_offset(field) + i * mono_type_size(fieldType, NULL)); + record_struct_field_physical_lowering(lowered_bytes, fieldType, offset + m_field_get_offset(field) + i * mono_type_size(fieldType, &align) - type_offset); } }