[Mono-bugs] [Bug 76100][Wis] New - mcs: yield in a lock block generates exception

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Sep 14 06:34:01 EDT 2005


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 schwimmlehrer at hotmail.com.

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

--- shadow/76100	2005-09-14 06:34:01.000000000 -0400
+++ shadow/76100.tmp.25324	2005-09-14 06:34:01.000000000 -0400
@@ -0,0 +1,67 @@
+Bug#: 76100
+Product: Mono: Compilers
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: C#
+AssignedTo: rharinath at novell.com                            
+ReportedBy: schwimmlehrer at hotmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: mcs: yield in a lock block generates exception
+
+Description of Problem:
+I have a "yield return" statement in a lock block. This compiles and runs
+on Ms.Net but on Mono it generates an unhandled exception on compilation.
+
+Steps to reproduce the problem:
+1. Compile a C# file containing code similar to this:
+
+static object lockit = new Object();
+public static IEnumerable GetData()
+{
+  lock (lockit)
+  {
+   for (int i = 0; i < 10; i++)
+    yield return true;
+  }
+}
+
+Actual Results:
+Unhandled Exception: System.Exception: Trying to emit a local from a 
+different ILGenerator.
+in <0x005e7> System.Reflection.Emit.ILGenerator:Emit (OpCode opcode, 
+System.Reflection.Emit.LocalBuilder lbuilder)
+in <0x0002e> Mono.CSharp.Lock:EmitFinally (Mono.CSharp.EmitContext ec)
+in <0x001bd> Mono.CSharp.Iterator:EmitDispose (Mono.CSharp.EmitContext ec)
+in <0x00013> Mono.CSharp.Iterator+DisposeMethod:DoEmit 
+(Mono.CSharp.EmitContext ec)
+in <0x00024> Mono.CSharp.Statement:Emit (Mono.CSharp.EmitContext ec)
+in <0x000a8> Mono.CSharp.Block:DoEmit (Mono.CSharp.EmitContext ec)
+in <0x00254> Mono.CSharp.Block:Emit (Mono.CSharp.EmitContext ec)
+in <0x0001b> Mono.CSharp.EmitContext:EmitResolvedTopBlock 
+(Mono.CSharp.ToplevelBlock block, Boolean unreachable)
+in <0x00068> Mono.CSharp.EmitContext:EmitTopBlock (IMethodData md, 
+Mono.CSharp.ToplevelBlock block, Mono.CSharp.InternalParameters ip)
+in <0x001f2> Mono.CSharp.MethodData:Emit (Mono.CSharp.TypeContainer 
+container, Mono.CSharp.Attributable kind)
+in <0x00029> Mono.CSharp.Method:Emit ()
+in <0x0064d> Mono.CSharp.TypeContainer:EmitType ()
+in <0x012a4> Mono.CSharp.TypeContainer:EmitType ()
+in <0x00225> Mono.CSharp.RootContext:EmitCode ()
+in <0x00c63> Mono.CSharp.Driver:MainDriver (System.String[] args)
+in <0x0000f> Mono.CSharp.Driver:Main (System.String[] args)
+
+Expected Results:
+Should compile and run (lock the object as long as the loop is executed).
+MCS should not expose its stack trace especially on code that seems to be
+valid (at least to me and to Microsoft csc).
+
+How often does this happen? 
+Always


More information about the mono-bugs mailing list