Bug 42224

Summary: Compiler crashed with code: 1, "Await yields with non-empty stack" from AssertEmptyStack ()
Product: [Mono] Compilers Reporter: Ryan Niebur <ryan.niebur>
Component: C#Assignee: Marek Safar <masafa>
Severity: normal CC: mono-bugs+mono
Priority: ---    
Version: 4.4.0 (C7)   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: Example solution causing the crash, including the Build Output log

Description Ryan Niebur 2016-06-28 23:14:05 UTC
Created attachment 16513 [details]
Example solution causing the crash, including the Build Output log

Using Xamarin Studio 6.0.1 (build 9), up to date from the Stable channel, we were unable to build due to this error:
		/Library/Frameworks/Mono.framework/Versions/4.4.1/lib/mono/4.5/Microsoft.CSharp.targets: error : Compiler crashed with code: 1.

The problem turned out to be caused by this code pattern:
		Data += await GetHello () + "!\n" + 123.ToString () + "...";

For this to crash the compiler, Data must be a property, 123.ToString() cannot be a string literal, and both the string literals must be there in that pattern. Code following this pattern built fine in Visual Studio.

Here is the exception from the build output (where line 16 is the beginning of the function containing that code pattern):
		Unhandled Exception:
		Mono.CSharp.InternalErrorException: Program.cs(16,9): CompilerCrash.MainClass.<Demo>c__async0.MoveNext() ---> Mono.CSharp.InternalErrorException: (1,1): ---> Mono.CSharp.InternalErrorException: Await yields with non-empty stack in `CompilerCrash.MainClass.<Demo>c__async0.MoveNext()
		  at Mono.CSharp.EmitContext.AssertEmptyStack () <0x24e0350 + 0x000cc> in <filename unknown>:0 

Program.cs and BuiltOutput.log are attached, providing a full example.

I verified this happens in both Xamarin.iOS and Console projects.
Comment 1 Marek Safar 2016-07-28 12:42:02 UTC
Fixed in master and Mono 4.6