Bug 15673 - GCHandle value belongs to a different domain Exception
Summary: GCHandle value belongs to a different domain Exception
Status: RESOLVED DUPLICATE of bug 15681
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 7.0.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Rolf Bjarne Kvinge [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2013-10-24 16:52 UTC by Frank A. Krueger
Modified: 2013-10-28 20:31 UTC (History)
3 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 DUPLICATE of bug 15681

Description Frank A. Krueger 2013-10-24 16:52:43 UTC
I've built with /Developer/MonoTouch/usr/bin/mtouch --version
mtouch 7.0.4.92 (6701308)

Running on iOS 7.0.3

Testing a release build, I got an unhandled exception: GCHandle value belongs to a different domain. System.Runtime.InteropServices.GCHandle.FromIntPtr (intptr) causes it.

This seems to come from an animation completion handler firing through a delegate.

Unhandled Exception:
0   Calca                               0x004d2453 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4213358
1   Calca                               0x004d2c1b _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4215350
2   Calca                               0x004d28eb _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4214534
3   Calca                               0x004cc3e9 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4188676
4   Calca                               0x00378ba8 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 2798019
at System.Runtime.InteropServices.GCHandle.FromIntPtr (intptr) <0x00024>
at MonoTouch.ObjCRuntime.Trampolines/SDUICompletionHandler.Invoke (intptr,bool) <0x00064>
at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Trampolines/SDUICompletionHandler.Invoke (intptr,int) <0x00068>
8  UIKit                         	0x35948aae -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 154
9  UIKit                         	0x359bd8ea -[UIViewAnimationState animationDidStop:finished:] + 46
10  QuartzCore                    	0x356f2bfc CA::Layer::run_animation_callbacks(void*) + 204
11  libdispatch.dylib             	0x3bde64b4 _dispatch_client_callout + 20
12  libdispatch.dylib             	0x3bdeb1b8 _dispatch_main_queue_callback_4CF$VARIANT$mp + 220
13  CoreFoundation                	0x33afef36 __CFRunLoopRun + 1286
14  CoreFoundation                      0x33a71ebd CFRunLoopRunSpecific + 356
15  CoreFoundation                      0x33a71d49 CFRunLoopRunInMode + 104
16  GraphicsServices                    0x376262eb GSEventRunModal + 74
17  UIKit                               0x35987301 UIApplicationMain + 1120
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00110>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) <0x0012c>
at Calca.iOS.Application.Main (string[]) <0x00030>
at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0x000c8>
22  Calca                               0x004e0081 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4269724
23  Calca                               0x00527a5d _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4563064
24  Calca                               0x0052b7ed _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4578824
25  Calca                               0x0052b62d _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4578376
26  Calca                               0x004ca419 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4180532
27  Calca                               0x00571af4 monotouch_IntPtr_objc_msgSendSuper_IntPtr + 3320
28  libdyld.dylib                       0x3be06b20 <redacted> + 0

Oct 24 13:38:48 Precious-X Calca[1182] <Warning>: Unhandled managed exception: GCHandle value belongs to a different domain (System.ArgumentException)
	  at System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr value) [0x00000] in <filename unknown>:0 
	  at System.Runtime.InteropServices.GCHandle.FromIntPtr (IntPtr value) [0x00000] in <filename unknown>:0 
	  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
Comment 1 Frank A. Krueger 2013-10-24 23:41:18 UTC
This is pretty reproducible and I now have a more detailed native stack trace that shows monotouch_release_managed_ref as the last mono function called.

Here is the managed exception stack trace:

Unhandled managed exception: GCHandle value belongs to a different domain (System.ArgumentException)
	  at System.Runtime.InteropServices.GCHandle.op_Explicit (IntPtr value) [0x00000] in <filename unknown>:0 
	  at System.Runtime.InteropServices.GCHandle.FromIntPtr (IntPtr value) [0x00000] in <filename unknown>:0 
	  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 


Here is the native stack trace


