A couple of months back I hit JIT errors when using LINQ for objects. I was
never able to resolve them, but as the LINQ involved was pretty simple, I
just "unrolled" it into procedural code.

Now I'm getting more of them, and I'd really prefer to leave the LINQ alone
if possible. The exception I'm getting today is:

Attempting to JIT compile method
'System.Linq.Enumerable:<ToLookup`2>m__18<JIT20110908.ActualScore, int>
(JIT20110908.ActualScore)' while running with --aot-only.

Below is my ProblemLinq.cs file, which contains a class with an Execute()
method that causes this error. I realize there's a lot of interfaces and
classes here; this is a severely dumbed-down version of the actual code,
which is part of a cross-platform reporting library. The code in question is
running in Windows as part of a production product.

I've read the "Limitations" section on the xamarin website, and while I
can't say I understand it totally, I don't see that my code is doing any of
the verboten virtualization things; although LINQ does enough magic that I
don't necessarily know the secondary effects of the code.

The stack trace from the error this class causes follows the code.

I'm running MT 4.0.7 and MD2.6.

Am I doing some LINQ thing I shouldn't? Or is MT missing something?

Thanks.

// PROBLEMLINQ.CS -- calling the Execute method on ProblemLinq causes this
error

using System;

using System.Linq;

using System.Collections.Generic;


namespace JIT20110908

{

public class ProblemLinq

{

 public ProblemLinq ()

 {

 }

  public IList<SummaryRow> Execute ()

 {

 DateTime startDate = new DateTime (2011, 07, 01);

 DateTime endDate = new DateTime (2011, 08, 01);

   IList<IScore> scores = new List<IScore> ();

 ActualScore score1 = new ActualScore () {

  Name = "ACTIVITIES",

  Score = 22.2,

  OwnerID = 666

 } ;

 scores.Add (score1);

   IList<IFooSession > sessions = new List<IFooSession> ();

 MySession mysession = new MySession () {

  SessionDate = new DateTime(2011, 07, 15),

  SessionID = 666,

 } ;

 sessions.Add (mysession);

   IList<SummaryRow > summaryRows = (from s in sessions

                                             orderby s.SessionDate

                                             join score
inscores.OfType<ActualScore>()

                                                on s.SessionID equals
score.OwnerID

                                             where s.SessionDate >=
startDate && s.SessionDate <= endDate

                                             select new SummaryRow

                                             {

                                                 AssessmentDate =
s.SessionDate,

                                                 Name = score.Name,

                                                 OwnerID = score.OwnerID

                                             }).ToList ();

 return summaryRows;

 }

}

 public interface IScore

{

 int OwnerID { get; set; }

 string Name { get; set; }

}

 public class SummaryRow : IScore

{

 public string Name { get; set; }

 public int OwnerID { get; set; }

 public DateTime AssessmentDate { get; set; }

}

 public interface IFooSession

{

 int SessionID { get; set; }

 DateTime SessionDate { get; set; }

}

 public class MySession : IFooSession

{

 public int SessionID { get; set; }

 public DateTime SessionDate { get; set; }

}

 public class GeneralScore : IScore

{

 public int OwnerID { get; set; }

 public string Name { get; set; }

}


 public class ActualScore : GeneralScore

{

 public double Score { get; set; }

}

}

// END PROBLEMLINQ.CS


STACK TRACE FROM ERROR:


Unhandled Exception: System.ExecutionEngineException: Attempting to JIT
compile method
'System.Linq.Enumerable:<ToLookup`2>m__18<JIT20110908.ActualScore, int>
(JIT20110908.ActualScore)' while running with --aot-only.


  at System.Linq.Enumerable.ToLookup[ActualScore,Int32,ActualScore]
