[llvm] Fix the calling of fault clauses in llvm compiled code. Fixes #58446. (#5286)
authorZoltan Varga <vargaz@gmail.com>
Mon, 31 Jul 2017 15:20:22 +0000 (11:20 -0400)
committerGitHub <noreply@github.com>
Mon, 31 Jul 2017 15:20:22 +0000 (11:20 -0400)
mono/mini/aot-tests.cs
mono/mini/mini-exceptions.c

index 36c7a15a3e8fe91e1c44ebe8d40cf6546c441994..7f3dafea5c602ab31d1db9590fca9253b7f2a265 100644 (file)
@@ -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<IEnumerable> ().GetEnumerator ().MoveNext (); };
+                       d ();
+               } catch (Exception ex) {
+               }
+               return 0;
+       }
 }
index c8a71c69378dac317a72716a0aa8cccb1182bc29..348bc3948c5a30575db3dc0836e9b501c5a12380 100644 (file)
@@ -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) {
                                                /*