Bug 4799 - Crash in dmcs when compiling an IEnumerable<TOutput> return with a yield and an anonymous method with a try finally within a using block
Summary: Crash in dmcs when compiling an IEnumerable<TOutput> return with a yield and ...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2012-05-01 10:49 UTC by David Ferguson
Modified: 2012-05-01 12:11 UTC (History)
1 user (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Class that replicates the compiler crash (607 bytes, text/x-csharp)
2012-05-01 10:49 UTC, David Ferguson
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description David Ferguson 2012-05-01 10:49:53 UTC
Created attachment 1786 [details]
Class that replicates the compiler crash

The compiler crashes when compiling the attached class with the following error message and stack trace.  It looks to be the yield statement in conjunction with the anonymous method for the thread start and the finally block.  If you remove the code in the finally block or change the yield statement to a different return (not an IEnumerable return).  The using block is also necessary.  If you remove the using block, the code will compile.

Building: UnitTests (Debug)
Performing main compilation...
/home/dferguson/.local/bin/dmcs /noconfig "/out:/home/dferguson/Development/mono/TestProject/UnitTests/bin/Debug/UnitTests.dll" "/r:/home/dferguson/.local/lib/mono/4.0/System.dll" "/r:/home/dferguson/.local/lib/mono/4.0/System.ServiceModel.Web.dll" "/r:/home/dferguson/.local/lib/monodevelop/AddIns/NUnit/MonoDevelop.NUnit.dll" "/r:/home/dferguson/Development/replay5-mono/common/sdks/nunit/bin/net-2.0/framework/nunit.framework.dll" "/r:/home/dferguson/.local/lib/mono/4.0/System.ServiceModel.dll" "/r:/home/dferguson/.local/lib/mono/4.0/System.Core.dll" "/r:/home/dferguson/.local/lib/mono/4.0/System.Runtime.Serialization.dll" /nologo /warn:4 /debug:full /optimize- /codepage:utf8 "/define:DEBUG"  /t:library "/home/dferguson/Development/mono/TestProject/UnitTests/MyClass.cs" "/home/dferguson/Development/mono/TestProject/UnitTests/AssemblyInfo.cs" "/home/dferguson/Development/mono/TestProject/UnitTests/UriTemplateTests.cs" "/home/dferguson/Development/mono/TestProject/UnitTests/DataContractSerializerTests.cs" 
Internal compiler error at /home/dferguson/Development/mono/TestProject/UnitTests/MyClass.cs(29,17):: exception caught while emitting Void <>__Finally0()


Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldSpec spec, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldBase fi, Location l) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.GetFieldExpression (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Expression.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Binary.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.If.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using+VariableDeclaration.EmitDispose (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using.EmitFinallyBody (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Iterator+TryFinallyBlockProxyStatement.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ParametersBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldSpec spec, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldBase fi, Location l) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.GetFieldExpression (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Expression.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Binary.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.If.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using+VariableDeclaration.EmitDispose (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using.EmitFinallyBody (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Iterator+TryFinallyBlockProxyStatement.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ParametersBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 



Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldSpec spec, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldBase fi, Location l) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.GetFieldExpression (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Expression.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Binary.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.If.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using+VariableDeclaration.EmitDispose (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using.EmitFinallyBody (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Iterator+TryFinallyBlockProxyStatement.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ParametersBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldSpec spec, Location loc) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr..ctor (Mono.CSharp.FieldBase fi, Location l) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.GetFieldExpression (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.HoistedVariable.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec, Boolean leave_copy) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.VariableReference.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Expression.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Binary.EmitBranchable (Mono.CSharp.EmitContext ec, Label target, Boolean on_true) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.If.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using+VariableDeclaration.EmitDispose (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Using.EmitFinallyBody (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Iterator+TryFinallyBlockProxyStatement.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Statement.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Block.DoEmit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ExplicitBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ParametersBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodData.Emit (Mono.CSharp.TypeDefinition parent) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.MethodOrOperator.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Method.Emit () [0x00000] in <filename unknown>:0 
Build complete -- 1 error, 0 warnings


This is on Ubuntu 12.04 running a forked branch of master (commit ec7ed0e5548335897c51cbd742571dbcbe925c10).
Comment 1 Marek Safar 2012-05-01 12:11:38 UTC
Fixed in master