Bug 587 - Full-AOT failure when *not* linking the application
Summary: Full-AOT failure when *not* linking the application
Status: CLOSED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 4.x
Hardware: Macintosh Mac OS
: High critical
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
: 765 770 1017 1824 ()
Depends on:
Blocks:
 
Reported: 2011-09-01 16:45 UTC by Sebastien Pouliot
Modified: 2012-01-04 16:06 UTC (History)
7 users (show)

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


Attachments
log of the execution with "MONO_LOG_LEVEL=debug" (unlinked build) (136.62 KB, text/plain)
2011-09-01 16:45 UTC, Sebastien Pouliot
Details
Unlinked System.Core.dll (failing full-aot) (265.50 KB, application/octet-stream)
2011-09-01 16:51 UTC, Sebastien Pouliot
Details
linked System.Core.dll (working in full-aot) (8.50 KB, application/octet-stream)
2011-09-01 16:54 UTC, Sebastien Pouliot
Details
log of the execution with "MONO_LOG_LEVEL=debug" (working linked build) (65.01 KB, text/plain)
2011-09-01 16:55 UTC, Sebastien Pouliot
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 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:
Status:
CLOSED FIXED

Description Sebastien Pouliot 2011-09-01 16:45:59 UTC
Created attachment 232 [details]
log of the execution with "MONO_LOG_LEVEL=debug" (unlinked build)

The following code break MonoTouch

private readonly Dictionary<string, string> queued = new Dictionary<string, string> ();
KeyValuePair<string, string> valuePair = queued.FirstOrDefault (delegate { return true; });

while running on devices with:

[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException: Attempting to JIT compile method 'System.Linq.Check:SourceAndPredicate (object,object)' while running with --aot-only.

The method mentioned does not include any generic. What is stranger is that this fails when using "Don't link" but it *works* when using "Link SDK assemblies". The method (above) is *not* linked away (see attached assemblies).
Comment 1 Sebastien Pouliot 2011-09-01 16:51:38 UTC
Created attachment 233 [details]
Unlinked System.Core.dll (failing full-aot)
Comment 2 Sebastien Pouliot 2011-09-01 16:54:17 UTC
Created attachment 235 [details]
linked System.Core.dll (working in full-aot)
Comment 3 Sebastien Pouliot 2011-09-01 16:55:06 UTC
Created attachment 236 [details]
log of the execution with "MONO_LOG_LEVEL=debug" (working linked build)
Comment 4 Sebastien Pouliot 2011-09-12 21:15:00 UTC
*** Bug 765 has been marked as a duplicate of this bug. ***
Comment 5 Sebastien Pouliot 2011-09-12 21:17:00 UTC
This is a regression from 4.0.7 (see bug #765). I'll start to bisect this tomorrow morning.
Comment 6 Sebastien Pouliot 2011-09-13 09:20:25 UTC
*** Bug 770 has been marked as a duplicate of this bug. ***
Comment 7 Sebastien Pouliot 2011-09-19 19:17:27 UTC
Bug #872 attached test case shows the same issue (when "Don't link" is used).

It also hit Jackson today

[14:18:09] <jackson> Is there something I need to do to get Linq working? I'm getting lots of these errors "Attempting to JIT compile method 'System.Linq.Enumerable:Count<string> (System.Collections.Generic.IEnumerable`1<string>)' while running with --aot-only."
...
[15:21:27] <spouliot> jackson: your LINQ issue is likely related to http://ios.xamarin.com/Documentation/Limitations#Limited_Generics_Support or, if you turned off the linker, to bug #587
...
[15:24:06] <jackson> spouliot: thanks. It apparently worked before though
...
[15:25:45] <jackson> oh, the linker is off for this app
[15:25:56] <spouliot> :)
[15:27:22] <jackson> excellent. i think that fixed it
Comment 8 Sebastien Pouliot 2011-09-21 13:11:36 UTC
Finally found the issue, the new 4.1 build system does not build System.dll and System.Core.dll like it was done before, i.e. it includes more things and that leads (not sure why) to the "Attempting to JIT compile method ..." messages. 

The linker eliminates those (must be because they are called from the runtime, otherwise it would keep them) and produce working applications. Since "Link SDK assemblies" is the default, for devices/AOT builds, it took some time before we started getting reports about the issue (and looking at the mono source code changes did not help ;-)
Comment 9 Sebastien Pouliot 2011-09-21 14:33:24 UTC
Fixed in master and monotouch-4.2
Comment 10 AndyW 2011-09-29 10:06:29 UTC
*** Bug 1017 has been marked as a duplicate of this bug. ***
Comment 11 Sebastien Pouliot 2011-11-04 22:24:10 UTC
*** Bug 1824 has been marked as a duplicate of this bug. ***
Comment 12 PJ 2012-01-04 16:06:42 UTC
Verified as fixed
Mac 10.7.2
Mono 2.10.8
MonoDeveloper 2.8.5
MonoTouch 5.0.4
Closing.