部署MonoTouch致命崩溃

时间:2012-03-13 13:40:20

标签: xamarin.ios

我发现,一旦我为iPhone 4s部署了一个解决方案,导致应用程序崩溃而不会在MonoTouch中引发任何错误,我就会收到错误。我正在处理UIApplication.Main并写入错误日志中的任何异常,并且没有任何异常。

我已将其跟踪到我已部署到iPad的一行代码而没有此问题,该行在AppDelegate类中:

[DllImport(MonoTouch.Constants.SystemLibrary)]  
    internal static extern int sysctlbyname( [MarshalAs(UnmanagedType.LPStr)] string property, IntPtr output, IntPtr oldLen, IntPtr newp, uint newlen);  

它崩溃了应用程序,但仍然在任务列表中,而不是强行关闭整个应用程序。

设备登录崩溃是:

Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>: Native stacktrace:
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     0   RWMAppStore                         0x004917b4 RWMAppStore + 4786100
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     1   RWMAppStore                         0x0047bde0 RWMAppStore + 4697568
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     2   libsystem_c.dylib                   0x3620e539 _sigtramp + 48
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     3   RWMAppStore                         0x004dd98c RWMAppStore + 5097868
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     4   RWMAppStore                         0x004dd98c RWMAppStore + 5097868
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     5   RWMAppStore                         0x00574a84 RWMAppStore + 5716612
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     6   RWMAppStore                         0x004bdb40 RWMAppStore + 4967232
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     7   RWMAppStore                         0x004de134 RWMAppStore + 5099828
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     8   RWMAppStore                         0x005483a0 RWMAppStore + 5534624
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     9   RWMAppStore                         0x00560764 RWMAppStore + 5633892
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     10  RWMAppStore                         0x0057b034 RWMAppStore + 5742644
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     11  libsystem_c.dylib                   0x361c5c1d _pthread_start + 320
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>:     12  libsystem_c.dylib                   0x361c5ad8 thread_start + 8
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>: =================================================================
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>: Got a SIGSEGV while executing native code. This usually indicates
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>: a fatal error in the mono runtime or one of the native libraries 
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>: used by your application.
Mar 13 14:35:18 unknown UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5][5456] <Notice>: =================================================================
Mar 13 14:35:19 unknown ReportCrash[5458] <Notice>: Formulating crash report for process RWMAppStore[5456]
Mar 13 14:35:19 unknown com.apple.launchd[1] <Warning>: (UIKitApplication:come.redware-mobile.iphoneappstore[0x91f5]) Job appears to have crashed: Abort trap: 6
Mar 13 14:35:19 unknown SpringBoard[15] <Warning>: Application 'App Store Front' exited abnormally with signal 6: Abort trap: 6

崩溃报告是:

    Incident Identifier: 49661917-C8E0-4FBB-9E21-1B9443B3443A
CrashReporter Key:   521c0afd53359e09a1e4eaae6ed1eda8500c4ebb
Hardware Model:      iPhone4,1
Process:         RWMAppStore [6537]
Path:            /var/mobile/Applications/A2345805-B9C2-412E-BCEA-0A45D7CC7358/RWMAppStore.app/RWMAppStore
Identifier:      RWMAppStore
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-03-14 13:53:06.552 +0000
OS Version:      iPhone OS 5.0.1 (9A405)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000011d
Crashed Thread:  9

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x33627010 0x33626000 + 4112
1   libsystem_kernel.dylib          0x33627206 0x33626000 + 4614
2   CoreFoundation                  0x37d7141c 0x37ce4000 + 578588
3   CoreFoundation                  0x37d7011a 0x37ce4000 + 573722
4   CoreFoundation                  0x37cf34d6 0x37ce4000 + 62678
5   CoreFoundation                  0x37cf339e 0x37ce4000 + 62366
6   GraphicsServices                0x37871fc6 0x3786e000 + 16326
7   UIKit                           0x3518373c 0x35152000 + 202556
8   RWMAppStore                     0x0023adf8 wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr (monotouch.dll.6.s:33721)
9   RWMAppStore                     0x00100b04 RWMAppStore_Application_Main_string__ (RWMAppStore.exe.6.s:21)
10  RWMAppStore                     0x003d0d20 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr (mscorlib.dll.6.s:160144)
11  RWMAppStore                     0x0047ddf8 mono_jit_runtime_invoke (mini.c:5786)
12  RWMAppStore                     0x00525224 mono_runtime_invoke (object.c:2757)
13  RWMAppStore                     0x005294d0 mono_runtime_exec_main (object.c:3932)
14  RWMAppStore                     0x0052e144 mono_runtime_run_main (object.c:3562)
15  RWMAppStore                     0x00482180 mono_jit_exec (driver.c:1112)
16  RWMAppStore                     0x0047a3e4 main (main.m:1702)
17  RWMAppStore                     0x00002730 0x1000 + 5936

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x336273b4 0x33626000 + 5044
1   libdispatch.dylib               0x37a5bf74 0x37a58000 + 16244
2   libdispatch.dylib               0x37a5bc92 0x37a58000 + 15506

