Bug 767 - App crashes with JIT exception
Summary: App crashes with JIT exception
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 4.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-09-12 18:16 UTC by Adrian Grigore
Modified: 2013-05-31 08:37 UTC (History)
3 users (show)

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 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 Adrian Grigore 2011-09-12 18:16:13 UTC

Comment 1 Adrian Grigore 2011-09-12 18:18:56 UTC
I am getting JIT exceptions in various places when starting my app. This is an example:


I really don't know how to work around this one by changing my code since the problem appears in so many functions. I tried removing several method calls just to see my app up on the screen for a change, but I just keep getting various JIT exceptions.
Comment 2 Adrian Grigore 2011-09-12 18:26:53 UTC
One case I forgot to mention: I'm using Monotouch 4.2
Comment 3 Sebastien Pouliot 2011-09-12 19:29:34 UTC
There are a few reasons for that, most of them listed in:

The most common one, for LINQ, is the use of value-types in generics (even if hidden inside the LINQ expression). See bug #760 for an example. We can likely help to find workarounds for most cases.
Comment 4 Adrian Grigore 2011-09-18 16:15:24 UTC
I eventually managed to get around this bug by removing all LINQ from my source code. I tried just removing the bit that could not be compiled, rerun the app, repeat first, but after a few hours it became apparent that almost no LINQ code in my app can be compiled at all (only exception I noticed: LINQ2XML). So it was easier to remove everything instead. 

What made this really annoying is that there isn't even a warning when running the same app in the emulator. So I wrote a lot of incompatible code when I was still running the demo version of Monotouch, only to have to strip it out again once I was running the app on my actual iPhone device. 

I would highly suggest removing Linq entirely from monotouch by default and just make it possible to switch it on for developers who feel adventurous. Right now LINQ support is so broken that it probably does more harm than it is of any use.
Comment 5 Sebastien Pouliot 2013-05-31 08:37:09 UTC
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).