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-16 08:22:56 +0300
committerRodrigo Kumpera <kumpera@gmail.com>2016-01-27 04:12:18 +0300
commit68795e408196d2467b5efce340dc005de1a1c535 (patch)
tree17d069bd4651ff444f4bb6a8951b0a5b800ebb34
parentd7908572783b1a8f3b6f4b4685385a7becf0bab3 (diff)
[jit] Fix error propagation when loading methods. Move more checks to rely on cfg->error.
-rw-r--r--mono/mini/method-to-ir.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c
index e582e6146de..cc63ef267e2 100644
--- a/mono/mini/method-to-ir.c
+++ b/mono/mini/method-to-ir.c
@@ -7373,20 +7373,19 @@ exception_exit:
}
static inline MonoMethod *
-mini_get_method_allow_open (MonoMethod *m, guint32 token, MonoClass *klass, MonoGenericContext *context)
+mini_get_method_allow_open (MonoMethod *m, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error)
{
- MonoError error;
MonoMethod *method;
+ mono_error_init (error);
+
if (m->wrapper_type != MONO_WRAPPER_NONE) {
method = (MonoMethod *)mono_method_get_wrapper_data (m, token);
if (context) {
- method = mono_class_inflate_generic_method_checked (method, context, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ method = mono_class_inflate_generic_method_checked (method, context, error);
}
} else {
- method = mono_get_method_checked (m->klass->image, token, klass, context, &error);
- g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+ method = mono_get_method_checked (m->klass->image, token, klass, context, error);
}
return method;
@@ -7395,10 +7394,16 @@ mini_get_method_allow_open (MonoMethod *m, guint32 token, MonoClass *klass, Mono
static inline MonoMethod *
mini_get_method (MonoCompile *cfg, MonoMethod *m, guint32 token, MonoClass *klass, MonoGenericContext *context)
{
- MonoMethod *method = mini_get_method_allow_open (m, token, klass, context);
+ MonoError error;
+ MonoMethod *method = mini_get_method_allow_open (m, token, klass, context, cfg ? &cfg->error : &error);
- if (method && cfg && !cfg->gshared && mono_class_is_open_constructed_type (&method->klass->byval_arg))
- return NULL;
+ if (method && cfg && !cfg->gshared && mono_class_is_open_constructed_type (&method->klass->byval_arg)) {
+ mono_error_set_bad_image (&cfg->error, cfg->method->klass->image, "Method with open type while not compiling gshared");
+ method = NULL;
+ }
+
+ if (!method && !cfg)
+ mono_error_cleanup (&error); /* FIXME don't swallow the error */
return method;
}
@@ -8981,9 +8986,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
token = read32 (ip + 1);
/* FIXME: check the signature matches */
cmethod = mini_get_method (cfg, method, token, NULL, generic_context);
-
- if (!cmethod || mono_loader_get_last_error ())
- LOAD_ERROR;
+ CHECK_CFG_ERROR;
if (cfg->gshared && mono_method_check_context_used (cmethod))
GENERIC_SHARING_FAILURE (CEE_JMP);
@@ -9183,6 +9186,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
ins = NULL;
cmethod = mini_get_method (cfg, method, token, NULL, generic_context);
+ CHECK_CFG_ERROR;
+
cil_method = cmethod;
if (constrained_class) {
@@ -9228,7 +9233,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (!dont_verify && !cfg->skip_visibility) {
MonoMethod *target_method = cil_method;
if (method->is_inflated) {
- target_method = mini_get_method_allow_open (method, token, NULL, &(mono_method_get_generic_container (method_definition)->context));
+ target_method = mini_get_method_allow_open (method, token, NULL, &(mono_method_get_generic_container (method_definition)->context), &cfg->error);
+ CHECK_CFG_ERROR;
}
if (!mono_method_can_access_method (method_definition, target_method) &&
!mono_method_can_access_method (method, cil_method))
@@ -10782,8 +10788,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
CHECK_OPSIZE (5);
token = read32 (ip + 1);
cmethod = mini_get_method (cfg, method, token, NULL, generic_context);
- if (!cmethod || mono_loader_get_last_error ())
- LOAD_ERROR;
+ CHECK_CFG_ERROR;
+
fsig = mono_method_get_signature_checked (cmethod, image, token, generic_context, &cfg->error);
CHECK_CFG_ERROR;
@@ -13041,8 +13047,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
CHECK_OPSIZE (6);
n = read32 (ip + 2);
cmethod = mini_get_method (cfg, method, n, NULL, generic_context);
- if (!cmethod || mono_loader_get_last_error ())
- LOAD_ERROR;
+ CHECK_CFG_ERROR;
+
mono_class_init (cmethod->klass);
mono_save_token_info (cfg, image, n, cmethod);
@@ -13118,8 +13124,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
CHECK_OPSIZE (6);
n = read32 (ip + 2);
cmethod = mini_get_method (cfg, method, n, NULL, generic_context);
- if (!cmethod || mono_loader_get_last_error ())
- LOAD_ERROR;
+ CHECK_CFG_ERROR;
+
mono_class_init (cmethod->klass);
context_used = mini_method_check_context_used (cfg, cmethod);