Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 2371 [details]
Sample program that reproduces the bug
The attached program compiles fine with mcs, but does not handle the variable correctly; when run, it results in a NullReferenceException. Looking at the compiled code, the variable is defined as local to the MoveNext method, so assigned value does not persist to the next call to MoveNext. When compiled with gmcs, the program runs as expected.
Steps to reproduce:
1. Compile the attached program with mcs
2. Run the program
Is output to the console.
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at CompilerBug.CompilerBug+<Foo>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0
at CompilerBug.CompilerBug.Main (System.String arguments) [0x00000] in <filename unknown>:0
This appears to be a result of this commit: https://github.com/mono/mono/commit/394140f5a495ff5fc718249c1406735a001edf85.
Submitted pull request with fix, https://github.com/mono/mono/pull/445.
Fixed in master
The same change should also be made to the if statement for await that follows, as it suffers from the same issue.
Fixed in master too now.