Skip to content

Commit be63af2

Browse files
authored
[mono][aot] Fix infinite recursion in the AOT dwarf emitter. (#79310)
The recursion would happen if a gshared type would contain a recursive reference to it. It was triggered by the JsonTypeInfo:JsonTypeInfo<Queue<T>> field added by #78646. Fixes #79279.
1 parent b858484 commit be63af2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/mono/mono/mini/dwarfwriter.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,11 @@ emit_class_dwarf_info (MonoDwarfWriter *w, MonoClass *klass, gboolean vtype)
939939
if (die)
940940
return die;
941941

942+
if (m_class_is_ginst (klass) && !vtype) {
943+
/* This could lead to recursion */
944+
return NULL;
945+
}
946+
942947
if (!((m_class_get_byval_arg (klass)->type == MONO_TYPE_CLASS) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_OBJECT) || m_class_get_byval_arg (klass)->type == MONO_TYPE_GENERICINST || m_class_is_enumtype (klass) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_VALUETYPE && vtype) ||
943948
(m_class_get_byval_arg (klass)->type >= MONO_TYPE_BOOLEAN && m_class_get_byval_arg (klass)->type <= MONO_TYPE_R8 && !vtype)))
944949
return NULL;
@@ -1174,6 +1179,8 @@ get_type_die (MonoDwarfWriter *w, MonoType *t)
11741179
case MONO_TYPE_GENERICINST:
11751180
if (!MONO_TYPE_ISSTRUCT (t)) {
11761181
tdie = (const char *)g_hash_table_lookup (w->class_to_reference_die, klass);
1182+
if (!tdie)
1183+
tdie = ".LDIE_OBJECT";
11771184
} else {
11781185
tdie = ".LDIE_I4";
11791186
}

0 commit comments

Comments
 (0)