From 9b37c9870b2f9b91a3863dba85b76e383f7574ae Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 10 Jul 2023 19:07:24 -0400 Subject: [PATCH] [mono][aot] Avoid prefer-ing gsharedvt versions of AsyncMethodBuilderCore etc. methods in profile-only mode. (#87990) The gsharedvt versions might not be generated if they are not in the profile, leading to crashes at runtime. Fixes https://github.com/dotnet/runtime/issues/87856. --- src/mono/mono/mini/aot-compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 7873a3cf369592..c7e2141171c759 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4300,7 +4300,7 @@ static gboolean prefer_gsharedvt_method (MonoAotCompile *acfg, MonoMethod *method) { /* One instantiation with valuetypes is generated for each async method */ - if (m_class_get_image (method->klass) == mono_defaults.corlib && (!strcmp (m_class_get_name (method->klass), "AsyncMethodBuilderCore") || !strcmp (m_class_get_name (method->klass), "AsyncVoidMethodBuilder"))) + if (!acfg->aot_opts.profile_only && m_class_get_image (method->klass) == mono_defaults.corlib && (!strcmp (m_class_get_name (method->klass), "AsyncMethodBuilderCore") || !strcmp (m_class_get_name (method->klass), "AsyncVoidMethodBuilder"))) return TRUE; else return FALSE;