[Mono-bugs] [Bug 81564][Blo] New - Mcs causes inifinite recursion

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue May 8 13:50:40 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by dm_mono_dev1 at yahoo.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81564

--- shadow/81564	2007-05-08 13:50:40.000000000 -0400
+++ shadow/81564.tmp.5306	2007-05-08 13:50:40.000000000 -0400
@@ -0,0 +1,127 @@
+Bug#: 81564
+Product: Mono: Compilers
+Version: 1.2
+OS: All
+OS Details: Win XP
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: dm_mono_dev1 at yahoo.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mcs causes inifinite recursion
+
+f I compile the OnUpdate method with mcs, I get an infinite recursion due
+to the compiler generating a callvirt instead of call.
+The Microsoft compiler doesn't have the same issue.
+Note that if I just have a virtual method Print1, both mcs and csc generate
+the same code (call       instance void Test1.TestItem1::Print()).
+
+Here's the ildasm output for the TestItem2::add_OnUpdate (mcs vs csc):
+
+mcs:
+.method public hidebysig specialname virtual
+        instance void  add_OnUpdate(class Test1.TestDelegate1 'value') cil
+managed
+{
+  // Code size       18 (0x12)
+  .maxstack  8
+  IL_0000:  ldstr      "OnUpdate add 2"
+  IL_0005:  call       void [mscorlib]System.Console::WriteLine(string)
+  IL_000a:  ldarg.0
+  IL_000b:  ldarg.1
+  IL_000c:  callvirt   instance void Test1.TestItem1::add_OnUpdate(class
+Test1.TestDelegate1)
+  IL_0011:  ret
+} // end of method TestItem2::add_OnUpdate
+
+csc:
+.method public hidebysig specialname virtual
+        instance void  add_OnUpdate(class Test1.TestDelegate1 'value') cil
+managed
+{
+  // Code size       18 (0x12)
+  .maxstack  2
+  IL_0000:  ldstr      "OnUpdate add 2"
+  IL_0005:  call       void [mscorlib]System.Console::WriteLine(string)
+  IL_000a:  ldarg.0
+  IL_000b:  ldarg.1
+  IL_000c:  call       instance void Test1.TestItem1::add_OnUpdate(class
+Test1.TestDelegate1)
+  IL_0011:  ret
+} // end of method TestItem2::add_OnUpdate
+
+and the test code:
+
+namespace Test1
+{    
+    public delegate void TestDelegate1(TestItem item);
+    
+    public interface TestItem
+    {        
+    event TestDelegate1 OnUpdate;       
+    }
+    
+    public class TestItem1 : TestItem
+    {   
+        private TestDelegate1 delegates1;
+        
+        public TestItem1()            
+        {
+        }
+        
+        public virtual void Print()
+        {
+            System.Console.WriteLine("Print 1");    
+        }
+
+        public virtual event TestDelegate1 OnUpdate
+        {
+            add
+            {
+                System.Console.WriteLine("OnUpdate add 1");
+                
+                delegates1 += value;
+            }
+            remove
+            {
+                System.Console.WriteLine("OnUpdate remove 2");
+                delegates1 -= value;
+            }
+        }
+        
+    }
+    
+    public class TestItem2 : TestItem1
+    {        
+        public TestItem2()
+            : base()
+        {
+        }
+        
+        public override void Print()
+    {
+        System.Console.WriteLine("Print 2");    
+        base.Print();    
+        }
+
+        public override event TestDelegate1 OnUpdate
+        {
+            add
+            {
+                System.Console.WriteLine("OnUpdate add 2");
+                base.OnUpdate += value;                
+            }
+            remove
+            {
+                System.Console.WriteLine("OnUpdate remove 2");
+                base.OnUpdate -= value;                
+            }
+        }
+    }
+}


More information about the mono-bugs mailing list