Bug 15681 - InvalidCastException in MonoTouch.ObjCRuntime.Trampolines+SDUICompletionHandler.Invoke
Summary: InvalidCastException in MonoTouch.ObjCRuntime.Trampolines+SDUICompletionHandl...
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: 7.0.6
Assignee: Rolf Bjarne Kvinge [MSFT]
: 15673 ()
Depends on:
Reported: 2013-10-24 23:52 UTC by Frank A. Krueger
Modified: 2014-01-14 18:33 UTC (History)
6 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 Frank A. Krueger 2013-10-24 23:52:44 UTC
Compiled with MT mtouch (6701308)

Release build on iOS 7.3

Unhandled managed exception: Cannot cast from source type to destination type. (System.InvalidCastException)
	  at MonoTouch.ObjCRuntime.Trampolines+SDUICompletionHandler.Invoke (IntPtr block, Boolean finished) [0x00000] in <filename unknown>:0 
	  at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Trampolines/SDUICompletionHandler:Invoke (intptr,int)
	  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
	  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0 
	  at Calca.iOS.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0 

0   libsystem_kernel.dylib        	0x3820e1fc __pthread_kill + 8
1   libsystem_pthread.dylib       	0x38275a4f pthread_kill + 55
2   libsystem_c.dylib             	0x381bf029 abort + 73
3   CalcaiOS                      	0x004ace45 mono_handle_native_sigsegv (mini-exceptions.c:2413)
4   CalcaiOS                      	0x004b208f sigabrt_signal_handler (mini-posix.c:206)
5   libsystem_platform.dylib      	0x38270721 _sigtramp + 41
6   libsystem_pthread.dylib       	0x38275a4f pthread_kill + 55
7   libsystem_c.dylib             	0x381bf029 abort + 73
8   CalcaiOS                      	0x0055d214 monotouch_unhandled_exception_handler (monotouch-glue.m:1436)
9   CalcaiOS                      	0x004ad205 mono_invoke_unhandled_exception_hook (mini-exceptions.c:2749)
10  CalcaiOS                      	0x004ba283 mono_thread_abort_dummy (mini.c:2767)
11  CalcaiOS                      	0x004aca0d mono_handle_exception_internal (mini-exceptions.c:1710)
12  CalcaiOS                      	0x004ac18f mono_handle_exception (mini-exceptions.c:2003)
13  CalcaiOS                      	0x004a5c8d mono_arm_throw_exception (exceptions-arm.c:161)
14  CalcaiOS                      	0x004a5ce1 mono_arm_throw_exception_by_token (exceptions-arm.c:172)
15  CalcaiOS                      	0x00351c30 ___lldb_unnamed_function21176$$CalcaiOS + 60
16  CalcaiOS                      	0x001db02c ___lldb_unnamed_function11406$$CalcaiOS + 100
17  UIKit                         	0x300b9e6b -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 283
18  UIKit                         	0x300b9ab3 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 175
19  UIKit                         	0x300b99cb -[UIViewAnimationState animationDidStop:finished:] + 63
20  QuartzCore                    	0x2fd0f40f CA::Layer::run_animation_callbacks(void*) + 231
21  libdispatch.dylib             	0x381430ad _dispatch_client_callout + 21
22  libdispatch.dylib             	0x381459a5 _dispatch_main_queue_callback_4CF + 265
23  CoreFoundation                	0x2d8c85ad __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 5
24  CoreFoundation                	0x2d8c6e79 __CFRunLoopRun + 1305
25  CoreFoundation                	0x2d83146d CFRunLoopRunSpecific + 521
26  CoreFoundation                	0x2d83124f CFRunLoopRunInMode + 103
27  GraphicsServices              	0x325652e7 GSEventRunModal + 135
28  UIKit                         	0x300e6841 UIApplicationMain + 1133
29  CalcaiOS                      	0x001da528 ___lldb_unnamed_function11385$$CalcaiOS + 268
30  CalcaiOS                      	0x001a5c54 ___lldb_unnamed_function9846$$CalcaiOS + 296
31  CalcaiOS                      	0x000a517c Calca.iOS.Application:Main + 44
32  CalcaiOS                      	0x00328150 ___lldb_unnamed_function20265$$CalcaiOS + 196
33  CalcaiOS                      	0x004b9927 mono_jit_runtime_invoke (mini.c:6503)
34  CalcaiOS                      	0x00501303 mono_runtime_invoke (object.c:2827)
35  CalcaiOS                      	0x00505091 mono_runtime_exec_main (object.c:4054)
36  CalcaiOS                      	0x00504ed1 mono_runtime_run_main (object.c:3678)
37  CalcaiOS                      	0x004a3cbd mono_jit_exec (driver.g.c:962)
38  CalcaiOS                      	0x0054b398 main (main.m:486)
39  libdyld.dylib                 	0x38157ab5 start + 1
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-10-25 03:55:01 UTC
What do I need to do to reproduce this?

I tried running the Calca code we have in release mode, and it doesn't crash at startup, nor when I open a few example sheets.
Comment 2 Frank A. Krueger 2013-10-25 11:42:37 UTC
You need to jump quickly between the examples. The easiest way is to use the left and right buttons. You have to be mean and press those buttons faster than it can handle.

Also, make sure it's 7.0.3. That seems to be an evil version.

If it still won't repro, then I'll send new code.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-10-28 20:31:58 UTC
*** Bug 15673 has been marked as a duplicate of this bug. ***
Comment 4 Rolf Bjarne Kvinge [MSFT] 2013-10-28 20:36:26 UTC
Fixed one source of this bug.

maccore/master: 7b82a35e22d2fab9f04cac79cdf0cdd3393ebaff
monotouch/master: 2db341b06781619cdad891b36139b6c136a656c0

maccore/monotouch-7.0.4-branch: 8808935e525c6d865027672a6a4ee0dd6203cfeb
monotouch/monotouch-7.0.4-branch: f48f38d1f34c4fc05939436936f5a0d98b566294
Comment 5 Rolf Bjarne Kvinge [MSFT] 2013-11-04 05:27:26 UTC
Frank, have you run into this problem again (or the "GCHandle value belongs to a different domain" exception) after the updated version I gave you?
Comment 6 Rolf Bjarne Kvinge [MSFT] 2013-11-11 08:29:27 UTC
Closing, looks like this is fixed.
Comment 7 PJ 2013-12-11 18:45:55 UTC
This fix is planned to be released with Xamarin.iOS 7.0.6, which should hit the beta channel before December 23rd.
Comment 8 narayanp 2014-01-14 07:30:31 UTC
Can you provide test project or test steps so that we can verify this issue?
Comment 9 Rolf Bjarne Kvinge [MSFT] 2014-01-14 07:43:16 UTC
There is no test project for this bug.
Comment 10 Prashant manu 2014-01-14 09:55:02 UTC
Hi Rolf,

Could you please provide us some test steps that we can follow to verify this Bug at our end? 

Comment 11 Rolf Bjarne Kvinge [MSFT] 2014-01-14 10:06:01 UTC
Prashant, no I can't provide a way to verify this bug. I'll just mark it as VERIFIED directly.