From 02a37d08735c8079920f27d49d9de33cf230ac29 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Mon, 31 Jul 2017 17:46:50 -0400 Subject: [PATCH] [llvm] Fix the calling of fault clauses in llvm compiled code. Fixes #58446. --- mono/mini/aot-tests.cs | 13 +++++++++++++ mono/mini/mini-exceptions.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/mono/mini/aot-tests.cs b/mono/mini/aot-tests.cs index 36c7a15a3e8f..7f3dafea5c60 100644 --- a/mono/mini/aot-tests.cs +++ b/mono/mini/aot-tests.cs @@ -4,6 +4,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -485,4 +486,16 @@ public static int test_0_array_wrappers_runtime_invoke () { m.Invoke (arr, null); return 0; } + + public static int test_0_fault_clauses () { + object [] data = { 1, 2, 3 }; + int [] expected = { 1, 2, 3 }; + + try { + Action d = delegate () { data.Cast ().GetEnumerator ().MoveNext (); }; + d (); + } catch (Exception ex) { + } + return 0; + } } diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index 8a1032adb225..5a5d0af1e977 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -2010,8 +2010,6 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu jit_tls->orig_ex_ctx_set = TRUE; mono_profiler_exception_clause_handler (method, ei->flags, i); jit_tls->orig_ex_ctx_set = FALSE; - mini_set_abort_threshold (ctx); - call_filter (ctx, ei->handler_start); } if (ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY) { if (mono_trace_is_enabled () && mono_trace_eval (method)) @@ -2022,6 +2020,8 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu #ifndef DISABLE_PERFCOUNTERS mono_perfcounters->exceptions_finallys++; #endif + } + if (ei->flags == MONO_EXCEPTION_CLAUSE_FAULT || ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY) { mono_set_lmf (lmf); if (ji->from_llvm) { /*