Thread 2:
0   libsystem_kernel.dylib          0x33637cd4 0x33626000 + 72916
1   libsystem_c.dylib               0x361c030a 0x361b6000 + 41738
2   libsystem_c.dylib               0x361c009c 0x361b6000 + 41116

Thread 3:
0   libsystem_kernel.dylib          0x33637cd4 0x33626000 + 72916
1   libsystem_c.dylib               0x361c030a 0x361b6000 + 41738
2   libsystem_c.dylib               0x361c009c 0x361b6000 + 41116

Thread 4 name:  WebThread
Thread 4:
0   libsystem_kernel.dylib          0x33627010 0x33626000 + 4112
1   libsystem_kernel.dylib          0x33627206 0x33626000 + 4614
2   CoreFoundation                  0x37d7141c 0x37ce4000 + 578588
3   CoreFoundation                  0x37d70154 0x37ce4000 + 573780
4   CoreFoundation                  0x37cf34d6 0x37ce4000 + 62678
5   CoreFoundation                  0x37cf339e 0x37ce4000 + 62366
6   WebCore                         0x325c4128 0x3251c000 + 688424
7   libsystem_c.dylib               0x361c5c16 0x361b6000 + 64534
8   libsystem_c.dylib               0x361c5ad0 0x361b6000 + 64208

Thread 5:
0   libsystem_kernel.dylib          0x33637628 0x33626000 + 71208
1   libsystem_c.dylib               0x361c9ff2 0x361b6000 + 81906
2   RWMAppStore                     0x0055f8f8 SleepEx (wthreads.c:1027)
3   RWMAppStore                     0x0053f494 monitor_thread (threadpool.c:781)
4   RWMAppStore                     0x00548398 start_wrapper (threads.c:784)
5   RWMAppStore                     0x0056075c thread_start_routine (wthreads.c:287)
6   RWMAppStore                     0x0057b02c GC_start_routine (pthread_support.c:1468)
7   libsystem_c.dylib               0x361c5c16 0x361b6000 + 64534
8   libsystem_c.dylib               0x361c5ad0 0x361b6000 + 64208

Thread 6:
0   libsystem_kernel.dylib          0x33627078 0x33626000 + 4216
1   RWMAppStore                     0x0056708c mono_sem_timedwait (mono-semaphore.c:76)
2   RWMAppStore                     0x005421a8 async_invoke_thread (threadpool.c:1497)
3   RWMAppStore                     0x00548398 start_wrapper (threads.c:784)
4   RWMAppStore                     0x0056075c thread_start_routine (wthreads.c:287)
5   RWMAppStore                     0x0057b02c GC_start_routine (pthread_support.c:1468)
6   libsystem_c.dylib               0x361c5c16 0x361b6000 + 64534
7   libsystem_c.dylib               0x361c5ad0 0x361b6000 + 64208

