Bug 2155 - Crash in iOS 5 iterating Linq.OrderedEnumerable
Summary: Crash in iOS 5 iterating Linq.OrderedEnumerable
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-11-22 11:34 UTC by Paul Seabury
Modified: 2011-12-05 11:21 UTC (History)
5 users (show)

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

OrderedEnumerable crash test case (2.32 MB, application/zip)
2011-11-22 11:34 UTC, Paul Seabury
diff between release and debug (14.29 KB, application/octet-stream)
2011-11-24 15:37 UTC, Sebastien Pouliot

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 Paul Seabury 2011-11-22 11:34:12 UTC
Created attachment 931 [details]
OrderedEnumerable crash test case

Test project is attached. 

Basically when running a release version of code on Hardware only, the test case produces a crash with the Exception:

Attempting to JIT compile 'System.Linq.OrderedEnumerable`1<MyObjectType>:GetEnumerator()' while running with --aot-only.

Debug builds work in both simulator and hardware, and release mode works fine in the simulator.  Using mono 2.106, and MonoTouch 5.0.2.

Comment 1 Sebastien Pouliot 2011-11-22 14:05:26 UTC
ref: http://stackoverflow.com/questions/8187990/monotouch-jit-error-in-release-mode-on-linq-method/8195686#comment10122131_8195686

Confirmed. It fails on Release but works on the Debug configuration.
Comment 2 Sebastien Pouliot 2011-11-22 15:34:33 UTC
Setting "Enable debugging" checkbox on the "iPhone Build" (Project Options) will make "Release" work, so this is not related to the DEBUG define (or when smcs compiles). IOW mtouch gets -debug and propagate it down to the other tools... I'll find which one(s) matter in this case.
Comment 3 Sebastien Pouliot 2011-11-22 21:00:29 UTC
I hope it's only because I'm sleepy... anyway the exception does not occur if both "--debug" and "soft-debug" are used when calling the AOT compiler. If only --debug is used the same exception occurs (and "soft-debug" and only be used with --debug).
Comment 4 Sebastien Pouliot 2011-11-24 15:37:17 UTC
Created attachment 945 [details]
diff between release and debug

I looked at the .s generated by the AOT compiler in release and debug mode, extracted the .no_dead_strip entries, sorted and diff'ed the results (attached)

The debug builds include quite a few more entries (than the release one) including a few GetEnumerator, including:

+	.no_dead_strip System_Linq_OrderedEnumerable_1_LinqOrderedEnumerableBugTestCase_DocType_GetEnumerator

which looks like the AOT exception being shown by the test case.
Comment 5 Sebastien Pouliot 2011-11-25 10:24:33 UTC
//		opt->mdb_optimizations = TRUE;
makes the DEBUG fails like the Release version
Comment 6 Sebastien Pouliot 2011-11-25 12:26:32 UTC
tracked down to:
cfg->opt &= ~MONO_OPT_INLINE;

i.e. disabling inlining is what allows the extra methods to be available and makes the DEBUG version works as expected.
Comment 7 Paul Seabury 2011-11-30 10:51:26 UTC
Thanks for looking at that Sebastian.  Is there a configuration workaround in Monodevelop/Monotouch that I can use until a fix is out?

Comment 11 Zoltan Varga 2011-12-04 23:53:49 UTC
Fixed in HEAD and on 2-10 (83e5c48472262d47fa73c3c65364b87ec328d425).
Comment 12 Zoltan Varga 2011-12-05 00:02:13 UTC
3e62b6e207e7355a07f1d166b17590726cde9 is needed as well from 2.10.
Comment 13 Sebastien Pouliot 2011-12-05 11:21:31 UTC
Fixes pulled in MonoTouch (master).
Confirmed as fixed.