Bug 37801

Summary: C# 6: Compiler crashed with code: 1 - FATAL UNHANDLED EXCEPTION
Product: [Mono] Compilers Reporter: Alexander Mezhov <as.mezhov>
Component: C#Assignee: Marek Safar <masafa>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://bugzilla.xamarin.com/show_bug.cgi?id=37824
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: xbuild output

Description Alexander Mezhov 2016-01-19 17:15:54 UTC
Created attachment 14630 [details]
xbuild output

Hello!

I have simple code wich does not compile. I think the main problem is operator "?.". I try to compile the next code block but get error: '/usr/lib/mono/4.5/Microsoft.CSharp.targets: Error: Compiler crashed with code: 1'. I attached the compile output to this issue.

CODE:

> using System;
> using System.Collections.Generic;
> using System.Linq;
> 
> namespace BadDynamic
> {
>     class MainClass
>     {
>         public static void Main(string[] args)
>         {
>             Console.WriteLine("Hello World!");
>         }
> 
>         public dynamic DoSomething(IEnumerable<dynamic> collection)
>         {
>             return collection?.FirstOrDefault().SomePropety;
>         }
>     }
> }

MONO:

> $ mono --version
> Mono JIT compiler version 4.2.1 (Stable 4.2.1.102/6dd2d0d Thu Nov 12 09:52:44 UTC 2015)
> Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
> 	TLS:           __thread
> 	SIGSEGV:       altstack
> 	Notifications: epoll
> 	Architecture:  amd64
> 	Disabled:      none
> 	Misc:          softdebug 
> 	LLVM:          supported, not enabled.
> 	GC:            sgen

XBUILD:

> $ xbuild /version
> XBuild Engine Version 12.0
> Mono, Version 4.2.1.0
> Copyright (C) 2005-2013 Various Mono authors

OUTPUT:

> ...
> [ERROR] FATAL UNHANDLED EXCEPTION: Mono.CSharp.InternalErrorException: Program.cs(14,24):
> BadDynamic.MainClass.DoSomething(System.Collections.Generic.IEnumerable<dynamic>) ---> 
> Mono.CSharp.InternalErrorException: Program.cs(15,9): ---> 
> System.NullReferenceException: Object reference not set to an instance of an object
> at Mono.CSharp.InstanceEmitter.Emit (Mono.CSharp.EmitContext ec, Boolean conditionalAccess) <0x7fe5dee33ff0 + 0x003bf> in <filename unknown>:0
Comment 1 Marek Safar 2016-01-28 12:13:15 UTC
Fixed in master and Mono 4.3.2