Bug 18282

Summary: Compiler crashes with a very specific generics case.
Product: [Mono] Compilers Reporter: Rasiel Rodriguez <rrodriguez>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 3.2.x   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Repro project.

Description Rasiel Rodriguez 2014-03-10 10:45:25 UTC
Created attachment 6271 [details]
Repro project.

Accidentally ran into a case where the compiler is just crashing with the message included in [1] Build Output.
Attached is a repro project. 
The workaround is to uncomment line #6 in the Dbs.cs class.
When changing ThreadLocal for a ThreadStatic approach, the compiler gives you the right message about the Timer namespace ambiguousness.

Thanks,
R.


[1] Build output:

Building Solution: iOs-MonoCrashRepro (Debug|iPhoneSimulator)

Building: iOs-MonoCrashRepro (Debug|iPhoneSimulator)
Performing main compilation...
/Library/Frameworks/Mono.framework/Versions/3.2.7/bin/mcs /noconfig "/r:/Developer/MonoTouch/usr/lib/mono/2.1/mscorlib.dll" -nostdlib "/out:/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/bin/iPhoneSimulator/Debug/iOsMonoCrashRepro.exe" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" "/r:/Users/racielrod/Projects/iOs-MonoCrashRepro/Components/sqlite-net-1.0.1/lib/ios/SQLite.dll" "/r:/Users/racielrod/Projects/iOs-MonoCrashRepro/Components/json.net-4.5.11/lib/ios/Newtonsoft.Json.dll" "/r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" /nologo /warn:4 /debug:full /optimize- /codepage:utf8 "/define:DEBUG;__MOBILE__;__IOS__"  /t:exe "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Main.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/AppDelegate.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/iOs-MonoCrashReproViewController.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/iOs-MonoCrashReproViewController.designer.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Queueable.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/IQueueable.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/IIdable.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/IStampable.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/eHttpVerb.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Dbs.cs" "/Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Timer.cs" 


Unhandled Exception:
Mono.CSharp.InternalErrorException: /Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Dbs.cs(10,22): ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec, IMemoryLocation target) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr.EmitAssign (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression source, Boolean leave_copy, Boolean isCompound) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.Emit (Mono.CSharp.EmitContext ec, Boolean is_statement) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldInitializer.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.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.EmitScopeInitializers (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 
  --- End of inner exception stack trace ---
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Constructor.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ClassOrStruct.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Class.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: /Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Dbs.cs(10,22): ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec, IMemoryLocation target) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr.EmitAssign (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression source, Boolean leave_copy, Boolean isCompound) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.Emit (Mono.CSharp.EmitContext ec, Boolean is_statement) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldInitializer.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.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.EmitScopeInitializers (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 
  --- End of inner exception stack trace ---
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Constructor.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ClassOrStruct.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Class.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 



Unhandled Exception:
Mono.CSharp.InternalErrorException: /Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Dbs.cs(10,22): ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec, IMemoryLocation target) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr.EmitAssign (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression source, Boolean leave_copy, Boolean isCompound) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.Emit (Mono.CSharp.EmitContext ec, Boolean is_statement) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldInitializer.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.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.EmitScopeInitializers (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 
  --- End of inner exception stack trace ---
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Constructor.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ClassOrStruct.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Class.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: /Users/racielrod/Projects/iOs-MonoCrashRepro/iOs-MonoCrashRepro/Dbs.cs(10,22): ---> System.NullReferenceException: Object reference not set to an instance of an object
  at Mono.CSharp.EmitContext.Emit (OpCode opcode, Mono.CSharp.MethodSpec method) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec, IMemoryLocation target) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.New.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldExpr.EmitAssign (Mono.CSharp.EmitContext ec, Mono.CSharp.Expression source, Boolean leave_copy, Boolean isCompound) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.Emit (Mono.CSharp.EmitContext ec, Boolean is_statement) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Assign.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.FieldInitializer.EmitStatement (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.StatementExpression.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.EmitScopeInitializers (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 
  --- End of inner exception stack trace ---
  at Mono.CSharp.ToplevelBlock.Emit (Mono.CSharp.EmitContext ec) [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Constructor.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ClassOrStruct.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Class.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeDefinition.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.NamespaceContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.TypeContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.ModuleContainer.EmitContainer () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinition.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.AssemblyDefinitionStatic.Emit () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0 
  at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0 
Build complete -- 1 error, 0 warnings

---------------------- Done ----------------------

Build: 1 error, 0 warnings
Comment 1 Marek Safar 2014-04-30 09:34:53 UTC
Fixed in master