Skip to content

Commit cf66826

Browse files
authored
[mono][aot] Fix compilation crashes when type load exception is generated in code (#110078)
* [mono][aot] Fix stack state when emitting type load throw Method compilation was continuing and we ended up failing with invalid IL. * [mono][aot] Mark clauses as dead when replacing method code with exception throw In the final stages of method compilation, when trying to compute clause ranges, we were asserting because the clause bblocks haven't been reached for compilation.
1 parent 3dd006a commit cf66826

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/mono/mono/mini/method-to-ir.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -6262,6 +6262,9 @@ method_make_alwaysthrow_typeloadfailure (MonoCompile* cfg, MonoClass* klass)
62626262
mono_link_bblock (cfg, bb, cfg->bb_exit);
62636263

62646264
cfg->disable_inline = TRUE;
6265+
6266+
for (guint i = 0; i < cfg->header->num_clauses; i++)
6267+
cfg->clause_is_dead [i] = TRUE;
62656268
}
62666269

62676270
typedef union _MonoOpcodeParameter {
@@ -12111,14 +12114,13 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
1211112114
break;
1211212115
case MONO_CEE_INITOBJ:
1211312116
klass = mini_get_class (method, token, generic_context);
12117+
--sp;
1211412118
if (CLASS_HAS_FAILURE (klass)) {
1211512119
HANDLE_TYPELOAD_ERROR (cfg, klass);
1211612120
inline_costs += 10;
1211712121
break; // reached only in AOT
1211812122
}
1211912123

12120-
--sp;
12121-
1212212124
if (mini_class_is_reference (klass))
1212312125
MONO_EMIT_NEW_STORE_MEMBASE_IMM (cfg, OP_STORE_MEMBASE_IMM, sp [0]->dreg, 0, 0);
1212412126
else

0 commit comments

Comments
 (0)