Bug 2096 - AOT fails on device when a generic method calls another method with additional hard-coded type parameter
Summary: AOT fails on device when a generic method calls another method with additiona...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-11-20 07:18 UTC by MartinG
Modified: 2013-05-29 20:21 UTC (History)
4 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-11-20 07:18:40 UTC
Following test case will reproduce when run on device (using MT 5.0.2):

    [TestFixture]
    public class GenericsTest
    {
        [Test]
        public void TestIt()
        {
            var a = new A();

            // The following work:
            a.OuterMethod<int>(1);
            a.OuterMethod<DateTime>(DateTime.Now);

            var v = new VT();
            a.OuterMethod<VT>(v);

            var x = new D();
            // Next line will crash with Attempting to JIT compile method on device
            //  Attempting to JIT compile method 'Touch.Unit.A:InnerMethod<Touch.Unit.D, long> (Touch.Unit.D,long)' while running with --aot-only.
            a.OuterMethod<D>(x);
        }
    }

    public struct VT
    {
        public Action a;
    }

    public class D
    {
    }

    public class A
    {
        public void OuterMethod<TArg1>(TArg1 value)
        {
            this.InnerMethod<TArg1, long>(value, 0);
        }

        private void InnerMethod<TArg1, TArg2>(TArg1 v1, TArg2 v2)
        {
            Console.WriteLine("{0} {1}",v1,v2);
        }
    }
Comment 1 Sebastien Pouliot 2011-11-23 17:52:24 UTC
Confirmed (both Debug/Release and Linked/Unlinked). 
We generally have issues with value-types but this one is different.
Test case added to our internal test suite.
Comment 2 Sebastien Pouliot 2013-05-29 20:21:41 UTC
This test case now works fine with 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).