Bug 40536

Summary: Compiler crash when attaching an event of a templated delegate with wrong template type
Product: [Mono] Compilers Reporter: Odd Kristian Kvarmestøl <okknor>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.4.0 (C7)   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: test.cs

Description Odd Kristian Kvarmestøl 2016-04-19 22:27:08 UTC
Created attachment 15773 [details]
test.cs

Steps to reproduce:
1) Compile the attached code, test.cs, using
> mcs test.cs

Expected result:
A compilation error like
>test.cs(10,7): error CS0407: A method or delegate `int CompilerCrashTest.func()' return type does not match delegate `string Foo<string>.FooEvent()' return type
>test.cs(3,20): (Location of the symbol related to previous error)
>test.cs(13,13): (Location of the symbol related to previous error)

Actual result:
Compilator crash
>Unhandled Exception:
>Mono.CSharp.InternalErrorException: test.cs(7,14): CompilerCrashTest.Main() ---> System.NullReferenceException: Object reference not set to an instance of an object
>  at Mono.CSharp.TypeDefinition.Mono.CSharp.ITypeDefinition.get_TypeParameters () <0x7f35973fe950 + 0x0001e> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitReferenceConversion (Mono.CSharp.Expression source, Mono.CSharp.TypeSpec source_type, Mono.CSharp.TypeSpec target_type) <0x7f3597424160 + 0x00a42> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversionCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597424ee0 + 0x00350> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversion (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597425860 + 0x00033> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConvertedCore (Mono.CSharp.ResolveContext ec, Location loc, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b940 + 0x0016b> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConverted (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b8f0 + 0x0003d> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ImplicitConversionRequired (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression source, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597422a10 + 0x00051> in <filename unknown>:0 
>  at Mono.CSharp.CompoundAssign.DoResolve (Mono.CSharp.ResolveContext ec) <0x7f35973d08e0 + 0x00240> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) <0x7f359743c7a0 + 0x000c1> in <filename unknown>:0 
>  --- End of inner exception stack trace ---
>  at Mono.CSharp.Method.Emit () <0x7f35974c7de0 + 0x00303> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.Emit () <0x7f35974042d0 + 0x0048c> in <filename unknown>:0 
>  at Mono.CSharp.ClassOrStruct.Emit () <0x7f35974069c0 + 0x0007a> in <filename unknown>:0 
>  at Mono.CSharp.Class.Emit () <0x7f3597407550 + 0x0000f> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.EmitContainer () <0x7f35974049a0 + 0x00025> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.NamespaceContainer.EmitContainer () <0x7f35974d2ce0 + 0x0001c> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.ModuleContainer.EmitContainer () <0x7f35974f57d0 + 0x00178> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinition.Emit () <0x7f35973d34d0 + 0x0016d> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinitionStatic.Emit () <0x7f35974b1fa0 + 0x00336> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Compile () <0x7f3597435460 + 0x00669> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Main (System.String[] args) <0x7f3597434ec0 + 0x00163> in <filename unknown>:0 
>  
>Unhandled Exception:
>Mono.CSharp.InternalErrorException: test.cs(7,14): CompilerCrashTest.Main() ---> System.NullReferenceException: Object reference not set to an instance of an object
>  at Mono.CSharp.TypeDefinition.Mono.CSharp.ITypeDefinition.get_TypeParameters () <0x7f35973fe950 + 0x0001e> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitReferenceConversion (Mono.CSharp.Expression source, Mono.CSharp.TypeSpec source_type, Mono.CSharp.TypeSpec target_type) <0x7f3597424160 + 0x00a42> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversionCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597424ee0 + 0x00350> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversion (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597425860 + 0x00033> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConvertedCore (Mono.CSharp.ResolveContext ec, Location loc, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b940 + 0x0016b> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConverted (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b8f0 + 0x0003d> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ImplicitConversionRequired (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression source, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597422a10 + 0x00051> in <filename unknown>:0 
>  at Mono.CSharp.CompoundAssign.DoResolve (Mono.CSharp.ResolveContext ec) <0x7f35973d08e0 + 0x00240> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) <0x7f359743c7a0 + 0x000c1> in <filename unknown>:0 
>  --- End of inner exception stack trace ---
>  at Mono.CSharp.Method.Emit () <0x7f35974c7de0 + 0x00303> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.Emit () <0x7f35974042d0 + 0x0048c> in <filename unknown>:0 
>  at Mono.CSharp.ClassOrStruct.Emit () <0x7f35974069c0 + 0x0007a> in <filename unknown>:0 
>  at Mono.CSharp.Class.Emit () <0x7f3597407550 + 0x0000f> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.EmitContainer () <0x7f35974049a0 + 0x00025> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.NamespaceContainer.EmitContainer () <0x7f35974d2ce0 + 0x0001c> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.ModuleContainer.EmitContainer () <0x7f35974f57d0 + 0x00178> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinition.Emit () <0x7f35973d34d0 + 0x0016d> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinitionStatic.Emit () <0x7f35974b1fa0 + 0x00336> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Compile () <0x7f3597435460 + 0x00669> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Main (System.String[] args) <0x7f3597434ec0 + 0x00163> in <filename unknown>:0 
>[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: test.cs(7,14): CompilerCrashTest.Main() ---> System.NullReferenceException: Object reference not set to an instance of an object
>  at Mono.CSharp.TypeDefinition.Mono.CSharp.ITypeDefinition.get_TypeParameters () <0x7f35973fe950 + 0x0001e> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitReferenceConversion (Mono.CSharp.Expression source, Mono.CSharp.TypeSpec source_type, Mono.CSharp.TypeSpec target_type) <0x7f3597424160 + 0x00a42> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversionCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597424ee0 + 0x00350> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversion (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597425860 + 0x00033> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConvertedCore (Mono.CSharp.ResolveContext ec, Location loc, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b940 + 0x0016b> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConverted (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b8f0 + 0x0003d> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ImplicitConversionRequired (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression source, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597422a10 + 0x00051> in <filename unknown>:0 
>  at Mono.CSharp.CompoundAssign.DoResolve (Mono.CSharp.ResolveContext ec) <0x7f35973d08e0 + 0x00240> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) <0x7f359743c7a0 + 0x000c1> in <filename unknown>:0 
>  --- End of inner exception stack trace ---
>  at Mono.CSharp.Method.Emit () <0x7f35974c7de0 + 0x00303> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.Emit () <0x7f35974042d0 + 0x0048c> in <filename unknown>:0 
>  at Mono.CSharp.ClassOrStruct.Emit () <0x7f35974069c0 + 0x0007a> in <filename unknown>:0 
>  at Mono.CSharp.Class.Emit () <0x7f3597407550 + 0x0000f> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.EmitContainer () <0x7f35974049a0 + 0x00025> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.NamespaceContainer.EmitContainer () <0x7f35974d2ce0 + 0x0001c> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.ModuleContainer.EmitContainer () <0x7f35974f57d0 + 0x00178> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinition.Emit () <0x7f35973d34d0 + 0x0016d> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinitionStatic.Emit () <0x7f35974b1fa0 + 0x00336> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Compile () <0x7f3597435460 + 0x00669> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Main (System.String[] args) <0x7f3597434ec0 + 0x00163> in <filename unknown>:0 
>[ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: test.cs(7,14): CompilerCrashTest.Main() ---> System.NullReferenceException: Object reference not set to an instance of an object
>  at Mono.CSharp.TypeDefinition.Mono.CSharp.ITypeDefinition.get_TypeParameters () <0x7f35973fe950 + 0x0001e> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitReferenceConversion (Mono.CSharp.Expression source, Mono.CSharp.TypeSpec source_type, Mono.CSharp.TypeSpec target_type) <0x7f3597424160 + 0x00a42> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversionCore (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597424ee0 + 0x00350> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ExplicitConversion (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression expr, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597425860 + 0x00033> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConvertedCore (Mono.CSharp.ResolveContext ec, Location loc, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b940 + 0x0016b> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Error_ValueCannotBeConverted (Mono.CSharp.ResolveContext ec, Mono.CSharp.TypeSpec target, Boolean expl) <0x7f359743b8f0 + 0x0003d> in <filename unknown>:0 
>  at Mono.CSharp.Convert.ImplicitConversionRequired (Mono.CSharp.ResolveContext ec, Mono.CSharp.Expression source, Mono.CSharp.TypeSpec target_type, Location loc) <0x7f3597422a10 + 0x00051> in <filename unknown>:0 
>  at Mono.CSharp.CompoundAssign.DoResolve (Mono.CSharp.ResolveContext ec) <0x7f35973d08e0 + 0x00240> in <filename unknown>:0 
>  at Mono.CSharp.Expression.Resolve (Mono.CSharp.ResolveContext ec, ResolveFlags flags) <0x7f359743c7a0 + 0x000c1> in <filename unknown>:0 
>  --- End of inner exception stack trace ---
>  at Mono.CSharp.Method.Emit () <0x7f35974c7de0 + 0x00303> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.Emit () <0x7f35974042d0 + 0x0048c> in <filename unknown>:0 
>  at Mono.CSharp.ClassOrStruct.Emit () <0x7f35974069c0 + 0x0007a> in <filename unknown>:0 
>  at Mono.CSharp.Class.Emit () <0x7f3597407550 + 0x0000f> in <filename unknown>:0 
>  at Mono.CSharp.TypeDefinition.EmitContainer () <0x7f35974049a0 + 0x00025> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.NamespaceContainer.EmitContainer () <0x7f35974d2ce0 + 0x0001c> in <filename unknown>:0 
>  at Mono.CSharp.TypeContainer.EmitContainer () <0x7f35973fd170 + 0x00045> in <filename unknown>:0 
>  at Mono.CSharp.ModuleContainer.EmitContainer () <0x7f35974f57d0 + 0x00178> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinition.Emit () <0x7f35973d34d0 + 0x0016d> in <filename unknown>:0 
>  at Mono.CSharp.AssemblyDefinitionStatic.Emit () <0x7f35974b1fa0 + 0x00336> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Compile () <0x7f3597435460 + 0x00669> in <filename unknown>:0 
>  at Mono.CSharp.Driver.Main (System.String[] args) <0x7f3597434ec0 + 0x00163> in <filename unknown>:0
Comment 1 Marek Safar 2016-04-20 14:01:41 UTC
Fixed in master