Bug 17572 - Unfounded 'ExecutionEngineException: Attempting to JIT compile method while running with --aot-only"
Summary: Unfounded 'ExecutionEngineException: Attempting to JIT compile method while r...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-02-03 12:09 UTC by Andres G. Aragoneses
Modified: 2018-01-24 18:07 UTC (History)
4 users (show)

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

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 Andres G. Aragoneses 2014-02-03 12:09:32 UTC
The following code, when compiled with --aot=full and run with --full-aot, works perfectly:

using System;
using System.Collections.Generic;

namespace TestAot
{
	public class GridCellValue<TRow, TProperty>
	{
		private readonly TRow mRow;
		public TProperty Value { get; private set; }
	}
	public abstract class GridCellBase<TRow, TProperty>
	{
		public GridCellValue<TRow, TProperty> CellValue { get; set; }
		protected GridCellBase()
		{
			Size = new KeyValuePair<int,int>(0,0);
		}
		public KeyValuePair<int,int> Size { get; protected set; }
	}
	class GridBindingDemoViewModelRow
	{
	}
	public class GridCheckBoxCell<TRow> : GridCellBase<TRow, bool> {
	}
	public class GridDrawingHelper<TRow>
	{
		public GridDrawingHelper() {
			var c = new GridCheckBoxCell<TRow>();
		}
	}
	class MainClass
	{
		public static void Main (string[] args)
		{
			var h = new GridDrawingHelper<GridBindingDemoViewModelRow>();
			var c = new GridCheckBoxCell<GridBindingDemoViewModelRow>();
		}
	}
}


However, if the second line of the Main method above is commented out, you get an error.

Given that the main sample works, I believe I'm not hitting a current FullAOT limitation.

The error is:

System.ExecutionEngineException: Attempting to JIT compile method 'TestAot.GridCellBase`2<TestAot.GridBindingDemoViewModelRow, bool>:.ctor ()' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

  at TestAot.GridCheckBoxCell`1[TestAot.GridBindingDemoViewModelRow]..ctor () [0x00000] in <filename unknown>:0 
  at TestAot.GridDrawingHelper`1[TestAot.GridBindingDemoViewModelRow]..ctor () [0x00000] in <filename unknown>:0 
  at TestAot.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
Comment 1 Andres G. Aragoneses 2014-02-04 05:32:10 UTC
Even more reduced testcase:

	public class Foo<T1> //: Bar<T1, bool>
	{
		public Foo() : base () {
			Console.WriteLine ("GridCheckBoxCell<{0}> ctor", new Bar<T1, bool>().ToString ());
		}
	}
	public class Bar<T1, T2>
	{
		public Bar()
		{
			Console.WriteLine ("T1:{0},T2:{1}", typeof(T1).FullName, typeof(T2).FullName);
		}
	}
	class Baz
	{
	}

	class MainClass
	{
		public static void Main (string[] args)
		{
			var c = new Foo<Baz>();
			Console.WriteLine (c.ToString ());
		}
	}

The way to make the testcase above work with AOT is have Foo<> inherit from Bar<,> (just uncomment the // part of the first line).

When compiling the testcase that doesn't work, only this Baz method is compiled:

@ mono --aot=print-skipped,full TestAot.exe  | grep Baz
add_method_with_index() called: Method 'TestAot.Baz:.ctor ()' 
compile_method() called: Method 'TestAot.Baz:.ctor ()' 

But when compiling the one with the extra inheritance, this happens:
@ mono --aot=print-skipped,full TestAot.exe  | grep Baz
add_method_with_index() called: Method 'TestAot.Baz:.ctor ()' 
add_method_with_index(): Method 'TestAot.Bar`2<TestAot.Baz, bool>:.ctor ()' 
compile_method(): Method 'TestAot.Baz:.ctor ()' 
compile_method(): Method 'TestAot.Bar`2<TestAot.Baz, bool>:.ctor ()'
Comment 2 Rodrigo Kumpera 2017-10-14 00:21:58 UTC
Thank you for your report!

It appears you are running a very old version of Mono. Could you please try to update to any recent version and try to reproduce the issue again.

If the issue still persists please include the version information and change the bug status to NEW.
Comment 3 Ludovic Henry 2018-01-24 18:07:28 UTC
I cannot reproduce with Mono 5.11.0.276 (master/117468d740a). Please reopen and provide information if you can still reproduce it. Thank you.