Clear the 'need_rgctx_tramp' flag when creating a synchronized wrapper. Fixes
authorZoltan Varga <vargaz@gmail.com>
Sat, 29 Jan 2011 19:51:23 +0000 (20:51 +0100)
committerZoltan Varga <vargaz@gmail.com>
Sat, 29 Jan 2011 19:52:08 +0000 (20:52 +0100)
mono/mini/generics.cs
mono/mini/mini-trampolines.c

index 85216778ab74811dcaf0ef029c7c3e2d2903eca0..0ec9a0ed98d615efb50fe9886a16fbf0187afba0 100644 (file)
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.CompilerServices;
 
 class Tests {
 
@@ -824,4 +825,27 @@ class Tests {
        static T Unbox <T> (object o) {
                return (T) o;
        }
+
+       interface IDefaultRetriever
+       {
+               T GetDefault<T>();
+       }
+
+       class DefaultRetriever : IDefaultRetriever
+       {
+               [MethodImpl(MethodImplOptions.Synchronized)]
+               public T GetDefault<T>()
+               {
+                       return default(T);
+               }
+       }
+
+       public static int test_0_regress_668095_synchronized_gshared () {
+               return DoSomething (new DefaultRetriever ());
+       }
+
+    static int DoSomething(IDefaultRetriever foo) {
+               int result = foo.GetDefault<int>();
+               return result;
+       }
 }
index 147073ba800a1409cb928588a0b7708dbc83bbfd..ec7edef29562e1bd8e1896d36f38678af2a494e1 100644 (file)
@@ -466,8 +466,10 @@ common_call_trampoline (mgreg_t *regs, guint8 *code, MonoMethod *m, guint8* tram
                        ji = NULL;
 
                /* Avoid recursion */
-               if (!(ji && ji->method->wrapper_type == MONO_WRAPPER_SYNCHRONIZED))
+               if (!(ji && ji->method->wrapper_type == MONO_WRAPPER_SYNCHRONIZED)) {
                        m = mono_marshal_get_synchronized_wrapper (m);
+                       need_rgctx_tramp = FALSE;
+               }
        }
 
        /* Calls made through delegates on platforms without delegate trampolines */