[interp] throw overflow exception on (0/-1)
authorBernhard Urban <bernhard.urban@xamarin.com>
Tue, 7 Mar 2017 09:46:59 +0000 (10:46 +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

index 7a9f21385d143ac6c973bf2810a0946e8595960c..805253bf6e8c9ccd653cb1b3e9c4e55f773c7d50 100644 (file)
@@ -1462,7 +1462,6 @@ class Tests
                return 0;
        }
        
-       [Category ("!INTERPRETER")]
        [Category ("NaClDisable")]
        public static int test_0_div_zero () {
                int d = 1;
@@ -1634,7 +1633,6 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        [Category ("NaClDisable")]
        public static int test_0_long_div_zero () {
                long d = 1;
index 9d6dbf7f1abb935f26684532e392c14d50787c93..7c4761ad15a4d88673973840dd5f7fe3caf64523 100644 (file)
@@ -2559,11 +2559,15 @@ ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
                MINT_IN_CASE(MINT_REM_I4)
                        if (sp [-1].data.i == 0)
                                THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       if (sp [-1].data.i == (-1))
+                               THROW_EX (mono_get_exception_overflow (), ip);
                        BINOP(i, %);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_I8)
                        if (sp [-1].data.l == 0)
                                THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       if (sp [-1].data.l == (-1))
+                               THROW_EX (mono_get_exception_overflow (), ip);
                        BINOP(l, %);
                        MINT_IN_BREAK;
                MINT_IN_CASE(MINT_REM_R8)