Bug 40536 - Compiler crash when attaching an event of a templated delegate with wrong template type
Summary: Compiler crash when attaching an event of a templated delegate with wrong tem...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.4.0 (C7)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-04-19 22:27 UTC by Odd Kristian Kvarmestøl
Modified: 2016-04-20 14:01 UTC (History)
1 user (show)

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


Attachments
test.cs (275 bytes, text/x-csharp)
2016-04-19 22:27 UTC, Odd Kristian Kvarmestøl
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 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