Skip to content

Commit 175a49e

Browse files
[mono][wasm] Disable AOTing methods which contain catch clauses inside finally/filter clauses. (#78732)
When the ENDFINALLY opcode of the outer clause is encountered while executing the inner catch clause from run_with_il_state (), it will assert since it doesn't know where to continue execution. Co-authored-by: Zoltan Varga <[email protected]>
1 parent b5e5ef6 commit 175a49e

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6554,8 +6554,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
65546554

65556555
if (cfg->llvm_only && cfg->interp && cfg->method == method && !cfg->deopt && !cfg->interp_entry_only) {
65566556
if (header->num_clauses) {
6557-
/* deopt is only disabled for gsharedvt */
6558-
g_assert (cfg->gsharedvt);
65596557
for (guint i = 0; i < header->num_clauses; ++i) {
65606558
MonoExceptionClause *clause = &header->clauses [i];
65616559
/* Finally clauses are checked after the remove_finally pass */

src/mono/mono/mini/mini.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3303,9 +3303,31 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts
33033303
}
33043304

33053305
if (cfg->llvm_only && cfg->interp && !cfg->interp_entry_only && header->num_clauses) {
3306-
cfg->deopt = TRUE;
3307-
/* Can't reconstruct inlined state */
3308-
cfg->disable_inline = TRUE;
3306+
gboolean can_deopt = TRUE;
3307+
/*
3308+
* Can't handle catch clauses inside finally clauses right now.
3309+
* When the ENDFINALLY opcode of the outer clause is encountered
3310+
* while executing the inner catch clause from run_with_il_state (),
3311+
* it will assert since it doesn't know where to continue execution.
3312+
*/
3313+
for (guint i = 0; i < cfg->header->num_clauses; ++i) {
3314+
for (guint j = 0; j < cfg->header->num_clauses; ++j) {
3315+
MonoExceptionClause *clause1 = &cfg->header->clauses [i];
3316+
MonoExceptionClause *clause2 = &cfg->header->clauses [j];
3317+
3318+
if (i != j && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset) {
3319+
if (clause1->flags == MONO_EXCEPTION_CLAUSE_NONE && clause2->flags != MONO_EXCEPTION_CLAUSE_NONE) {
3320+
can_deopt = FALSE;
3321+
break;
3322+
}
3323+
}
3324+
}
3325+
}
3326+
if (can_deopt) {
3327+
cfg->deopt = TRUE;
3328+
/* Can't reconstruct inlined state */
3329+
cfg->disable_inline = TRUE;
3330+
}
33093331
}
33103332

33113333
#ifdef ENABLE_LLVM

0 commit comments

Comments
 (0)