0   Calca                               0x0053cf97 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4228530
1   Calca                               0x005422db _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4249846
2   libsystem_platform.dylib            0x38270723 _sigtramp + 42
3   libsystem_pthread.dylib             0x38275a53 pthread_kill + 58
4   libsystem_c.dylib                   0x381bf02d abort + 76
5   Calca                               0x005ed460 monotouch_release_managed_ref + 2016
6   Calca                               0x0053d44f _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4229738
7   Calca                               0x0054a4cf _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4283114
8   Calca                               0x0053cc57 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4227698
9   Calca                               0x0053c3db _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4225526
10  Calca                               0x00535ed9 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4199668
11  Calca                               0x003e1ba8 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 2806211
12  Calca                               0x002da74c _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 1727847
13  Calca                               0x0024c840 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 1146459
14  Calca                               0x0026b15c _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 1271671
18  UIKit                         	0x300b9e6b -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 283
19  UIKit                         	0x300b9ab3 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 175
20  UIKit                         	0x300b99cb -[UIViewAnimationState animationDidStop:finished:] + 63
21  QuartzCore                    	0x2fd0f40f CA::Layer::run_animation_callbacks(void*) + 231
22  libdispatch.dylib             	0x381430ad _dispatch_client_callout + 21
23  libdispatch.dylib             	0x381459a5 _dispatch_main_queue_callback_4CF + 265
24  CoreFoundation                	0x2d8c85ad __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 5
25  CoreFoundation                	0x2d8c6e79 __CFRunLoopRun + 1305
26  CoreFoundation                	0x2d83146d CFRunLoopRunSpecific + 521
27  CoreFoundation                	0x2d83124f CFRunLoopRunInMode + 103
28  GraphicsServices              	0x325652e7 GSEventRunModal + 135
29  UIKit                         	0x300e6841 UIApplicationMain + 1133
27  Calca                               0x0026a658 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 1268851
28  Calca                               0x00235c58 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 1053299
29  Calca                               0x00135180 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 1947
30  Calca                               0x003b8154 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 2635631
31  Calca                               0x00549b71 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4280716
32  Calca                               0x0059154d _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4574056
33  Calca                               0x005952dd _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4589816
34  Calca                               0x0059511d _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4589368
35  Calca                               0x00533f09 _ZNSt3__16__treeINS_4pairINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_3mapIS7_iNS_4lessIS7_EENS5_INS1_IKS7_iEEEEEEEENS_19__map_value_compareIS7_SE_SA_Lb1EEENS5_ISF_EEE16__insert_node_atEPNS_16__tree_node_baseIPvEERSN_SN_ + 4191524
36  Calca                               0x005db5e4 monotouch_IntPtr_objc_msgSendSuper_IntPtr + 3320
37  libdyld.dylib                       0x38157ab7 <redacted> + 2
Comment 2 Frank A. Krueger 2013-10-24 23:58:11 UTC
Here is a cleaner native stack trace. Sorry about the messes before:

