Bug 56081 - Returning a valuetype from an async method with an awaited parameter yields a Mono.CSharp.InternalErrorException: Await yields with non-empty stack
Summary: Returning a valuetype from an async method with an awaited parameter yields a...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2017-05-07 09:30 UTC by tyler
Modified: 2017-05-26 16:31 UTC (History)
1 user (show)

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


Attachments
Sample solution attached detailing the compiler crash (3.35 KB, application/gzip)
2017-05-07 09:30 UTC, tyler
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 tyler 2017-05-07 09:30:24 UTC
Created attachment 21992 [details]
Sample solution attached detailing the compiler crash

Using Mono JIT compiler version 4.8.0 (Stable 4.8.0.495/e4a3cf3 Mon Feb 27 08:30:18 UTC 2017)

Sample project attached with a very isolated reproducible example.  Either build the solution using xbuild or use the provided commandline to compile it:

> mcs /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/CrashTest.dll A.cs B.cs Properties/AssemblyInfo.cs ValueType.cs obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs /target:library /define:"DEBUG;TRACE" /nostdlib /platform:AnyCPU /reference:/usr/lib/mono/4.5-api/System.dll /reference:/usr/lib/mono/4.5-api/System.Data.dll /reference:/usr/lib/mono/4.5-api/System.Xml.dll /reference:/usr/lib/mono/4.5-api/System.Core.dll /reference:/usr/lib/mono/4.5-api//mscorlib.dll /warn:4

The stacktrace is long and is ommitted in this report for brevity.  A full copy of the stderr of the compiler is contained in crash.log in the project tarball. Compiling an async method which returns a Task<struct> crashes the mono compiler when the results of an await is used as a parameter to the constructor of another value type inline without the use of a temporary local for storage.

The offending line is here in A.cs:18:

> return new ValueType(local1, await b.ProduceStructure(input1, input2));

b.ProduceStructure produces a Task<long>.  If I set the result of the awaited b.ProduceStructure is set to a local the compiler will emit successfully, so this is able to be fairly easily worked around, alas not a huge priority.

I feel that this is loosely related to #42224 - but was marked resolved in 4.6/stable and it is reproducible for me.

Thanks for your time in looking at this!
Comment 1 Marek Safar 2017-05-26 16:31:09 UTC
Fixed in master and 2017-04 branch