[interp] fix localloc instruction, storage must be cleared
authorBernhard Urban <bernhard.urban@xamarin.com>
Tue, 7 Mar 2017 09:46:58 +0000 (10:46 +0100)
committerBernhard Urban <bernhard.urban@xamarin.com>
Wed, 8 Mar 2017 22:02:51 +0000 (23:02 +0100)
mono/mini/iltests.il
mono/mini/interp/interp.c

index ddd09350921a0b1b0f6e093e58c27d16492b3b10..eed995c8a248b85d85efc4a56e6c19d9f13c346d 100644 (file)
        
        // this only happens with the managed pointer, not an unmanaged one.
        .method static public int32 test_0_foo () il managed {
-               .custom instance void [TestDriver]CategoryAttribute::.ctor(string) = ( 01 00 0C 21 49 4E 54 45 52 50 52 45 54 45 52 00 00 )   // ...!INTERPRETER.
        
                .locals init (
                        int32&  buf
        }
 
        .method static public int32 test_0_localloc () cil managed {
-               .custom instance void [TestDriver]CategoryAttribute::.ctor(string) = ( 01 00 0C 21 49 4E 54 45 52 50 52 45 54 45 52 00 00 )   // ...!INTERPRETER.
                .locals init (native int, native int, native int, native int, int32)
 
                ldc.i4 6
index 8b7776b31f97fd18e2b07ce5d6827e2b022e8fa1..1783854f7fc45235dc075cca3f4bb11453d7a202 100644 (file)
@@ -3931,12 +3931,19 @@ array_constructed:
                        ip += 4;
                        MINT_IN_BREAK;
 
-               MINT_IN_CASE(MINT_LOCALLOC)
+               MINT_IN_CASE(MINT_LOCALLOC) {
                        if (sp != frame->stack + 1) /*FIX?*/
                                THROW_EX (mono_get_exception_execution_engine (NULL), ip);
-                       sp [-1].data.p = alloca (sp [-1].data.i);
+
+                       int len = sp [-1].data.i;
+                       sp [-1].data.p = alloca (len);
+                       MonoMethodHeader *header = mono_method_get_header_checked (frame->runtime_method->method, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       if (header->init_locals)
+                               memset (sp [-1].data.p, 0, len);
                        ++ip;
                        MINT_IN_BREAK;
+               }
 #if 0
                MINT_IN_CASE(MINT_ENDFILTER) ves_abort(); MINT_IN_BREAK;
 #endif