[Mono-bugs] [Bug 477447] New: Exception thrown while compiling code with nested anonymous delegates containing closures

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 18 16:52:20 EST 2009


https://bugzilla.novell.com/show_bug.cgi?id=477447


           Summary: Exception thrown while compiling code with nested
                    anonymous delegates containing closures
    Classification: Mono
           Product: Mono: Compilers
           Version: SVN
          Platform: Macintosh
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: dmitchell at logos.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-us)
AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1

Thus far, I have been unable to reproduce this code with a simple test case,
but I get this exception when compiling one of my projects:

Exception caught by the compiler while emitting:
   Block that caused the problem begin at:
/Users/dmitchell/Code/common/DigitalLibrary/src/Libronix.DataTypes/GrammarDriven
/GrammarDrivenDataTypeBase.cs(150,98):
System.Exception: Trying to emit a local from a different ILGenerator.
Internal compiler error at
/Users/dmitchell/Code/common/DigitalLibrary/src/Libronix.DataTypes/GrammarDriven
/GrammarDrivenDataTypeBase.cs(150,82):: exception caught while emitting
MethodBuilder [<ParseStandardReferencesCore>c__AnonStorey2F::<>m__A7]


Unhandled Exception: System.Exception: Trying to emit a local from a different
ILGenerator.
  at System.Reflection.Emit.ILGenerator.Emit (OpCode opcode,
System.Reflection.Emit.LocalBuilder local) [0x00000] 
  at Mono.CSharp.LocalTemporary.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.MemberExpr.EmitInstance (Mono.CSharp.EmitContext ec, Boolean
prepare_for_load) [0x00000] 
  at Mono.CSharp.FieldExpr.Emit (Mono.CSharp.EmitContext ec, Boolean
leave_copy) [0x00000] 
  at Mono.CSharp.HoistedVariable.Emit (Mono.CSharp.EmitContext ec, Boolean
leave_copy) [0x00000] 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec, Boolean
leave_copy) [0x00000] 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean
is_base, Mono.CSharp.Expression instance_expr, System.Reflection.MethodBase
method, System.Collections.ArrayList Arguments, Location loc, Boolean dup_args,
Boolean omit_args) [0x00000] 
  at Mono.CSharp.PropertyExpr.Emit (Mono.CSharp.EmitContext ec, Boolean
leave_copy) [0x00000] 
  at Mono.CSharp.PropertyExpr.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ArrayAccess.LoadArrayAndArguments (Mono.CSharp.EmitContext ec)
[0x00000] 
  at Mono.CSharp.ArrayAccess.Emit (Mono.CSharp.EmitContext ec, Boolean
leave_copy) [0x00000] 
  at Mono.CSharp.ArrayAccess.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Argument.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Invocation.EmitArguments (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList arguments, Boolean dup_args,
Mono.CSharp.LocalTemporary this_arg) [0x00000] 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean
is_base, Mono.CSharp.Expression instance_expr, System.Reflection.MethodBase
method, System.Collections.ArrayList Arguments, Location loc, Boolean dup_args,
Boolean omit_args) [0x00000] 
  at Mono.CSharp.Invocation.EmitCall (Mono.CSharp.EmitContext ec, Boolean
is_base, Mono.CSharp.Expression instance_expr, System.Reflection.MethodBase
method, System.Collections.ArrayList Arguments, Location loc) [0x00000] 
  at Mono.CSharp.MethodGroupExpr.EmitCall (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList arguments) [0x00000] 
  at Mono.CSharp.ExtensionMethodGroupExpr.EmitCall (Mono.CSharp.EmitContext ec,
System.Collections.ArrayList arguments) [0x00000] 
  at Mono.CSharp.Invocation.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Nullable.NullCoalescingOperator.Emit (Mono.CSharp.EmitContext
ec) [0x00000] 
  at Mono.CSharp.Return.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ContextualReturn.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.Block.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] 
  at Mono.CSharp.EmitContext.EmitResolvedTopBlock (Mono.CSharp.ToplevelBlock
block, Boolean unreachable) [0x00000] 
  at Mono.CSharp.EmitContext.EmitTopBlock (IMethodData md,
Mono.CSharp.ToplevelBlock block) [0x00000] 

The issue occurs in an anonymous delegate three layers deep (that is, an
anonymous delegate defined within the scope of an anonymous delegate which is
itself defined in the scope of a third anonymous delegate) that refers to a
variable defined in the outermost anonymous delegate.

Reproducible: Couldn't Reproduce

Steps to Reproduce:
1. Attempt to compile code affected by this bug.
2.
3.
Actual Results:  
gmcs crashes with the exception listed in the details

Expected Results:  
gmcs should compile the code.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list