Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix domain reload crash in inflate_info. #1894

Draft
wants to merge 1 commit into
base: unity-2021.3-mbe
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions mono/mini/mini-generic-sharing.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,17 +726,21 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
MonoType *t = mono_class_inflate_generic_type_checked (m_class_get_byval_arg (dele_info->klass), context, error);
mono_error_assert_msg_ok (error, "Could not inflate generic type"); /* FIXME proper error handling */

MonoClass *klass = mono_class_from_mono_type_internal (t);
MonoClass *inflated_klass = mono_class_from_mono_type_internal (t);
mono_metadata_free_type (t);

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

// FIXME: Temporary
MonoDelegateClassMethodPair *res = (MonoDelegateClassMethodPair *)mono_domain_alloc0 (domain, sizeof (MonoDelegateClassMethodPair));
MonoDelegateClassMethodPair* res = NULL;
if (temporary)
res = (MonoDelegateClassMethodPair*)g_malloc0 (sizeof (MonoDelegateClassMethodPair));
else
res = (MonoDelegateClassMethodPair*)mono_image_alloc0 (m_class_get_image (klass), sizeof (MonoDelegateClassMethodPair));

res->is_virtual = dele_info->is_virtual;
res->method = method;
res->klass = klass;
res->klass = inflated_klass;
return res;

}
Expand All @@ -763,6 +767,9 @@ free_inflated_info (MonoRgctxInfoType info_type, gpointer info)
case MONO_RGCTX_INFO_CAST_CACHE:
mono_metadata_free_type ((MonoType *)info);
break;
case MONO_RGCTX_INFO_DELEGATE_TRAMP_INFO:
g_free (info);
break;
default:
break;
}
Expand Down