Skip to content

Commit

Permalink
[mono][wasm] Disable AOTing methods which contain catch clauses insid…
Browse files Browse the repository at this point in the history
…e 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]>
  • Loading branch information
github-actions[bot] and vargaz authored Nov 29, 2022
1 parent b5e5ef6 commit 175a49e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6554,8 +6554,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b

if (cfg->llvm_only && cfg->interp && cfg->method == method && !cfg->deopt && !cfg->interp_entry_only) {
if (header->num_clauses) {
/* deopt is only disabled for gsharedvt */
g_assert (cfg->gsharedvt);
for (guint i = 0; i < header->num_clauses; ++i) {
MonoExceptionClause *clause = &header->clauses [i];
/* Finally clauses are checked after the remove_finally pass */
Expand Down
28 changes: 25 additions & 3 deletions src/mono/mono/mini/mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -3303,9 +3303,31 @@ mini_method_compile (MonoMethod *method, guint32 opts, JitFlags flags, int parts
}

if (cfg->llvm_only && cfg->interp && !cfg->interp_entry_only && header->num_clauses) {
cfg->deopt = TRUE;
/* Can't reconstruct inlined state */
cfg->disable_inline = TRUE;
gboolean can_deopt = TRUE;
/*
* Can't handle catch clauses inside finally clauses right now.
* 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.
*/
for (guint i = 0; i < cfg->header->num_clauses; ++i) {
for (guint j = 0; j < cfg->header->num_clauses; ++j) {
MonoExceptionClause *clause1 = &cfg->header->clauses [i];
MonoExceptionClause *clause2 = &cfg->header->clauses [j];

if (i != j && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset) {
if (clause1->flags == MONO_EXCEPTION_CLAUSE_NONE && clause2->flags != MONO_EXCEPTION_CLAUSE_NONE) {
can_deopt = FALSE;
break;
}
}
}
}
if (can_deopt) {
cfg->deopt = TRUE;
/* Can't reconstruct inlined state */
cfg->disable_inline = TRUE;
}
}

#ifdef ENABLE_LLVM
Expand Down

0 comments on commit 175a49e

Please sign in to comment.