Thread 7:
0   libsystem_kernel.dylib          0x336273b4 0x33626000 + 5044
1   RWMAppStore                     0x005404dc tp_kqueue_wait (tpool-kqueue.c:98)
2   RWMAppStore                     0x00548398 start_wrapper (threads.c:784)
3   RWMAppStore                     0x0056075c thread_start_routine (wthreads.c:287)
4   RWMAppStore                     0x0057b02c GC_start_routine (pthread_support.c:1468)
5   libsystem_c.dylib               0x361c5c16 0x361b6000 + 64534
6   libsystem_c.dylib               0x361c5ad0 0x361b6000 + 64208

Thread 8:
0   libsystem_kernel.dylib          0x33627078 0x33626000 + 4216
1   RWMAppStore                     0x0056708c mono_sem_timedwait (mono-semaphore.c:76)
2   RWMAppStore                     0x005421a8 async_invoke_thread (threadpool.c:1497)
3   RWMAppStore                     0x00548398 start_wrapper (threads.c:784)
4   RWMAppStore                     0x0056075c thread_start_routine (wthreads.c:287)
5   RWMAppStore                     0x0057b02c GC_start_routine (pthread_support.c:1468)
6   libsystem_c.dylib               0x361c5c16 0x361b6000 + 64534
7   libsystem_c.dylib               0x361c5ad0 0x361b6000 + 64208

Thread 9 Crashed:
0   libsystem_kernel.dylib          0x3363732c 0x33626000 + 70444
1   libsystem_c.dylib               0x36203f54 0x361b6000 + 319316
2   libsystem_c.dylib               0x361fcfe4 0x361b6000 + 290788
3   RWMAppStore                     0x00491980 mono_handle_native_sigsegv (mini-exceptions.c:2255)
4   RWMAppStore                     0x0047bdd8 mono_sigsegv_signal_handler (mini.c:5923)
5   libsystem_c.dylib               0x3620e532 0x361b6000 + 361778
6   RWMAppStore                     0x004dd984 mono_gc_run_finalize (gc.c:113)
7   RWMAppStore                     0x004dd984 mono_gc_run_finalize (gc.c:113)
8   RWMAppStore                     0x00574a7c GC_invoke_finalizers (finalize.c:787)
9   RWMAppStore                     0x004bdb38 mono_gc_invoke_finalizers (boehm-gc.c:549)
10  RWMAppStore                     0x004de12c finalizer_thread (gc.c:1055)
11  RWMAppStore                     0x00548398 start_wrapper (threads.c:784)
12  RWMAppStore                     0x0056075c thread_start_routine (wthreads.c:287)
13  RWMAppStore                     0x0057b02c GC_start_routine (pthread_support.c:1468)
14  libsystem_c.dylib               0x361c5c16 0x361b6000 + 64534
15  libsystem_c.dylib               0x361c5ad0 0x361b6000 + 64208

Thread 9 crashed with ARM Thread State:
    r0: 0x00000000    r1: 0x00000000      r2: 0x00000001      r3: 0x00000000
    r4: 0x00000006    r5: 0x073f6000      r6: 0x00000000      r7: 0x073f5464
    r8: 0x3f1eb060    r9: 0x00000000     r10: 0x001068ca     r11: 0x01b40234
    ip: 0x00000148    sp: 0x073f5458      lr: 0x36203f5b      pc: 0x3363732c
  cpsr: 0x00000010

1 个答案:

答案 0 :(得分:1)

看起来堆已经以某种方式损坏了。我在您使用的代码中找不到任何错误,但也许您可以尝试更改此行:

var pStr = Marshal.AllocHGlobal(length);

var pStr = Marshal.AllocHGlobal(length * 2);

看看是否能解决问题。

我可能很快就可以在iPhone上测试它了。

<强>更新

我在iPhone4上试过这个,但它并没有崩溃。这意味着你的应用程序中可能会有几个不同的东西组合起来创建这个崩溃,修复/找到它的最好方法是在http://bugzilla.xamarin.com提交错误并附加你的项目(你可以标记bug如果您的项目是封闭的源代码,那么只有Xamarin员工才能看到它。