Monotouch SIGSEV In simulator only

1

I'm pretty new to Monotouch, and running into an error that is baffling me. I made a binding to an objective-c library for a sliding-style view ( https://github.com/edgecase/ECSlidingViewController ), and have been getting SIGSEVs while executing native code during the use of that library (specifically, it happens when I try to reveal the bottom view from the sliding controller).

Stacktrace:

at (wrapper managed-to-native) System.Runtime.InteropServices.GCHandle.CheckCurrentDomain (int) <IL 0x00021, 0xffffffff>
at System.Runtime.InteropServices.GCHandle.op_Explicit (intptr) [0x0001b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.InteropServices/GCHandle.cs:124
at System.Runtime.InteropServices.GCHandle.FromIntPtr (intptr) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.InteropServices/GCHandle.cs:169
at MonoTouch.ObjCRuntime.BlockDescriptor.CopyHelper (MonoTouch.ObjCRuntime.BlockLiteral*,MonoTouch.ObjCRuntime.BlockLiteral*) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/ObjCRuntime/Blocks.cs:54
at (wrapper native-to-managed) MonoTouch.ObjCRuntime.BlockDescriptor.CopyHelper (MonoTouch.ObjCRuntime.BlockLiteral*,MonoTouch.ObjCRuntime.BlockLiteral*) <IL 0x0001e, 0xffffffff>
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_int_IntPtr_IntPtr (intptr,intptr,int,intptr,intptr) <IL 0x00028, 0xffffffff>
at Enriquez.ECSlidingViewController.ECSlidingViewController.AnchorTopView (Enriquez.ECSlidingViewController.ECSide,Enriquez.ECSlidingViewController.ECAnimations,Enriquez.ECSlidingViewController.ECOnComplete) <IL 0x00097, 0x002ef>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___int_object_object (object,intptr,intptr,intptr) <IL 0x00066, 0xffffffff>
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_int (intptr,intptr,int) <IL 0x00025, 0xffffffff>
at Enriquez.ECSlidingViewController.ECSlidingViewController.AnchorTopView (Enriquez.ECSlidingViewController.ECSide) <IL 0x0002d, 0x0009f>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___int (object,intptr,intptr,intptr) <IL 0x00054, 0xffffffff>
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at FanApp.Application.Main (string[]) [0x00000] in /Users/markrubeo/Projects/FanApp/MonoTouch/Test Stuff/FanApp/Fan App/FanApp/Main.cs:17
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

0   FanApp                              0x00098adc mono_handle_native_sigsegv + 284
1   FanApp                              0x0000c3b8 mono_sigsegv_signal_handler + 248
2   libsystem_c.dylib                   0x99be28cb _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   FanApp                              0x00112aba GCHandle_CheckCurrentDomain + 26
5   ???                                 0x0d86e766 0x0 + 226944870
6   ???                                 0x0d86e668 0x0 + 226944616
7   ???                                 0x0d86e590 0x0 + 226944400
8   ???                                 0x0d86e4f8 0x0 + 226944248
9   ???                                 0x0d86db7c 0x0 + 226941820
10  libsystem_sim_blocks.dylib          0x0243acb6 _Block_call_copy_helper + 29
11  libsystem_sim_blocks.dylib          0x0243b73f _Block_copy_internal + 228
12  FanApp                              0x00004a91 -[ECSlidingViewController anchorTopViewTo:animations:onComplete:] + 545
13  ???                                 0x0d86e458 0x0 + 226944088
14  ???                                 0x0d86d2f0 0x0 + 226939632
15  ???                                 0x0d86d505 0x0 + 226940165
16  FanApp                              0x00010782 mono_jit_runtime_invoke + 722
17  FanApp                              0x00173c5e mono_runtime_invoke + 126
18  FanApp                              0x002169a6 monotouch_trampoline + 3686
19  FanApp                              0x00004864 -[ECSlidingViewController anchorTopViewTo:] + 84
20  ???                                 0x08618c4c 0x0 + 140610636
21  ???                                 0x06bfbd28 0x0 + 113229096
22  ???                                 0x08618bb0 0x0 + 140610480
23  FanApp                              0x00010782 mono_jit_runtime_invoke + 722
24  FanApp                              0x00173c5e mono_runtime_invoke + 126
25  FanApp                              0x002169a6 monotouch_trampoline + 3686
26  FanApp                              0x00004700 -[ECSlidingViewController updateTopViewHorizontalCenterWithRecognizer:] + 1680
27  UIKit                               0x00bede29 _UIGestureRecognizerSendActions + 143
28  UIKit                               0x00bed133 -[UIGestureRecognizer _updateGestureWithEvent:] + 379
29  UIKit                               0x00bee3bf -[UIGestureRecognizer _delayedUpdateGesture] + 46
30  UIKit                               0x00bf0a21 ___UIGestureRecognizerUpdate_block_invoke_0541 + 57
31  UIKit                               0x00bf097c _UIGestureRecognizerApplyBlocksToArray + 277
32  UIKit                               0x00be93d7 _UIGestureRecognizerUpdate + 1026
33  UIKit                               0x0094e1a2 -[UIWindow _sendGesturesForEvent:] + 1121
34  UIKit                               0x0094e532 -[UIWindow sendEvent:] + 93
35  UIKit                               0x00934dc4 -[UIApplication sendEvent:] + 464
36  UIKit                               0x00928634 _UIApplicationHandleEvent + 8196
37  GraphicsServices                    0x025f5ef5 PurpleEventCallback + 1274
38  CoreFoundation                      0x01c0f195 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
39  CoreFoundation                      0x01b73ff2 __CFRunLoopDoSource1 + 146
40  CoreFoundation                      0x01b728da __CFRunLoopRun + 2218
41  CoreFoundation                      0x01b71d84 CFRunLoopRunSpecific + 212
42  CoreFoundation                      0x01b71c9b CFRunLoopRunInMode + 123
43  GraphicsServices                    0x025f47d8 GSEventRunModal + 190
44  GraphicsServices                    0x025f488a GSEventRun + 103
45  UIKit                               0x00926626 UIApplicationMain + 1163
46  ???                                 0x0861397d 0x0 + 140589437
47  ???                                 0x085974f8 0x0 + 140080376
48  ???                                 0x08597100 0x0 + 140079360
49  ???                                 0x08597256 0x0 + 140079702
50  FanApp                              0x00010782 mono_jit_runtime_invoke + 722
51  FanApp                              0x00173c5e mono_runtime_invoke + 126
52  FanApp                              0x00177e54 mono_runtime_exec_main + 420
53  FanApp                              0x0017d245 mono_runtime_run_main + 725
54  FanApp                              0x0006de15 mono_jit_exec + 149
55  FanApp                              0x0020bc04 main + 1988
56  FanApp                              0x00009685 start + 53
57  ???                                 0x00000004 0x0 + 4

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

The weird part about this is that it only happens when I run the app in the iOS simulator. On devices, everything appears to work fine.

Anyone have any clue what's going on?

ETA: Crash Report:

Process:         FanApp [50509]
Path:            /Users/USER/Library/Application Support/iPhone Simulator/*/
Identifier:      FanApp
Version:         ???
Code Type:       X86 (Native)
Parent Process:  launchd [151]
User ID:         501

Date/Time:       2013-05-22 17:16:55.967 -0400
OS Version:      Mac OS X 10.8.3 (12D78)
Report Version:  10

Crashed Thread:  0

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000008

VM Regions Near 0x8:
    --> __PAGEZERO             0000000000000000-0000000000001000 [    4K] ---/--- SM=NUL  /Users/USER/Library/Application Support/iPhone Simulator/*/FanApp.app/FanApp
    __TEXT                 0000000000001000-00000000002cd000 [ 2864K] r-x/rwx SM=COW  /Users/USER/Library/Application Support/iPhone Simulator/*/FanApp.app/FanApp

Application Specific Information:
iPhone Simulator 369.2, iPhone OS 5.1 (iPhone/9B176)

abort() called

Thread 0 Crashed:
0   libsystem_kernel.dylib          0x94925a6a __pthread_kill + 10
1   libsystem_c.dylib               0x99bf7b2f pthread_kill + 101
2   libsystem_c.dylib               0x99c2e4ec abort + 168
3   FanApp                          0x00098d1a mono_handle_native_sigsegv + 858
4   FanApp                          0x0000c3b8 mono_sigsegv_signal_handler + 248
5   libsystem_c.dylib               0x99be28cb _sigtramp + 43
6   ???                             0xffffffff 0 + 4294967295
7   FanApp                          0x0000c2c0 mono_sigill_signal_handler + 64
8   FanApp                          0x00112aba GCHandle_CheckCurrentDomain + 26
9   ???                             0x0d86e766 0 + 226944870
10  ???                             0x0d86e668 0 + 226944616
11  ???                             0x0d86e590 0 + 226944400
12  ???                             0x0d86e4f8 0 + 226944248
13  ???                             0x0d86db7c 0 + 226941820
14  libsystem_sim_blocks.dylib      0x0243acb6 _Block_call_copy_helper + 29
15  libsystem_sim_blocks.dylib      0x0243b73f _Block_copy_internal + 228
16  FanApp                          0x00004a91 -[ECSlidingViewController anchorTopViewTo:animations:onComplete:] + 545
17  ???                             0x0d86e458 0 + 226944088
18  ???                             0x0d86d2f0 0 + 226939632
19  ???                             0x0d86d505 0 + 226940165
20  FanApp                          0x00010782 mono_jit_runtime_invoke + 722
21  FanApp                          0x00173c5e mono_runtime_invoke + 126
22  FanApp                          0x002169a6 monotouch_trampoline + 3686
23  FanApp                          0x00004864 -[ECSlidingViewController anchorTopViewTo:] + 84
24  ???                             0x08618c4c 0 + 140610636
25  ???                             0x06bfbd28 0 + 113229096
26  ???                             0x08618bb0 0 + 140610480
27  FanApp                          0x00010782 mono_jit_runtime_invoke + 722
28  FanApp                          0x00173c5e mono_runtime_invoke + 126
29  FanApp                          0x002169a6 monotouch_trampoline + 3686
30  FanApp                          0x00004700 -[ECSlidingViewController updateTopViewHorizontalCenterWithRecognizer:] + 1680
31  UIKit                           0x00bede29 _UIGestureRecognizerSendActions + 143
32  UIKit                           0x00bed133 -[UIGestureRecognizer _updateGestureWithEvent:] + 379
33  UIKit                           0x00bee3bf -[UIGestureRecognizer _delayedUpdateGesture] + 46
34  UIKit                           0x00bf0a21 ___UIGestureRecognizerUpdate_block_invoke_0541 + 57
35  UIKit                           0x00bf097c _UIGestureRecognizerApplyBlocksToArray + 277
36  UIKit                           0x00be93d7 _UIGestureRecognizerUpdate + 1026
37  UIKit                           0x0094e1a2 -[UIWindow _sendGesturesForEvent:] + 1121
38  UIKit                           0x0094e532 -[UIWindow sendEvent:] + 93
39  UIKit                           0x00934dc4 -[UIApplication sendEvent:] + 464
40  UIKit                           0x00928634 _UIApplicationHandleEvent + 8196
41  GraphicsServices                0x025f5ef5 PurpleEventCallback + 1274
42  CoreFoundation                  0x01c0f195 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
43  CoreFoundation                  0x01b73ff2 __CFRunLoopDoSource1 + 146
44  CoreFoundation                  0x01b728da __CFRunLoopRun + 2218
45  CoreFoundation                  0x01b71d84 CFRunLoopRunSpecific + 212
46  CoreFoundation                  0x01b71c9b CFRunLoopRunInMode + 123
47  GraphicsServices                0x025f47d8 GSEventRunModal + 190
48  GraphicsServices                0x025f488a GSEventRun + 103
49  UIKit                           0x00926626 UIApplicationMain + 1163
50  ???                             0x0861397d 0 + 140589437
51  ???                             0x085974f8 0 + 140080376
52  ???                             0x08597100 0 + 140079360
53  ???                             0x08597256 0 + 140079702
54  FanApp                          0x00010782 mono_jit_runtime_invoke + 722
55  FanApp                          0x00173c5e mono_runtime_invoke + 126
56  FanApp                          0x00177e54 mono_runtime_exec_main + 420
57  FanApp                          0x0017d245 mono_runtime_run_main + 725
58  FanApp                          0x0006de15 mono_jit_exec + 149
59  FanApp                          0x0020bc04 main + 1988
60  FanApp                          0x00009685 start + 53

Thread 1:
0   libsystem_kernel.dylib          0x949269ae kevent + 10
1   libdispatch.dylib               0x02474372 _dispatch_mgr_invoke + 918
2   libdispatch.dylib               0x02472be1 _dispatch_mgr_thread + 53

Thread 2:
0   libsystem_kernel.dylib          0x94925b3e __recvfrom + 10
1   libsystem_c.dylib               0x99c80bbf recv$UNIX2003 + 54
2   FanApp                          0x0020d021 recv_uninterrupted + 81
3   FanApp                          0x0020e88b monotouch_process_connection + 107
4   FanApp                          0x0020ddef monotouch_connect_wifi + 3279
5   FanApp                          0x0020cd07 monotouch_configure_debugging + 2311
6   FanApp                          0x0020bce5 -[CocoaThreadInitializer entryPoint:] + 133
7   Foundation                      0x005da4d6 -[NSThread main] + 76
8   Foundation                      0x005da447 __NSThread__main__ + 1258
9   libsystem_c.dylib               0x99bf65b7 _pthread_start + 344
10  libsystem_c.dylib               0x99be0d4e thread_start + 34

Thread 3:
0   libsystem_kernel.dylib          0x949237d2 mach_msg_trap + 10
1   libsystem_kernel.dylib          0x94922cb0 mach_msg + 68
2   FanApp                          0x000de03a mach_exception_thread + 90
3   FanApp                          0x0020816d GC_start_routine + 93
4   libsystem_c.dylib               0x99bf65b7 _pthread_start + 344
5   libsystem_c.dylib               0x99be0d4e thread_start + 34

Thread 4:
0   libsystem_kernel.dylib          0x9492380e semaphore_wait_trap + 10
1   FanApp                          0x001e91ea mono_sem_wait + 26
2   FanApp                          0x00112d2a finalizer_thread + 74
3   FanApp                          0x001aeca6 start_wrapper + 422
4   FanApp                          0x001e0c6a thread_start_routine + 154
5   FanApp                          0x0020816d GC_start_routine + 93
6   libsystem_c.dylib               0x99bf65b7 _pthread_start + 344
7   libsystem_c.dylib               0x99be0d4e thread_start + 34

Thread 5:
0   libsystem_kernel.dylib          0x94925b3e __recvfrom + 10
1   libsystem_c.dylib               0x99c80bbf recv$UNIX2003 + 54
2   FanApp                          0x0020d021 recv_uninterrupted + 81
3   FanApp                          0x0020d104 sdb_recv + 52
4   FanApp                          0x000af49a debugger_thread + 186
5   FanApp                          0x001e0c6a thread_start_routine + 154
6   FanApp                          0x0020816d GC_start_routine + 93
7   libsystem_c.dylib               0x99bf65b7 _pthread_start + 344
8   libsystem_c.dylib               0x99be0d4e thread_start + 34

Thread 6:
0   libsystem_kernel.dylib          0x94925c72 __semwait_signal + 10
1   libsystem_c.dylib               0x99c80a55 nanosleep$UNIX2003 + 189
2   libsystem_c.dylib               0x99c8091e usleep$UNIX2003 + 60
3   FanApp                          0x00211342 monotouch_pump_gc + 50
4   libsystem_c.dylib               0x99bf65b7 _pthread_start + 344
5   libsystem_c.dylib               0x99be0d4e thread_start + 34

Thread 7:: WebThread
0   libsystem_kernel.dylib          0x949237d2 mach_msg_trap + 10
1   libsystem_kernel.dylib          0x94922cb0 mach_msg + 68
2   CoreFoundation                  0x01c0f10a __CFRunLoopServiceMachPort + 186
3   CoreFoundation                  0x01b725d5 __CFRunLoopRun + 1445
4   CoreFoundation                  0x01b71d84 CFRunLoopRunSpecific + 212
5   CoreFoundation                  0x01b71c9b CFRunLoopRunInMode + 123
6   WebCore                         0x03933420 RunWebThread(void*) + 560
7   libsystem_c.dylib               0x99bf65b7 _pthread_start + 344
8   libsystem_c.dylib               0x99be0d4e thread_start + 34

Thread 0 crashed with X86 Thread State (32-bit):
  eax: 0x00000000  ebx: 0x07ad42e8  ecx: 0xbfffbc2c  edx: 0x94925a6a
  edi: 0xacd18a28  esi: 0x00000006  ebp: 0xbfffbc48  esp: 0xbfffbc2c
   ss: 0x00000023  efl: 0x00000206  eip: 0x94925a6a   cs: 0x0000000b
   ds: 0x00000023   es: 0x00000023   fs: 0x00000000   gs: 0x0000000f
  cr2: 0x010cd88c
Logical CPU: 0

Binary Images:
// Omitted to get under character limit

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 20396
    thread_create: 0
    thread_set_state: 66

VM Region Summary:
ReadOnly portion of Libraries: Total=131.8M resident=44.7M(34%) swapped_out_or_unallocated=87.1M(66%)
Writable regions: Total=60.1M written=3060K(5%) resident=9756K(16%) swapped_out=0K(0%) unallocated=50.6M(84%)

REGION TYPE                      VIRTUAL
===========                      =======
CG image                             16K
CoreAnimation                       328K
MALLOC                             41.7M
MALLOC guard page                    32K
Memory tag=35                      9900K
Stack                              68.8M
VM_ALLOCATE                        2456K
__DATA                             8484K
__LINKEDIT                         50.5M
__OBJC                                4K
__PAGEZERO                            4K
__TEXT                             81.3M
__UNICODE                           544K
mapped file                       237.1M
shared memory                        12K
===========                      =======
TOTAL                             500.7M
ios
xamarin.ios
xamarin
asked on Stack Overflow May 22, 2013 by user2410983

2 Answers

1

It looks like a problem with marshaling an Objective-C block to a managed delegate in ECSlidingViewController.AnchorTopView.

We do not currently support marshaling Objective-C blocks (that didn't originate from a managed delegate in the first place), you'll end up with a crash just like this one.

If you do not need to override ECSlidingViewController.AnchorTopView, you can just type the block as an IntPtr in the binding, so it would be something like this (note that I'm just guessing about how you did your binding):

interface ECSlidingViewController {
    void AnchorTopView (ECSide first, ECAnimations second, IntPtr block);
}

If you're interested here is someone with a similar problem (and this forum thread contains a bit more explanation).

answered on Stack Overflow May 22, 2013 by Rolf Bjarne Kvinge
0

"Got a SIGSEGV while executing native code" may be indicate that some Actions assigned to UI elements in InterfaceBuilder are not found when app is executing. Verify all IBActions connected with your UIElements (UIButtons, GesturesRecognizers, etc.). Clear it and reassign to correct IBAction in .h files. Pay attention specially in duplicate Views.

IBAction connected with Interface Builder

answered on Stack Overflow Jul 3, 2013 by orafaelreis

User contributions licensed under CC BY-SA 3.0