[interp] fix type init exception propagation for methods that trigger static constructors
authorBernhard Urban <bernhard.urban@xamarin.com>
Tue, 7 Mar 2017 09:47:00 +0000 (10:47 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Wed, 8 Mar 2017 22:02:51 +0000 (23:02 +0100)
mono/mini/exceptions.cs
mono/mini/interp/interp.c
mono/mini/interp/transform.c

index d13385e35bb09348a29b3760622749223b02fbba..4755adbaab1f01f086f98a416846348c5356ca8a 100644 (file)
@@ -2230,7 +2230,6 @@ class Tests
                }
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_exception_in_cctor () {
                try {
                        Broken.DoSomething ();
index c37652d68ad1b1651adcdfdd751ae505b8ddcd9c..4d70808a41e5d641b24d0ab93610f97a661ab91c 100644 (file)
@@ -1930,7 +1930,7 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
                                 * An exception occurred, need to run finally, fault and catch handlers..
                                 */
                                frame->ex = child_frame.ex;
-                               goto handle_finally;
+                               goto handle_exception;;
                        }
 
                        /* need to handle typedbyref ... */
index e4cb8c8c20ac4c66166b752fc87146f9b80eaaa3..f207fbea0835e29e960f60434ce0118bce8b1815 100644 (file)
@@ -3250,9 +3250,11 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
        // g_printerr ("TRANSFORM(0x%016lx): begin %s::%s\n", mono_thread_current (), method->klass->name, method->name);
        method_class_vt = mono_class_vtable (domain, runtime_method->method->klass);
        if (!method_class_vt->initialized) {
+               MonoError error;
                jmp_buf env;
                MonoInvocation *last_env_frame = context->env_frame;
                jmp_buf *old_env = context->current_env;
+               error_init (&error);
 
                if (setjmp(env)) {
                        MonoException *failed = context->env_frame->ex;
@@ -3263,7 +3265,10 @@ mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *cont
                }
                context->env_frame = context->current_frame;
                context->current_env = &env;
-               mono_runtime_class_init (method_class_vt);
+               mono_runtime_class_init_full (method_class_vt, &error);
+               if (!mono_error_ok (&error)) {
+                       return mono_error_convert_to_exception (&error);
+               }
                context->env_frame = last_env_frame;
                context->current_env = old_env;
        }