Hi,
I'm working with MT on a project and now I'm stuck with a "strange" problem;
I've already googled for the issue and for a possible solution or
workaround, but nothing help me.
I'm using XCode 4, MT 4.0.7, Mono 2.10.5 and MD 2.6.0.1 and I'm developing
for iPhone.
After many inspections of the issue in my project I have succeeded in
synthesizing the problem in a single file project:
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
using System.Drawing;
namespace GenericsFailure
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
}
public interface IInterface
{
void Foo<T>();
}
public class CClass : IInterface
{
public void Foo<T> ()
{
T t = default(T);
}
}
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
private MonoTouch.UIKit.UIWindow __mt_window;
public override bool FinishedLaunching (UIApplication app,
NSDictionary
options)
{
__mt_window = new
UIWindow(UIScreen.MainScreen.ApplicationFrame);
UIView mainView = new
UIView(UIScreen.MainScreen.Bounds);
__mt_window.AddSubview(mainView);
UIButton clickMe =
UIButton.FromType(UIButtonType.RoundedRect);
clickMe.Frame = new RectangleF(0, 0,
UIScreen.MainScreen.Bounds.Width,
43);
clickMe.SetTitle("Click me", UIControlState.Normal);
clickMe.TouchUpInside += HandleClickMeTouchUpInside;
mainView.AddSubview(clickMe);
__mt_window.MakeKeyAndVisible ();
return true;
}
void HandleClickMeTouchUpInside (object sender, EventArgs e)
{
IInterface intf = new CClass();
intf.Foo<int>();
}
// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}
}
}
That is, a simple iPhone window based application with a button inside the
main view; I intercept the tap on the button and I create an instance of
CClass (the code inside Foo<T>() is just to use the type parameter...
not sure if it is necessary) then I call the Foo<T>() method.
Now, if I execute this app from the iPhoneSimulator everything works fine;
but if I execute the application from the physical device, the app crash and
print to the console the following message:
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT
compile method 'GenericsFailure.CClass:Foo<int> ()' while running with
--aot-only.
at GenericsFailure.AppDelegate.HandleClickMeTouchUpInside (System.Object
sender, System.EventArgs e) [0x00006] in
/Users/sergiofadda/Projects/MonoTest/GenericsFailure/GenericsFailure/Main.cs:56
at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
<filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00000] in
<filename unknown>:0
at GenericsFailure.Application.Main (System.String[] args) [0x00000] in
/Users/sergiofadda/Projects/MonoTest/GenericsFailure/GenericsFailure/Main.cs:12
[ERROR] FATAL UNHANDLED EXCEPTION: System.ExecutionEngineException:
Attempting to JIT compile method 'GenericsFailure.CClass:Foo<int> ()'
while running with --aot-only.
at GenericsFailure.AppDelegate.HandleClickMeTouchUpInside (System.Object
sender, System.EventArgs e) [0x00006] in
/Users/sergiofadda/Projects/MonoTest/GenericsFailure/GenericsFailure/Main.cs:56
at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
<filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String
principalClassName, System.String delegateClassName) [0x00000] in
<filename unknown>:0
at GenericsFailure.Application.Main (System.String[] args) [0x00000] in
/Users/sergiofadda/Projects/MonoTest/GenericsFailure/GenericsFailure/Main.cs:12
Terminating runtime due to unhandled exception
Stacktrace:
Native stacktrace:
0 GenericsFailure 0x0020185c
mono_handle_native_sigsegv + 412
1 GenericsFailure 0x00228a48
sigabrt_signal_handler +
148
2 libsystem_c.dylib 0x33e4372f _sigtramp + 42
3 libsystem_c.dylib 0x33e383bb pthread_kill + 58
4 libsystem_c.dylib 0x33e30bff abort + 78
5 GenericsFailure 0x0033da3c monoeg_g_logv + 248
6 GenericsFailure 0x0033dad0
monoeg_assertion_message
+ 44
7 GenericsFailure 0x001e32fc mono_thread_abort +
224
8 GenericsFailure 0x00200ca4
mono_handle_exception_internal + 2436
9 GenericsFailure 0x0020158c
mono_handle_exception +
108
10 GenericsFailure 0x00226a5c
mono_arm_throw_exception
+ 324
11 GenericsFailure 0x0019028c throw_exception + 48
12 GenericsFailure 0x001e62d0
mono_jit_compile_method
+ 136
13 GenericsFailure 0x002cfc6c mono_compile_method
+ 84
14 GenericsFailure 0x00203228
common_call_trampoline +
2208
15 GenericsFailure 0x00203aac
mono_vcall_trampoline +
464
16 GenericsFailure 0x00190198
generic_trampoline_vcall
+ 136
17 GenericsFailure 0x0004c7dc
MonoTouch_UIKit_UIControlEventProxy_Activated + 68
18 GenericsFailure 0x0015fb1c
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200
19 GenericsFailure 0x001e73a0
mono_jit_runtime_invoke
+ 2800
20 GenericsFailure 0x002d607c mono_runtime_invoke +
140
21 GenericsFailure 0x0035bcb4 monotouch_trampoline
+
2840
22 CoreFoundation 0x33bb7571 -[NSObject(NSObject)
performSelector:withObject:withObject:] + 24
23 UIKit 0x322b5ec9 -[UIApplication
sendAction:to:from:forEvent:] + 84
24 UIKit 0x322b5e69 -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 32
25 UIKit 0x322b5e3b -[UIControl
sendAction:to:forEvent:] + 38
26 UIKit 0x322b5b8d -[UIControl(Internal)
_sendActionsForEvents:withEvent:] + 356
27 UIKit 0x322b6423 -[UIControl
touchesEnded:withEvent:] + 342
28 UIKit 0x322b4bf5 -[UIWindow
_sendTouchesForEvent:] + 368
29 UIKit 0x322b456f -[UIWindow
sendEvent:] +
262
30 UIKit 0x3229d313 -[UIApplication
sendEvent:] + 298
31 UIKit 0x3229cc53
_UIApplicationHandleEvent + 5090
32 GraphicsServices 0x318dce77 PurpleEventCallback +
666
33 CoreFoundation 0x33c1ea97
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
34 CoreFoundation 0x33c2083f __CFRunLoopDoSource1
+
166
35 CoreFoundation 0x33c2160d __CFRunLoopRun + 520
36 CoreFoundation 0x33bb1ec3 CFRunLoopRunSpecific
+
230
37 CoreFoundation 0x33bb1dcb CFRunLoopRunInMode +
58
38 GraphicsServices 0x318dc41f GSEventRunModal + 114
39 GraphicsServices 0x318dc4cb GSEventRun + 62
40 UIKit 0x322c7d69 -[UIApplication
_run] +
404
41 UIKit 0x322c5807 UIApplicationMain +
670
42 GenericsFailure 0x00060f58
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr
+ 240
43 GenericsFailure 0x00002600
GenericsFailure_Application_Main_string__ + 152
44 GenericsFailure 0x0015fb1c
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
+ 200
45 GenericsFailure 0x001e73a0
mono_jit_runtime_invoke
+ 2800
46 GenericsFailure 0x002d607c mono_runtime_invoke +
140
47 GenericsFailure 0x002d902c
mono_runtime_exec_main +
784
48 GenericsFailure 0x002d8090
mono_runtime_run_main +
1048
49 GenericsFailure 0x001eeb50 mono_jit_exec + 216
50 GenericsFailure 0x001e1978 main + 3448
51 GenericsFailure 0x00002454 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.
=================================================================
I've noticed that this issue happens only if the generics method declaration
is defined into the interface.
Am I missing something?
Thanks in advance
Sergio
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/Generics-method-and-JIT-issue-tp3815466p3815466.html
Sent from the MonoTouch mailing list archive at Nabble.com._______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch