Bug 42224 - Compiler crashed with code: 1, "Await yields with non-empty stack" from AssertEmptyStack ()
Summary: Compiler crashed with code: 1, "Await yields with non-empty stack" from Asser...
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.4.0 (C7)
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2016-06-28 23:14 UTC by Ryan Niebur
Modified: 2016-07-28 12:42 UTC (History)
1 user (show)

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

Example solution causing the crash, including the Build Output log (19.77 KB, application/zip)
2016-06-28 23:14 UTC, Ryan Niebur

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:

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