Bug 5509 - AOT failure with generic types.
Summary: AOT failure with generic types.
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.2
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-06-04 07:05 UTC by Greg Munn
Modified: 2013-05-31 08:34 UTC (History)
2 users (show)

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

AppDelegate used to recreate the crash. (14.54 KB, application/octet-stream)
2012-06-04 07:05 UTC, Greg Munn

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 Developer Community or GitHub 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 Greg Munn 2012-06-04 07:05:33 UTC
Created attachment 2017 [details]
AppDelegate used to recreate the crash.

I have a sample here that fails with the following error when running on device.  I realise that the compiler can't always figure out what to generate ahead of time with generics but thought that it might be a useful test case.

I created a new iPhone application and used the attached AppDelegate.cs.  It doesn't have a window - it just crashes instead :)  I have been experimenting with some Rx type functions and found this case which crashes on the device.

I have read in a few of the other bug reports that there might be more issues with value types in generics, is this true?


Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method 'AotTest.ObservableExtensions:<Subscribe`1>m__8<AotTest.Unit> (AotTest.Unit)' while running with --aot-only.

  at AotTest.AnonymousObserver`1[AotTest.Unit].OnNext (Unit value) [0x0000b] in /Users/sgm/Projects/Test/AotTestBackup/AotTest/AppDelegate.cs:358 
  at AotTest.MainThreadObservableExtensions+<ObserveOnMainThread>c__AnonStorey4`1+<ObserveOnMainThread>c__AnonStorey5`1[AotTest.Unit].<>m__D (Unit next) [0x00000] in /Users/sgm/Projects/Test/AotTestBackup/AotTest/AppDelegate.cs:419 
  at AotTest.MainThreadObserver`1+<OnNext>c__AnonStorey7[AotTest.Unit].<>m__12 () [0x00000] in /Users/sgm/Projects/Test/AotTestBackup/AotTest/AppDelegate.cs:484 
  at MonoTouch.Foundation.NSActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSAction.cs:48 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at AotTest.Application.Main (System.String[] args) [0x00000] in /Users/sgm/Projects/Test/AotTestBackup/AotTest/Main.cs:37 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: Attempting to JIT compile method 'AotTest.ObservableExtensions:<Subscribe`1>m__8<AotTest.Unit> (AotTest.Unit)' while running with --aot-only.
Comment 1 Greg Munn 2012-06-04 07:12:03 UTC
Changing the 'Unit' type from a struct to a class does actually 'fix' the issue, which leads me to think that generics and value types can have more issues.
Comment 2 Sebastien Pouliot 2013-05-31 08:34:22 UTC
This still fails with 6.2.6 but works with 6.3.x.

The 6.3.x beta releases have much improved to avoid this situation (the EngineExecutionException). You might want to try this, or similar code, again and report any remaining issues (with a test case).