From fab6cd35fc65f173ecd689b1fa4474eaa3f42435 Mon Sep 17 00:00:00 2001 From: monojenkins Date: Wed, 12 Aug 2020 20:02:36 -0400 Subject: [PATCH] [aot] Fix an assert which is hit for generic instances with a lot of arguments. (#40736) The c# compiler generates these for anonymous types. Fixes https://github.com/xamarin/xamarin-macios/issues/9289. Co-authored-by: vargaz --- src/mono/mono/mini/aot-compiler.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 63f6d12..4cb352e 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -3424,12 +3424,14 @@ get_shared_ginst_ref (MonoAotCompile *acfg, MonoGenericInst *ginst) guint32 offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->ginst_blob_hash, ginst)); if (!offset) { guint8 *buf2, *p2; + int len; - buf2 = (guint8 *)g_malloc (1024); + len = 1024 + (ginst->type_argc * 32); + buf2 = (guint8 *)g_malloc (len); p2 = buf2; encode_ginst (acfg, ginst, p2, &p2); - g_assert (p2 - buf2 < 1024); + g_assert (p2 - buf2 < len); offset = add_to_blob (acfg, buf2, p2 - buf2); g_free (buf2); -- 2.7.4