From 9b51ee25f4fb9ffb79f8216fee1e85dd4ed1a7b3 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Fri, 30 Aug 2019 10:30:58 -0700 Subject: [PATCH] [coop] mono_runtime_class_init_full (mono/mono#16580) Commit migrated from https://github.com/mono/mono/commit/86c45ff645e59c997341ac44e95d03d4491c50eb --- src/mono/mono/metadata/object.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/metadata/object.c b/src/mono/mono/metadata/object.c index f9245bf..a372b21 100644 --- a/src/mono/mono/metadata/object.c +++ b/src/mono/mono/metadata/object.c @@ -473,9 +473,12 @@ mono_runtime_class_init_full (MonoVTable *vtable, MonoError *error) gboolean ret = FALSE; + HANDLE_FUNCTION_ENTER (); + if (vtable->init_failed) { /* The type initialization already failed once, rethrow the same exception */ MonoException *exp = get_type_init_exception_for_vtable (vtable); + MONO_HANDLE_NEW (MonoException, exp); /* Reset the stack_trace and trace_ips because the exception is reused */ exp->stack_trace = NULL; exp->trace_ips = NULL; @@ -544,12 +547,14 @@ mono_runtime_class_init_full (MonoVTable *vtable, MonoError *error) mono_threads_begin_abort_protected_block (); mono_runtime_try_invoke (method, NULL, NULL, (MonoObject**) &exc, error); + MonoExceptionHandle exch = MONO_HANDLE_NEW (MonoException, exc); mono_threads_end_abort_protected_block (); //exception extracted, error will be set to the right value later - if (exc == NULL && !is_ok (error))//invoking failed but exc was not set + if (exc == NULL && !is_ok (error)) { // invoking failed but exc was not set exc = mono_error_convert_to_exception (error); - else + MONO_HANDLE_ASSIGN_RAW (exch, exc); + } else mono_error_cleanup (error); error_init_reuse (error); @@ -572,6 +577,7 @@ mono_runtime_class_init_full (MonoVTable *vtable, MonoError *error) full_name = g_strdup (klass_name); MonoException *exc_to_throw = mono_get_exception_type_initialization_checked (full_name, exc, error); + MONO_HANDLE_NEW (MonoException, exc_to_throw); g_free (full_name); mono_error_assert_ok (error); //We can't recover from this, no way to fail a type we can't alloc a failure. @@ -641,7 +647,7 @@ return_true: return_false: ret = FALSE; exit: - return ret; + HANDLE_FUNCTION_RETURN_VAL (ret); } MonoDomain * -- 2.7.4