[verifier] Fix the verifiers to handle Roslyn style fixed blocks.
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 12 Oct 2015 20:39:39 +0000 (16:39 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 12 Oct 2015 20:39:39 +0000 (16:39 -0400)
Roslyn used byref vars whenever possible to store fixed statements. This leads to confusion in
both the full verifier and the JIT built-in one.

Now we skip it in the JIT one and allow it when not in strict mode for the full verifier.

mono/metadata/verify.c
mono/mini/method-to-ir.c

index 68fe0688774e03bdf70e4f80f566f1e98cc3abf8..43a938d0fc4a0e09757c04938cbbb2ba5b269639 100644 (file)
@@ -2515,6 +2515,12 @@ verify_stack_type_compatibility_full (VerifyContext *ctx, MonoType *type, ILStac
        if (drop_byref)
                return verify_type_compatibility_full (ctx, type, mono_type_get_type_byval (candidate), FALSE);
 
+       /* Handle how Roslyn emit fixed statements by encoding it as byref */
+       if (type->byref && candidate->byref && (type->type == MONO_TYPE_I) && !mono_type_is_reference (candidate)) {
+               if (!IS_STRICT_MODE (ctx))
+                       return TRUE;
+       }
+
        return verify_type_compatibility_full (ctx, type, candidate, FALSE);
 }
 
index 0c1ad62bac972539e57f29175a3ef2c3d62328e6..1c8d35704461aaedd5d68044bbc335ed6a9009a0 100644 (file)
@@ -2184,7 +2184,7 @@ target_type_is_incompatible (MonoCompile *cfg, MonoType *target, MonoInst *arg)
        if (target->byref) {
                /* FIXME: check that the pointed to types match */
                if (arg->type == STACK_MP)
-                       return arg->klass != mono_class_from_mono_type (target);
+                       return target->type != MONO_TYPE_I && arg->klass != mono_class_from_mono_type (target);
                if (arg->type == STACK_PTR)
                        return 0;
                return 1;