[interp] throw overflow exception on ulong to long cast where ulong is too large...
authorBernhard Urban <bernhard.urban@xamarin.com>
Tue, 7 Mar 2017 09:47:00 +0000 (10:47 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Wed, 8 Mar 2017 22:02:51 +0000 (23:02 +0100)
mono/mini/exceptions.cs
mono/mini/interp/interp.c
mono/mini/interp/mintops.def
mono/mini/interp/transform.c

index 805253bf6e8c9ccd653cb1b3e9c4e55f773c7d50..86cec08c3eb3a69530b21943a295c7b8d9aef961 100644 (file)
@@ -1800,7 +1800,6 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_3_checked_cast_un () {
                 ulong i = 0x8000000034000000;
                 long j;
index 7c4761ad15a4d88673973840dd5f7fe3caf64523..3b5307f13e418bb8d1dca785a9f1eb30466eafa5 100644 (file)
@@ -3168,9 +3168,14 @@ array_constructed:
                        sp [-1].data.l = sp [-1].data.i;
                        ++ip;
                        MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I8_U8)
+                       if ((guint64) sp [-1].data.l > MYGINT64_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
                MINT_IN_CASE(MINT_CONV_OVF_U8_R8)
                MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R8)
-                       if (sp [-1].data.f < 0 || sp [-1].data.f > 9223372036854775807LL)
+                       if (sp [-1].data.f < 0 || sp [-1].data.f > MYGINT64_MAX)
                                THROW_EX (mono_get_exception_overflow (), ip);
                        sp [-1].data.l = (guint64)sp [-1].data.f;
                        ++ip;
index d876f07056ee1dc89d82f6c5432c8c4252b24fce..21ad893d07fda7abcddf4625ff5a0b4f61c05936 100644 (file)
@@ -455,6 +455,7 @@ OPDEF(MINT_CONV_OVF_U4_I4, "conv.ovf.u4.i4", 1, MintOpNoArgs)
 OPDEF(MINT_CONV_OVF_U4_I8, "conv.ovf.u4.i8", 1, MintOpNoArgs)
 OPDEF(MINT_CONV_OVF_U4_R8, "conv.ovf.u4.r8", 1, MintOpNoArgs)
 
+OPDEF(MINT_CONV_OVF_I8_U8, "conv.ovf.i8.u8", 1, MintOpNoArgs)
 OPDEF(MINT_CONV_OVF_I8_R8, "conv.ovf.i8.r8", 1, MintOpNoArgs)
 
 OPDEF(MINT_CONV_OVF_I8_UN_R8, "conv.ovf.i8.un.r8", 1, MintOpNoArgs)
index 2e5b3df73760e6ccd11a4513c509fb53e2d9a002..434e2cdb0c4d4c2bddadb180fe4dc579a0efdd5b 100644 (file)
@@ -2175,6 +2175,8 @@ generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, Mo
                                ADD_CODE(&td, MINT_CONV_OVF_I8_UN_R8);
                                break;
                        case STACK_TYPE_I8:
+                               if (*td.ip == CEE_CONV_OVF_I8_UN)
+                                       ADD_CODE (&td, MINT_CONV_OVF_I8_U8);
                                break;
                        case STACK_TYPE_I4:
                                ADD_CODE(&td, MINT_CONV_I8_U4);