Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigo Kumpera <kumpera@gmail.com>2015-11-06 10:47:03 +0300
committerRodrigo Kumpera <kumpera@gmail.com>2016-01-27 00:23:34 +0300
commitd7908572783b1a8f3b6f4b4685385a7becf0bab3 (patch)
tree9917955894da68e89e1b8f3f34cd1ddbb516de4e
parentf100c2f5ff1a626fa4f467973e5cff7e5b2d3692 (diff)
[mono-error] Replace legacy calls to mono_get_method(_full) with _checked variant.
-rw-r--r--mono/metadata/attach.c6
-rw-r--r--mono/metadata/coree.c4
-rw-r--r--mono/metadata/debug-helpers.c7
-rw-r--r--mono/metadata/marshal.c5
-rw-r--r--mono/metadata/metadata-verify.c8
-rw-r--r--mono/metadata/reflection.c6
-rw-r--r--mono/mini/aot-compiler.c4
-rw-r--r--mono/mini/aot-runtime.c70
-rw-r--r--mono/mini/debugger-agent.c5
-rw-r--r--mono/mini/driver.c33
-rw-r--r--mono/mini/dwarfwriter.c10
-rw-r--r--mono/mini/method-to-ir.c5
-rw-r--r--mono/mini/mini-runtime.c8
-rw-r--r--mono/mini/mini-trampolines.c6
14 files changed, 130 insertions, 47 deletions
diff --git a/mono/metadata/attach.c b/mono/metadata/attach.c
index 4f5024a72f0..e41bbf7d02b 100644
--- a/mono/metadata/attach.c
+++ b/mono/metadata/attach.c
@@ -265,6 +265,7 @@ mono_attach_cleanup (void)
static int
mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject **exc)
{
+ MonoError error;
MonoAssembly *agent_assembly;
MonoImage *image;
MonoMethod *method;
@@ -292,9 +293,10 @@ mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject
return 1;
}
- method = mono_get_method (image, entry, NULL);
+ method = mono_get_method_checked (image, entry, NULL, NULL, &error);
if (method == NULL){
- g_print ("The entry point method of assembly '%s' could not be loaded\n", agent);
+ g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, mono_error_get_message (&error));
+ mono_error_cleanup (&error);
g_free (agent);
return 1;
}
diff --git a/mono/metadata/coree.c b/mono/metadata/coree.c
index d722271ebb7..7c4be6afe7e 100644
--- a/mono/metadata/coree.c
+++ b/mono/metadata/coree.c
@@ -136,6 +136,7 @@ BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpRes
/* Called by ntdll.dll reagardless of entry point after _CorValidateImage. */
__int32 STDMETHODCALLTYPE _CorExeMain(void)
{
+ MonoError error;
MonoDomain* domain;
MonoAssembly* assembly;
MonoImage* image;
@@ -179,9 +180,10 @@ __int32 STDMETHODCALLTYPE _CorExeMain(void)
ExitProcess (1);
}
- method = mono_get_method (image, entry, NULL);
+ method = mono_get_method_checked (image, entry, NULL, NULL, &error);
if (method == NULL) {
g_free (file_name);
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
MessageBox (NULL, L"The entry point method could not be loaded.", NULL, MB_ICONERROR);
mono_runtime_quit ();
ExitProcess (1);
diff --git a/mono/metadata/debug-helpers.c b/mono/metadata/debug-helpers.c
index db4b765fbde..27c885bc41b 100644
--- a/mono/metadata/debug-helpers.c
+++ b/mono/metadata/debug-helpers.c
@@ -541,12 +541,17 @@ mono_method_desc_search_in_image (MonoMethodDesc *desc, MonoImage *image)
mono_image_get_table_info (image, MONO_TABLE_TYPEDEF);
methods = mono_image_get_table_info (image, MONO_TABLE_METHOD);
for (i = 0; i < mono_table_info_get_rows (methods); ++i) {
+ MonoError error;
guint32 token = mono_metadata_decode_row_col (methods, i, MONO_METHOD_NAME);
const char *n = mono_metadata_string_heap (image, token);
if (strcmp (n, desc->name))
continue;
- method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
+ method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+ if (!method) {
+ mono_error_cleanup (&error);
+ continue;
+ }
if (mono_method_desc_full_match (desc, method))
return method;
}
diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c
index 8ae146eccde..3c6768041b2 100644
--- a/mono/metadata/marshal.c
+++ b/mono/metadata/marshal.c
@@ -8155,6 +8155,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
gpointer
mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
{
+ MonoError error;
MonoMethod *method;
MonoMethodSignature *sig;
MonoMethodBuilder *mb;
@@ -8162,7 +8163,9 @@ mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type)
g_assert (token);
- method = mono_get_method (image, token, NULL);
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ if (!method)
+ g_error ("Could not load vtfixup token 0x%x due to %s", token, mono_error_get_message (&error));
g_assert (method);
if (type & (VTFIXUP_TYPE_FROM_UNMANAGED | VTFIXUP_TYPE_FROM_UNMANAGED_RETAIN_APPDOMAIN)) {
diff --git a/mono/metadata/metadata-verify.c b/mono/metadata/metadata-verify.c
index 65f3bba5686..753e5269e92 100644
--- a/mono/metadata/metadata-verify.c
+++ b/mono/metadata/metadata-verify.c
@@ -2925,6 +2925,7 @@ verify_cattr_table (VerifyContext *ctx)
static void
verify_cattr_table_full (VerifyContext *ctx)
{
+ MonoError error;
MonoTableInfo *table = &ctx->image->tables [MONO_TABLE_CUSTOMATTRIBUTE];
MonoMethod *ctor;
const char *ptr;
@@ -2949,7 +2950,12 @@ verify_cattr_table_full (VerifyContext *ctx)
ADD_ERROR (ctx, g_strdup_printf ("Invalid CustomAttribute constructor row %d Token 0x%08x", i, data [MONO_CUSTOM_ATTR_TYPE]));
}
- ctor = mono_get_method (ctx->image, mtoken, NULL);
+ ctor = mono_get_method_checked (ctx->image, mtoken, NULL, NULL, &error);
+
+ if (!ctor) {
+ ADD_ERROR (ctx, g_strdup_printf ("Invalid CustomAttribute content row %d Could not load ctor due to %s", i, mono_error_get_message (&error)));
+ mono_error_cleanup (&error);
+ }
/*This can't fail since this is checked in is_valid_cattr_blob*/
g_assert (decode_signature_header (ctx, data [MONO_CUSTOM_ATTR_VALUE], &size, &ptr));
diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c
index 4bba73e3620..591820d0065 100644
--- a/mono/metadata/reflection.c
+++ b/mono/metadata/reflection.c
@@ -9083,6 +9083,7 @@ mono_custom_attrs_from_index (MonoImage *image, guint32 idx)
ainfo->num_attrs = len;
ainfo->image = image;
for (i = len, tmp = list; i != 0; --i, tmp = tmp->next) {
+ MonoError error;
mono_metadata_decode_row (ca, GPOINTER_TO_UINT (tmp->data), cols, MONO_CUSTOM_ATTR_SIZE);
mtoken = cols [MONO_CUSTOM_ATTR_TYPE] >> MONO_CUSTOM_ATTR_TYPE_BITS;
switch (cols [MONO_CUSTOM_ATTR_TYPE] & MONO_CUSTOM_ATTR_TYPE_MASK) {
@@ -9097,9 +9098,10 @@ mono_custom_attrs_from_index (MonoImage *image, guint32 idx)
break;
}
attr = &ainfo->attrs [i - 1];
- attr->ctor = mono_get_method (image, mtoken, NULL);
+ attr->ctor = mono_get_method_checked (image, mtoken, NULL, NULL, &error);
if (!attr->ctor) {
- g_warning ("Can't find custom attr constructor image: %s mtoken: 0x%08x", image->name, mtoken);
+ g_warning ("Can't find custom attr constructor image: %s mtoken: 0x%08x due to %s", image->name, mtoken, mono_error_get_message (&error));
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
g_list_free (list);
g_free (ainfo);
return NULL;
diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c
index 1e994651997..0c02a8e416f 100644
--- a/mono/mini/aot-compiler.c
+++ b/mono/mini/aot-compiler.c
@@ -3695,10 +3695,12 @@ add_wrappers (MonoAotCompile *acfg)
#if 0
/* remoting-invoke wrappers */
for (i = 0; i < acfg->image->tables [MONO_TABLE_METHOD].rows; ++i) {
+ MonoError error;
MonoMethodSignature *sig;
token = MONO_TOKEN_METHOD_DEF | (i + 1);
- method = mono_get_method (acfg->image, token, NULL);
+ method = mono_get_method_checked (acfg->image, token, NULL, NULL, &error);
+ g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
sig = mono_method_signature (method);
diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c
index 28f72b83fb0..aa544c8006f 100644
--- a/mono/mini/aot-runtime.c
+++ b/mono/mini/aot-runtime.c
@@ -1217,9 +1217,11 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
if (!image)
return FALSE;
- ref->method = mono_get_method_full (image, ref->token, NULL, NULL);
- if (!ref->method)
+ ref->method = mono_get_method_checked (image, ref->token, NULL, NULL, &error);
+ if (!ref->method) {
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
return FALSE;
+ }
memset (&ctx, 0, sizeof (ctx));
@@ -1228,7 +1230,8 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
ctx.method_inst = NULL;
ref->method = mono_class_inflate_generic_method_full_checked (ref->method, klass, &ctx, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ if (!ref->method)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
}
memset (&ctx, 0, sizeof (ctx));
@@ -1237,7 +1240,9 @@ decode_method_ref_with_target (MonoAotModule *module, MethodRef *ref, MonoMethod
return FALSE;
ref->method = mono_class_inflate_generic_method_full_checked (ref->method, klass, &ctx, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ if (!ref->method)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+
} else if (image_index == MONO_AOT_METHODREF_ARRAY) {
MonoClass *klass;
int method_type;
@@ -1299,8 +1304,10 @@ decode_method_ref (MonoAotModule *module, MethodRef *ref, guint8 *buf, guint8 **
static MonoMethod*
decode_resolve_method_ref_with_target (MonoAotModule *module, MonoMethod *target, guint8 *buf, guint8 **endbuf)
{
+ MonoError error;
MethodRef ref;
gboolean res;
+ MonoMethod *result;
res = decode_method_ref_with_target (module, &ref, target, buf, endbuf);
if (!res)
@@ -1309,7 +1316,10 @@ decode_resolve_method_ref_with_target (MonoAotModule *module, MonoMethod *target
return ref.method;
if (!ref.image)
return NULL;
- return mono_get_method (ref.image, ref.token, NULL);
+ result = mono_get_method_checked (ref.image, ref.token, NULL, NULL, &error);
+ if (!result)
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
+ return result;
}
static MonoMethod*
@@ -3312,8 +3322,11 @@ mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr)
/* Happens when a random address is passed in which matches a not-yey called wrapper encoded using its name */
return NULL;
} else {
+ MonoError error;
token = mono_metadata_make_token (MONO_TABLE_METHOD, method_index + 1);
- method = mono_get_method (image, token, NULL);
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ if (!method)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
}
}
/* FIXME: */
@@ -3390,10 +3403,14 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
ji->type = MONO_PATCH_INFO_ABS;
}
else {
- if (ref.method)
+ if (ref.method) {
ji->data.method = ref.method;
- else
- ji->data.method = mono_get_method (ref.image, ref.token, NULL);
+ }else {
+ MonoError error;
+ ji->data.method = mono_get_method_checked (ref.image, ref.token, NULL, NULL, &error);
+ if (!ji->data.method)
+ g_error ("AOT Runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+ }
g_assert (ji->data.method);
mono_class_init (ji->data.method->klass);
}
@@ -3770,8 +3787,11 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT)) {
char *full_name;
- if (!method)
- method = mono_get_method (image, token, NULL);
+ if (!method) {
+ MonoError error;
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ }
full_name = mono_method_full_name (method, TRUE);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: NOT FOUND: %s.", full_name);
g_free (full_name);
@@ -3802,8 +3822,12 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
if (mono_jit_stats.methods_aot >= mono_last_aot_method)
return NULL;
else if (mono_jit_stats.methods_aot == mono_last_aot_method - 1) {
- if (!method)
- method = mono_get_method (image, token, NULL);
+ if (!method) {
+ MonoError error;
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ if (!method)
+ mono_error_cleanup (&error);/* FIXME don't swallow the error */
+ }
if (method) {
char *name = mono_method_full_name (method, TRUE);
g_print ("LAST AOT METHOD: %s.\n", name);
@@ -3823,8 +3847,12 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT)) {
char *full_name;
- if (!method)
- method = mono_get_method (image, token, NULL);
+ if (!method) {
+ MonoError error;
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ if (!method)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+ }
full_name = mono_method_full_name (method, TRUE);
@@ -3852,8 +3880,10 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
MonoJitInfo *jinfo;
if (!method) {
- method = mono_get_method (amodule->assembly->image, token, NULL);
- g_assert (method);
+ MonoError error;
+ method = mono_get_method_checked (amodule->assembly->image, token, NULL, NULL, &error);
+ if (!method)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
}
mono_profiler_method_jit (method);
jinfo = mono_jit_info_table_find (domain, (char*)code);
@@ -4328,7 +4358,8 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
ctx.method_inst = mono_metadata_get_generic_inst (1, args);
m = mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (m, &ctx, &error), TRUE, TRUE);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ if (!m)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
/*
* Get the code for the <object> instantiation which should be emitted into
@@ -4362,7 +4393,8 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
ctx.method_inst = mono_metadata_get_generic_inst (1, args);
m = mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (m, &ctx, &error), TRUE, TRUE);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ if (!m)
+ g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
/* Avoid recursion */
if (method == m)
diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c
index 7340ac302cf..b52c5de38e1 100644
--- a/mono/mini/debugger-agent.c
+++ b/mono/mini/debugger-agent.c
@@ -7628,7 +7628,10 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
if (token == 0) {
buffer_add_id (buf, 0);
} else {
- m = mono_get_method (ass->image, token, NULL);
+ MonoError error;
+ m = mono_get_method_checked (ass->image, token, NULL, NULL, &error);
+ if (!m)
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
buffer_add_methodid (buf, domain, m);
}
}
diff --git a/mono/mini/driver.c b/mono/mini/driver.c
index c801bd9ed21..2bf88c38789 100644
--- a/mono/mini/driver.c
+++ b/mono/mini/driver.c
@@ -382,9 +382,12 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total,
if (mini_stats_fd)
fprintf (mini_stats_fd, "[");
for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
- MonoMethod *method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
- if (!method)
+ MonoError error;
+ MonoMethod *method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+ if (!method) {
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
continue;
+ }
if (strncmp (method->name, "test_", 5) == 0) {
MonoCompile *cfg;
@@ -475,9 +478,12 @@ mini_regression (MonoImage *image, int verbose, int *total_run)
/* load the metadata */
for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
- method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
- if (!method)
+ MonoError error;
+ method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+ if (!method) {
+ mono_error_cleanup (&error);
continue;
+ }
mono_class_init (method->klass);
if (!strncmp (method->name, "test_", 5) && mini_stats_fd) {
@@ -905,15 +911,18 @@ compile_all_methods_thread_main_inner (CompileAllThreadArgs *args)
int i, count = 0, fail_count = 0;
for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+ MonoError error;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
MonoMethodSignature *sig;
if (mono_metadata_has_generic_params (image, token))
continue;
- method = mono_get_method (image, token, NULL);
- if (!method)
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ if (!method) {
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
continue;
+ }
if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
@@ -990,6 +999,7 @@ compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts, guint32 recom
int
mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
{
+ MonoError error;
MonoImage *image = mono_assembly_get_image (assembly);
MonoMethod *method;
guint32 entry = mono_image_get_entry_point (image);
@@ -1001,9 +1011,10 @@ mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[
return 1;
}
- method = mono_get_method (image, entry, NULL);
+ method = mono_get_method_checked (image, entry, NULL, NULL, &error);
if (method == NULL){
- g_print ("The entry point method could not be loaded\n");
+ g_print ("The entry point method could not be loaded due to %s\n", mono_error_get_message (&error));
+ mono_error_cleanup (&error);
mono_environment_exitcode_set (1);
return 1;
}
@@ -1074,6 +1085,7 @@ static void main_thread_handler (gpointer user_data)
static int
load_agent (MonoDomain *domain, char *desc)
{
+ MonoError error;
char* col = strchr (desc, ':');
char *agent, *args;
MonoAssembly *agent_assembly;
@@ -1112,9 +1124,10 @@ load_agent (MonoDomain *domain, char *desc)
return 1;
}
- method = mono_get_method (image, entry, NULL);
+ method = mono_get_method_checked (image, entry, NULL, NULL, &error);
if (method == NULL){
- g_print ("The entry point method of assembly '%s' could not be loaded\n", agent);
+ g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, &error);
+ mono_error_cleanup (&error);
g_free (agent);
return 1;
}
diff --git a/mono/mini/dwarfwriter.c b/mono/mini/dwarfwriter.c
index 771c1be1e7f..f925ccf3f9c 100644
--- a/mono/mini/dwarfwriter.c
+++ b/mono/mini/dwarfwriter.c
@@ -1429,10 +1429,14 @@ token_handler (MonoDisHelper *dh, MonoMethod *method, guint32 token)
case CEE_NEWOBJ:
case CEE_CALL:
case CEE_CALLVIRT:
- if (method->wrapper_type)
+ if (method->wrapper_type) {
cmethod = (MonoMethod *)data;
- else
- cmethod = mono_get_method_full (method->klass->image, token, NULL, NULL);
+ } else {
+ MonoError error;
+ cmethod = mono_get_method_checked (method->klass->image, token, NULL, NULL, &error);
+ if (!cmethod)
+ g_error ("Could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+ }
desc = mono_method_full_name (cmethod, TRUE);
res = g_strdup_printf ("<%s>", desc);
g_free (desc);
diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c
index 4c0a925becf..e582e6146de 100644
--- a/mono/mini/method-to-ir.c
+++ b/mono/mini/method-to-ir.c
@@ -7375,17 +7375,18 @@ exception_exit:
static inline MonoMethod *
mini_get_method_allow_open (MonoMethod *m, guint32 token, MonoClass *klass, MonoGenericContext *context)
{
+ MonoError error;
MonoMethod *method;
if (m->wrapper_type != MONO_WRAPPER_NONE) {
method = (MonoMethod *)mono_method_get_wrapper_data (m, token);
if (context) {
- MonoError error;
method = mono_class_inflate_generic_method_checked (method, context, &error);
g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
}
} else {
- method = mono_get_method_full (m->klass->image, token, klass, context);
+ method = mono_get_method_checked (m->klass->image, token, klass, context, &error);
+ g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
}
return method;
diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c
index c7270e2a8ec..a027ec1c9bf 100644
--- a/mono/mini/mini-runtime.c
+++ b/mono/mini/mini-runtime.c
@@ -4117,7 +4117,13 @@ mono_precompile_assembly (MonoAssembly *ass, void *user_data)
printf ("PRECOMPILE: %s.\n", mono_image_get_filename (image));
for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
- method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
+ MonoError error;
+
+ method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+ if (!method) {
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
+ continue;
+ }
if (method->flags & METHOD_ATTRIBUTE_ABSTRACT)
continue;
if (method->is_generic || method->klass->generic_container)
diff --git a/mono/mini/mini-trampolines.c b/mono/mini/mini-trampolines.c
index d40ace4cd3e..f1fe616b969 100644
--- a/mono/mini/mini-trampolines.c
+++ b/mono/mini/mini-trampolines.c
@@ -954,8 +954,10 @@ mono_aot_trampoline (mgreg_t *regs, guint8 *code, guint8 *token_info,
addr = mono_aot_get_method_from_token (mono_domain_get (), image, token);
if (!addr) {
- method = mono_get_method (image, token, NULL);
- g_assert (method);
+ MonoError error;
+ method = mono_get_method_checked (image, token, NULL, NULL, &error);
+ if (!method)
+ g_error ("Could not load AOT trampoline due to %s", mono_error_get_message (&error));
/* Use the generic code */
return mono_magic_trampoline (regs, code, method, tramp);