From: Zoltan Varga Date: Mon, 31 Jul 2017 15:20:22 +0000 (-0400) Subject: [llvm] Fix the calling of fault clauses in llvm compiled code. Fixes #58446. (#5286) X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=f0398a70a52b66e4f0aec55cc760712e5f84aaeb;p=mono.git [llvm] Fix the calling of fault clauses in llvm compiled code. Fixes #58446. (#5286) --- diff --git a/mono/mini/aot-tests.cs b/mono/mini/aot-tests.cs index 36c7a15a3e8..7f3dafea5c6 100644 --- a/mono/mini/aot-tests.cs +++ b/mono/mini/aot-tests.cs @@ -4,6 +4,7 @@ using System.Linq; 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 @@ class Tests 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 c8a71c69378..348bc3948c5 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -2186,8 +2186,6 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu jit_tls->orig_ex_ctx_set = TRUE; MONO_PROFILER_RAISE (exception_clause, (method, i, ei->flags, ex_obj)); 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)) @@ -2198,6 +2196,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) { /*