Skip to content

Commit 9ee881a

Browse files
authored
[release/9.0-staging] [mono][aot] Fix compilation crashes when type load exception is generated in code (#110271)
* [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 5e05023 commit 9ee881a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6263,6 +6263,9 @@ method_make_alwaysthrow_typeloadfailure (MonoCompile* cfg, MonoClass* klass)
62636263
mono_link_bblock (cfg, bb, cfg->bb_exit);
62646264

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

62686271
typedef union _MonoOpcodeParameter {
@@ -12112,13 +12115,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
1211212115
break;
1211312116
case MONO_CEE_INITOBJ:
1211412117
klass = mini_get_class (method, token, generic_context);
12118+
--sp;
1211512119
if (CLASS_HAS_FAILURE (klass)) {
1211612120
HANDLE_TYPELOAD_ERROR (cfg, klass);
1211712121
inline_costs += 10;
1211812122
break; // reached only in AOT
1211912123
}
12120-
12121-
--sp;
1212212124

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

0 commit comments

Comments
 (0)