Bug 2337 - Task<T>.ContinueWith failing with Attempting to JIT compile errors on device
Summary: Task<T>.ContinueWith failing with Attempting to JIT compile errors on device
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-12-04 09:00 UTC by MartinG
Modified: 2013-08-08 17:48 UTC (History)
5 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 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:
RESOLVED FIXED

Description MartinG 2011-12-04 09:00:56 UTC
Following code reproduces JIT compile error on device:
        [Test]
        public void ContinuationTestB()
        {
            this.InnerTestB<string>();
        }

        private Task<bool> InnerTestB<T>()
        {
            return Task.Factory.StartNew(() => default(T))
                        .ContinueWith(t => true);
        }

Testing on MT5.1 Beta

Errors with:

 System.ExecutionEngineException : Attempting to JIT compile method 'System.Threading.Tasks.Task`1<string>:ContinueWith<bool> (System.Func`2<System.Threading.Tasks.Task`1<string>, bool>,System.Threading.Tasks.TaskScheduler)' while running with --aot-only.

Note that this does not error if the continuation is replaced with a reference type, e.g.:
            return Task.Factory.StartNew(() => default(T))
                        .ContinueWith(t => new object());
Comment 1 Sebastien Pouliot 2012-03-11 12:01:02 UTC
This case has been added to our test suite.
Comment 2 Sebastien Pouliot 2013-05-29 20:17:50 UTC
This test case works fine in 6.3.x.

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).