From b820b5854d048cba6cfedcb6d0a0b8ba08a02189 Mon Sep 17 00:00:00 2001 From: Vlad Brezae Date: Thu, 23 Jan 2025 19:35:07 +0200 Subject: [PATCH] [mono][mini] Disable inlining if we encounter class initialization failure method_make_alwaysthrow_typeloadfailure replaces the entire method code with a throw of type load exception. This behaviour not only seem dubious, if it is triggered from inlining a method, that might never even get called, but it also does changes to the set of basic blocks that can lead to crashes later on during compilation. --- src/mono/mono/mini/method-to-ir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/method-to-ir.c b/src/mono/mono/mini/method-to-ir.c index 651ef6e8988c35..96992d29557990 100644 --- a/src/mono/mono/mini/method-to-ir.c +++ b/src/mono/mono/mini/method-to-ir.c @@ -10143,6 +10143,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b EMIT_NEW_PCONST (cfg, *sp, NULL); sp++; } else if (il_op == MONO_CEE_LDFLD || il_op == MONO_CEE_LDSFLD) { + // method_make_alwaysthrow_typeloadfailure currently doesn't work with inlining + INLINE_FAILURE("type load error"); // An object is expected here. It may be impossible to correctly infer its type, // we turn this entire method into a throw. method_make_alwaysthrow_typeloadfailure (cfg, klass);