Skip to content

Commit b240d77

Browse files
authored
Merge pull request #1893 from Unity-Technologies/unity-main-fix-crash-inflate-info
Fix domain reload crash in inflate_info.
2 parents 124702a + e492b14 commit b240d77

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

mono/mini/mini-generic-sharing.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,17 +726,21 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
726726
MonoType *t = mono_class_inflate_generic_type_checked (m_class_get_byval_arg (dele_info->klass), context, error);
727727
mono_error_assert_msg_ok (error, "Could not inflate generic type"); /* FIXME proper error handling */
728728

729-
MonoClass *klass = mono_class_from_mono_type_internal (t);
729+
MonoClass *inflated_klass = mono_class_from_mono_type_internal (t);
730730
mono_metadata_free_type (t);
731731

732732
MonoMethod *method = mono_class_inflate_generic_method_checked (dele_info->method, context, error);
733733
mono_error_assert_msg_ok (error, "Could not inflate generic method"); /* FIXME proper error handling */
734734

735-
// FIXME: Temporary
736-
MonoDelegateClassMethodPair *res = (MonoDelegateClassMethodPair *)mono_domain_alloc0 (domain, sizeof (MonoDelegateClassMethodPair));
735+
MonoDelegateClassMethodPair* res = NULL;
736+
if (temporary)
737+
res = (MonoDelegateClassMethodPair*)g_malloc0 (sizeof (MonoDelegateClassMethodPair));
738+
else
739+
res = (MonoDelegateClassMethodPair*)mono_image_alloc0 (m_class_get_image (klass), sizeof (MonoDelegateClassMethodPair));
740+
737741
res->is_virtual = dele_info->is_virtual;
738742
res->method = method;
739-
res->klass = klass;
743+
res->klass = inflated_klass;
740744
return res;
741745

742746
}
@@ -763,6 +767,9 @@ free_inflated_info (MonoRgctxInfoType info_type, gpointer info)
763767
case MONO_RGCTX_INFO_CAST_CACHE:
764768
mono_metadata_free_type ((MonoType *)info);
765769
break;
770+
case MONO_RGCTX_INFO_DELEGATE_TRAMP_INFO:
771+
g_free (info);
772+
break;
766773
default:
767774
break;
768775
}

0 commit comments

Comments
 (0)