Bug 3087 - Optimization "precomp" breaks with EMA-335
Summary: Optimization "precomp" breaks with EMA-335
Status: RESOLVED INVALID
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-01-26 06:20 UTC by Martin Daeumler
Modified: 2012-09-02 13:37 UTC (History)
4 users (show)

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


Attachments
Test case with a class constructor which is executed too early while pre-compiling (733 bytes, application/octet-stream)
2012-01-26 06:20 UTC, Martin Daeumler
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 INVALID

Description Martin Daeumler 2012-01-26 06:20:32 UTC
Created attachment 1273 [details]
Test case with a class constructor which is executed too early while pre-compiling

The class 'Test' of the appended test case (test.cs) has an (explicit)
class constructor. That is, in class Test's IL-code, the flag
"beforefieldinit" is not set. ECMA-335 §8.9.5 states that the class
constructor is executed at first access to any static member of that
class or at first creation of one instance of that class. The test
case is compiled by "mcs test.cs" and executed by "mono test.exe". 
The expected (and correct) output is:

Starting Main
In type initializer
Echo!
After echo
After field access


When executing the programm with "mono -O=precomp test.exe" by Mono-2.6.1,
the incorrect output is:

In type initializer
Starting Main
Echo!
After echo
After field access


That is, the class constructor is called while pre-compiling. Even worse,
Mono 2.10.8.1 crashes while pre-compiling (tested on Linux and Mac OS X) with
an assertion failure in method-to-ir.c:684.
Comment 1 Zoltan Varga 2012-01-26 14:07:30 UTC
-O=precomp is not really supported, I don't even remember why we added it.
Comment 2 Zoltan Varga 2012-01-26 14:08:02 UTC
If you want to precompile code, use AOT.