Bug 53166

Summary: Application crashes when setting a get-only property in constructor
Product: [Mono] Compilers Reporter: Ilya Trukhanov <lahvuun>
Component: C#Assignee: Marek Safar <masafa>
Severity: normal CC: lahvuun, mono-bugs+mono
Priority: ---    
Version: 4.8.0 (C9)   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: A smallest possible test case for reproducing the bug.
Another smallest possible test case reproducing the bug

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