[jit] Fix MethodAccessExceptions, the caller and callee were switched. (#4465)
authorZoltan Varga <vargaz@gmail.com>
Fri, 3 Mar 2017 00:21:08 +0000 (19:21 -0500)
committerGitHub <noreply@github.com>
Fri, 3 Mar 2017 00:21:08 +0000 (19:21 -0500)
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/method-to-ir.c
mono/tests/method-access.il

index 765d3096a1cd2707f02b2d45e89bb1b2a75f8943..ab4ab1295f8f3f6fb8d73bcca4ba8e7b9d320f16 100644 (file)
@@ -1909,14 +1909,14 @@ mono_interruption_checkpoint_from_trampoline (void)
 }
 
 void
-mono_throw_method_access (MonoMethod *callee, MonoMethod *caller)
+mono_throw_method_access (MonoMethod *caller, MonoMethod *callee)
 {
-       char *callee_name = mono_method_full_name (callee, 1);
        char *caller_name = mono_method_full_name (caller, 1);
+       char *callee_name = mono_method_full_name (callee, 1);
        MonoError error;
 
        error_init (&error);
-       mono_error_set_generic_error (&error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'\n", callee_name, caller_name);
+       mono_error_set_generic_error (&error, "System", "MethodAccessException", "Method `%s' is inaccessible from method `%s'", callee_name, caller_name);
        mono_error_set_pending_exception (&error);
        g_free (callee_name);
        g_free (caller_name);
index 9d8deb26198c77832464ab704408e37ec51115cf..a83b337baaafb9d7fa97c1dc66313aca59c983b7 100644 (file)
@@ -224,7 +224,7 @@ MonoObject* mono_get_method_object (MonoMethod *method);
 
 double mono_ckfinite (double d);
 
-void mono_throw_method_access (MonoMethod *callee, MonoMethod *caller);
+void mono_throw_method_access (MonoMethod *caller, MonoMethod *callee);
 
 void mono_dummy_jit_icall (void);
 
index 2246578a7162b378d813599a0570ca546f6b2be6..78d0c219216cd033ca369312d2963955f063beb1 100644 (file)
@@ -2949,12 +2949,12 @@ mono_emit_widen_call_res (MonoCompile *cfg, MonoInst *ins, MonoMethodSignature *
 
 
 static void
-emit_method_access_failure (MonoCompile *cfg, MonoMethod *method, MonoMethod *cil_method)
+emit_method_access_failure (MonoCompile *cfg, MonoMethod *caller, MonoMethod *callee)
 {
        MonoInst *args [16];
 
-       args [0] = emit_get_rgctx_method (cfg, mono_method_check_context_used (method), method, MONO_RGCTX_INFO_METHOD);
-       args [1] = emit_get_rgctx_method (cfg, mono_method_check_context_used (cil_method), cil_method, MONO_RGCTX_INFO_METHOD);
+       args [0] = emit_get_rgctx_method (cfg, mono_method_check_context_used (caller), caller, MONO_RGCTX_INFO_METHOD);
+       args [1] = emit_get_rgctx_method (cfg, mono_method_check_context_used (callee), callee, MONO_RGCTX_INFO_METHOD);
 
        mono_emit_jit_icall (cfg, mono_throw_method_access, args);
 }
index 98e9f7fa7ff6b0696a2724929e437928438b31ac..558fb5931e4b8fa25ceaa486bcb8da40c6ab66e6 100644 (file)
                        call void Test::call_sfoo ()
                        br fail
                } catch [mscorlib]System.MethodAccessException {
-                       pop
+                       call instance string [mscorlib]System.MethodAccessException::get_Message ()
+                       ldstr "Method `MethFail:sfoo ()' is inaccessible from method `Test:call_sfoo ()'"
+                       call instance bool [mscorlib]System.String::Equals (string)
+                       brfalse fail
                        br continue
                } catch [mscorlib]System.Exception {
                        pop