Bug 53166 - Application crashes when setting a get-only property in constructor
Summary: Application crashes when setting a get-only property in constructor
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2017-03-08 20:59 UTC by Ilya Trukhanov
Modified: 2017-03-09 14:14 UTC (History)
2 users (show)

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

A smallest possible test case for reproducing the bug. (348 bytes, text/x-csharp)
2017-03-08 20:59 UTC, Ilya Trukhanov
Another smallest possible test case reproducing the bug (397 bytes, text/x-csharp)
2017-03-08 21:03 UTC, Ilya Trukhanov

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 Ilya Trukhanov 2017-03-08 20:59:10 UTC
Created attachment 20219 [details]
A smallest possible test case for reproducing the bug.

Compiled application crashes during run-time if source code contains setting an overwritten get-only property in constructor while inside of curly brackets (please see the attachment).

Steps to reproduce: 
1. Compile the attached file (test.cs) with mcs, no arguments (mcs test.cs).
2. Run it with mono, no arguments (mono test.exe).

Actual results:
Application crashes with an unhandled exception:
[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in Test.Child:.ctor (): IL_0018: stfld     0x04000003

Expected results:
Application should not crash and should output "success" to the console.

Build Date & Hardware:
Build 2017-03-08 on Arch Linux with a patched Linux kernel (

Additional Builds and Platforms:
Does not occur on Build 2017-03-08 on Windows 10 when compiled using csc (Visual C# Compiler version

Additional Information: 
Crash occurs when both setting the property during array initialization (test.cs) and initializing a field during a new object initialization (see the next comment), hence "inside of curly brackets".
Comment 1 Ilya Trukhanov 2017-03-08 21:03:38 UTC
Created attachment 20220 [details]
Another smallest possible test case reproducing the bug

This test case produces the same output, but instead of setting a property while initializing an array it is set during field initialization of another class.
Comment 2 Ilya Trukhanov 2017-03-08 21:13:36 UTC
Also note: 
— applications do not crash if the "override" keyword is replaced with "new";
— setting the property outside of curly brackets and then passing it also does not result in a crash.
Comment 3 Marek Safar 2017-03-09 14:14:25 UTC
Fixed in master