Thread 0 Crashed:
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                      	0x004c8e45 mono_handle_native_sigsegv (mini-exceptions.c:2413)
4   CalcaiOS                      	0x004ce08f 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                      	0x00579214 monotouch_unhandled_exception_handler (monotouch-glue.m:1436)
9   CalcaiOS                      	0x004c9205 mono_invoke_unhandled_exception_hook (mini-exceptions.c:2749)
10  CalcaiOS                      	0x004d6283 mono_thread_abort_dummy (mini.c:2767)
11  CalcaiOS                      	0x004c8a0d mono_handle_exception_internal (mini-exceptions.c:1710)
12  CalcaiOS                      	0x004c818f mono_handle_exception (mini-exceptions.c:2003)
13  CalcaiOS                      	0x004c1c8d mono_arm_throw_exception (exceptions-arm.c:161)
14  CalcaiOS                      	0x0036dba4 ___lldb_unnamed_function21174$$CalcaiOS + 64
15  CalcaiOS                      	0x00266748 ___lldb_unnamed_function15106$$CalcaiOS + 32
16  CalcaiOS                      	0x001d87dc ___lldb_unnamed_function10691$$CalcaiOS + 96
17  CalcaiOS                      	0x001f704c ___lldb_unnamed_function11406$$CalcaiOS + 100
18  UIKit                         	0x300b9e6b -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 283
19  UIKit                         	0x300b9ab3 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 175
20  UIKit                         	0x300b99cb -[UIViewAnimationState animationDidStop:finished:] + 63
21  QuartzCore                    	0x2fd0f40f CA::Layer::run_animation_callbacks(void*) + 231
22  libdispatch.dylib             	0x381430ad _dispatch_client_callout + 21
23  libdispatch.dylib             	0x381459a5 _dispatch_main_queue_callback_4CF + 265
24  CoreFoundation                	0x2d8c85ad __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 5
25  CoreFoundation                	0x2d8c6e79 __CFRunLoopRun + 1305
26  CoreFoundation                	0x2d83146d CFRunLoopRunSpecific + 521
27  CoreFoundation                	0x2d83124f CFRunLoopRunInMode + 103
28  GraphicsServices              	0x325652e7 GSEventRunModal + 135
29  UIKit                         	0x300e6841 UIApplicationMain + 1133
30  CalcaiOS                      	0x001f6548 ___lldb_unnamed_function11385$$CalcaiOS + 268
31  CalcaiOS                      	0x001c1c74 ___lldb_unnamed_function9846$$CalcaiOS + 296
32  CalcaiOS                      	0x000c117c Calca.iOS.Application:Main + 44
33  CalcaiOS                      	0x00344150 ___lldb_unnamed_function20265$$CalcaiOS + 196
34  CalcaiOS                      	0x004d5927 mono_jit_runtime_invoke (mini.c:6503)
35  CalcaiOS                      	0x0051d303 mono_runtime_invoke (object.c:2827)
36  CalcaiOS                      	0x00521091 mono_runtime_exec_main (object.c:4054)
37  CalcaiOS                      	0x00520ed1 mono_runtime_run_main (object.c:3678)
38  CalcaiOS                      	0x004bfcbd mono_jit_exec (driver.g.c:962)
39  CalcaiOS                      	0x00567398 main (main.m:486)
40  libdyld.dylib                 	0x38157ab5 start + 1
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-10-25 03:57:23 UTC
Is it possible to reproduce this with the Calca app we have? If so, how?
Comment 4 Frank A. Krueger 2013-10-25 11:40:08 UTC
Repro:
1. Compile on Release and run on iOS 7.0.3
2. Use local storage (don't think it matters) and Restore the Docs so you have a full Examples directory
3. Open one of the Examples
4. Move between examples using the left and right arrows in the editor screen. Press the arrows as fast as possible. Be mean. Left and right. Eventually she will crash with the GCHandle bug or the other bug I filed.

I believe that it will repro with your code. But if it refuses to, I can send new code.
Comment 5 Frank A. Krueger 2013-10-26 00:11:45 UTC
This bug repros fine with debug builds so I was able to get a better native stack.

Thread 0 Crashed:
0   libsystem_kernel.dylib        	0x3aa451fc __pthread_kill + 8
1   libsystem_pthread.dylib       	0x3aaaea2e pthread_kill + 54
2   libsystem_c.dylib             	0x3a9f5ff8 abort + 72
3   CalcaiOS                      	0x00711e7c mono_handle_native_sigsegv (mini-exceptions.c:2413)
4   CalcaiOS                      	0x007170c6 sigabrt_signal_handler (mini-posix.c:206)
5   libsystem_platform.dylib      	0x3aaa9060 _sigtramp + 40
6   libsystem_pthread.dylib       	0x3aaaea2e pthread_kill + 54
7   libsystem_c.dylib             	0x3a9f5ff8 abort + 72
8   CalcaiOS                      	0x007c73dc monotouch_unhandled_exception_handler (monotouch-glue.m:1436)
9   CalcaiOS                      	0x0071223c mono_invoke_unhandled_exception_hook (mini-exceptions.c:2749)
10  CalcaiOS                      	0x0071f2ba mono_thread_abort_dummy (mini.c:2767)
11  CalcaiOS                      	0x00711a44 mono_handle_exception_internal (mini-exceptions.c:1710)
12  CalcaiOS                      	0x007111c6 mono_handle_exception (mini-exceptions.c:2003)
13  CalcaiOS                      	0x0070acc4 mono_arm_throw_exception (exceptions-arm.c:161)
14  CalcaiOS                      	0x00591f24 throw_exception + 64
15  CalcaiOS                      	0x0048a930 System_Runtime_InteropServices_GCHandle_FromIntPtr_intptr + 32
16  CalcaiOS                      	0x003fa7e0 MonoTouch_ObjCRuntime_Trampolines_SDUICompletionHandler_Invoke_intptr_bool + 96
17  CalcaiOS                      	0x00419148 wrapper_native_to_managed_MonoTouch_ObjCRuntime_Trampolines_SDUICompletionHandler_Invoke_intptr_int + 100
18  UIKit                         	0x3238f7c6 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 282
19  UIKit                         	0x3238f412 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 174
20  UIKit                         	0x3238f32e -[UIViewAnimationState animationDidStop:finished:] + 66
21  QuartzCore                    	0x31fe5724 CA::Layer::run_animation_callbacks(void*) + 228
22  libdispatch.dylib             	0x3a969d04 _dispatch_client_callout + 20
23  libdispatch.dylib             	0x3a970788 _dispatch_main_queue_callback_4CF$VARIANT$mp + 264
24  CoreFoundation                	0x2fbaf814 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
25  CoreFoundation                	0x2fbae0e8 __CFRunLoopRun + 1296
26  CoreFoundation                	0x2fb18c22 CFRunLoopRunSpecific + 518
27  CoreFoundation                	0x2fb18a06 CFRunLoopRunInMode + 102
28  GraphicsServices              	0x3481927e GSEventRunModal + 134
29  UIKit                         	0x323bc044 UIApplicationMain + 1132
30  CalcaiOS                      	0x00418644 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 268
31  CalcaiOS                      	0x003e33f0 MonoTouch_UIKit_UIApplication_Main_string___string_string + 296
32  CalcaiOS                      	0x0017d264 Calca.iOS.Application:Main + 168
33  CalcaiOS                      	0x00568434 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 196
34  CalcaiOS                      	0x0071e95e mono_jit_runtime_invoke (mini.c:6503)
35  CalcaiOS                      	0x0076633a mono_runtime_invoke (object.c:2827)
36  CalcaiOS                      	0x0076a0c8 mono_runtime_exec_main (object.c:4054)
37  CalcaiOS                      	0x00769f08 mono_runtime_run_main (object.c:3678)
38  CalcaiOS                      	0x00708cf4 mono_jit_exec (driver.g.c:962)
39  CalcaiOS                      	0x007b05b8 main (main.m:486)
40  libdyld.dylib                 	0x3a98eab4 start + 0
Comment 6 Rolf Bjarne Kvinge [MSFT] 2013-10-28 09:40:27 UTC
Even after lots of finger drumming to different rhythms I'm unable to reproduce any crashes when tapping the left/right buttons.

I've tried both on an iPad2 and iPad4, both with iOS 7.0.3, and Xamarin.iOS v7.0.4.92 (6701308).

So, could I get your updated code and see if that's the difference?
Comment 7 Miguel de Icaza [MSFT] 2013-10-28 12:27:47 UTC
These are the potential sources of this problem:

UICollectionView:
PerformBatchUpdates, SetCollectionViewLayout

UIPageViewController:
SetViewControllers

UIView:
AnimateNotify, TransitionNotify, PerformSystemAnimation, AnimateKeyframes

UIViewController:
Transition
Comment 8 Rolf Bjarne Kvinge [MSFT] 2013-10-28 13:33:42 UTC
I can reproduce with the new code drop.
Comment 9 Rolf Bjarne Kvinge [MSFT] 2013-10-28 20:31:58 UTC

*** This bug has been marked as a duplicate of bug 15681 ***