(IEnumerable`1 source, System.Func`2 keySelector, System.Func`2
elementSelector, IEqualityComparer`1 comparer) [0x00079] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2915

  at System.Linq.Enumerable.ToLookup[ActualScore,Int32] (IEnumerable`1
source, System.Func`2 keySelector, IEqualityComparer`1 comparer) [0x00000]
in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2883

  at
System.Linq.Enumerable+<CreateJoinIterator>c__IteratorB`4[JIT20110908.IFooSession,JIT20110908.ActualScore,System.Int32,<>__AnonType0`2[JIT20110908.IFooSession,JIT20110908.ActualScore]].MoveNext
() [0x00023] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:1153

  at
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1E`1[<>__AnonType0`2[JIT20110908.IFooSession,JIT20110908.ActualScore]].MoveNext
() [0x00000] in <filename unknown>:0

  at
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[<>__AnonType0`2[JIT20110908.IFooSession,JIT20110908.ActualScore],JIT20110908.SummaryRow].MoveNext
() [0x00000] in <filename unknown>:0

  at System.Collections.Generic.List`1[JIT20110908.SummaryRow].AddEnumerable
(IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0

  at System.Collections.Generic.List`1[JIT20110908.SummaryRow]..ctor
(IEnumerable`1 collection) [0x00000] in <filename unknown>:0

  at System.Linq.Enumerable.ToList[SummaryRow] (IEnumerable`1 source)
[0x00000] in <filename unknown>:0

  at JIT20110908.ProblemLinq.Execute () [0x0009f] in
/Users/alphce/Projects/JIT20110908/JIT20110908/ProblemLinq.cs:33

  at JIT20110908.AppDelegate.FinishedLaunching
(MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary
options) [0x00011] in
/Users/alphce/Projects/JIT20110908/JIT20110908/Main.cs:29

  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00000] in <filename
unknown>:0

  at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in
<filename unknown>:0

  at JIT20110908.Application.Main (System.String[] args) [0x00000] in
/Users/alphce/Projects/JIT20110908/JIT20110908/Main.cs:13

[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException:
Attempting to JIT compile method
'System.Linq.Enumerable:<ToLookup`2>m__18<JIT20110908.ActualScore, int>
(JIT20110908.ActualScore)' while running with --aot-only.


  at System.Linq.Enumerable.ToLookup[ActualScore,Int32,ActualScore]
(IEnumerable`1 source, System.Func`2 keySelector, System.Func`2
elementSelector, IEqualityComparer`1 comparer) [0x00079] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2915

  at System.Linq.Enumerable.ToLookup[ActualScore,Int32] (IEnumerable`1
source, System.Func`2 keySelector, IEqualityComparer`1 comparer) [0x00000]
in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:2883

  at
System.Linq.Enumerable+<CreateJoinIterator>c__IteratorB`4[JIT20110908.IFooSession,JIT20110908.ActualScore,System.Int32,<>__AnonType0`2[JIT20110908.IFooSession,JIT20110908.ActualScore]].MoveNext
() [0x00023] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Core/System.Linq/Enumerable.cs:1153

  at
System.Linq.Enumerable+<CreateWhereIterator>c__Iterator1E`1[<>__AnonType0`2[JIT20110908.IFooSession,JIT20110908.ActualScore]].MoveNext
() [0x00000] in <filename unknown>:0

  at
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10`2[<>__AnonType0`2[JIT20110908.IFooSession,JIT20110908.ActualScore],JIT20110908.SummaryRow].MoveNext
() [0x00000] in <filename unknown>:0

  at System.Collections.Generic.List`1[JIT20110908.SummaryRow].AddEnumerable
(IEnumerable`1 enumerable) [0x00000] in <filename unknown>:0

  at System.Collections.Generic.List`1[JIT20110908.SummaryRow]..ctor
(IEnumerable`1 collection) [0x00000] in <filename unknown>:0

  at System.Linq.Enumerable.ToList[SummaryRow] (IEnumerable`1 source)
[0x00000] in <filename unknown>:0

  at JIT20110908.ProblemLinq.Execute () [0x0009f] in
/Users/alphce/Projects/JIT20110908/JIT20110908/ProblemLinq.cs:33

  at JIT20110908.AppDelegate.FinishedLaunching
(MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary
options) [0x00011] in
/Users/alphce/Projects/JIT20110908/JIT20110908/Main.cs:29

  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00000] in <filename
unknown>:0

  at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in
<filename unknown>:0

  at JIT20110908.Application.Main (System.String[] args) [0x00000] in
/Users/alphce/Projects/JIT20110908/JIT20110908/Main.cs:13

Terminating runtime due to unhandled exception

Stacktrace:



Native stacktrace:


0   JIT20110908                         0x002653dc
mono_handle_native_sigsegv + 412

1   JIT20110908                         0x0028c5c8 sigabrt_signal_handler +
148

2   libsystem_c.dylib                   0x3564172f _sigtramp + 42

3   libsystem_c.dylib                   0x356363bb pthread_kill + 58

4   libsystem_c.dylib                   0x3562ebff abort + 78

5   JIT20110908                         0x003a15bc monoeg_g_logv + 248

6   JIT20110908                         0x003a1650 monoeg_assertion_message
+ 44

7   JIT20110908                         0x00246e7c mono_thread_abort + 224

8   JIT20110908                         0x00264824
mono_handle_exception_internal + 2436

9   JIT20110908                         0x0026510c mono_handle_exception +
108

10  JIT20110908                         0x0028a5dc mono_arm_throw_exception
+ 324

11  JIT20110908                         0x0019547c throw_exception + 48

12  JIT20110908                         0x00249e50 mono_jit_compile_method +
136

13  JIT20110908                         0x003337ec mono_compile_method + 84

14  JIT20110908                         0x00268110 mono_delegate_trampoline
+ 904

15  JIT20110908                         0x00194f64
generic_trampoline_delegate + 136

16  JIT20110908                         0x001f3254
System_Linq_Enumerable_ToLookup_JIT20110908_ActualScore_int_System_Collections_Generic_IEnumerable_1_JIT20110908_ActualScore_System_Func_2_JIT20110908_ActualScore_int_System_Collections_Generic_IEqualityComparer_1_int
+ 228

17  JIT20110908                         0x001f0c58
System_Linq_Enumerable__CreateJoinIteratorc__IteratorB_4_JIT20110908_IFooSession_JIT20110908_ActualScore_int____AnonType0_2_JIT20110908_IFooSession_JIT20110908_ActualScore_MoveNext
+ 432

18  JIT20110908                         0x00004ac0
System_Linq_Enumerable__CreateWhereIteratorc__Iterator1E_1_MoveNext + 456

19  JIT20110908                         0x00004644
System_Linq_Enumerable__CreateSelectIteratorc__Iterator10_2_MoveNext + 432

20  JIT20110908                         0x000ad5d8
System_Collections_Generic_List_1_AddEnumerable_System_Collections_Generic_IEnumerable_1_T
+ 188

21  JIT20110908                         0x000acd68
System_Collections_Generic_List_1__ctor_System_Collections_Generic_IEnumerable_1_T
+ 132

22  JIT20110908                         0x000030f8
System_Linq_Enumerable_ToList_TSource_System_Collections_Generic_IEnumerable_1_TSource
+ 68

23  JIT20110908                         0x001e6be0
JIT20110908_ProblemLinq_Execute + 2604

24  JIT20110908                         0x001e5e98
JIT20110908_AppDelegate_FinishedLaunching_MonoTouch_UIKit_UIApplication_MonoTouch_Foundation_NSDictionary
+ 300

25  JIT20110908                         0x00164c88
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200

26  JIT20110908                         0x0024af20 mono_jit_runtime_invoke +
2800

27  JIT20110908                         0x00339bfc mono_runtime_invoke + 140

28  JIT20110908                         0x003bf834 monotouch_trampoline +
2840

29  UIKit                               0x31120821 -[UIApplication
_callInitializationDelegatesForURL:payload:suspended:] + 772

30  UIKit                               0x3111ab65 -[UIApplication
_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272

31  UIKit                               0x310ef7d7 -[UIApplication
handleEvent:withNewEvent:] + 1114

32  UIKit                               0x310ef215 -[UIApplication
sendEvent:] + 44

33  UIKit                               0x310eec53 _UIApplicationHandleEvent
+ 5090

34  GraphicsServices                    0x31a7ae77 PurpleEventCallback + 666

35  CoreFoundation                      0x3718ea97
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26

36  CoreFoundation                      0x3719083f __CFRunLoopDoSource1 +
166

37  CoreFoundation                      0x3719160d __CFRunLoopRun + 520

38  CoreFoundation                      0x37121ec3 CFRunLoopRunSpecific +
230

39  CoreFoundation                      0x37121dcb CFRunLoopRunInMode + 58

40  UIKit                               0x31119d49 -[UIApplication _run] +
372

41  UIKit                               0x31117807 UIApplicationMain + 670

42  JIT20110908                         0x0006656c
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr
+ 240

43  JIT20110908                         0x000528bc
MonoTouch_UIKit_UIApplication_Main_string__ + 36

44  JIT20110908                         0x001e60a0
JIT20110908_Application_Main_string__ + 128

45  JIT20110908                         0x00164c88
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200

46  JIT20110908                         0x0024af20 mono_jit_runtime_invoke +
2800

47  JIT20110908                         0x00339bfc mono_runtime_invoke + 140

48  JIT20110908                         0x0033cbac mono_runtime_exec_main +
784

49  JIT20110908                         0x0033bc10 mono_runtime_run_main +
1048

50  JIT20110908                         0x002526d0 mono_jit_exec + 216

51  JIT20110908                         0x002454f8 main + 3448

52  JIT20110908                         0x00002774 start + 52


Debug info from gdb:



=================================================================

Got a SIGABRT while executing native code. This usually indicates

a fatal error in the mono runtime or one of the native libraries

used by your application.

=================================================================



-- 
Brian Schuth
ALPHCE, Inc.
Eastport, ME
+1 207 370 2430
[email protected]
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to