3

我们的 iPad 应用程序“MyApp”从现场收到了多份无法重现的崩溃报告,每天约有 3000 名用户。原因:“无法识别的选择器发送到实例” 受影响的设备:仅 iPad 1。

崩溃报告是指[__NSCFDictionary buttonPressed:]whilebuttonPressed:是 UIButton 的操作。显然,在崩溃情况下,按钮还没有准备好接收消息。相反,消息被分派到内存中的某个其他实例(在大多数情况下是字典)。

该操作buttonPressed:通过一个 xib 文件附加到按钮上(还有一种情况,即该操作以编程方式附加到图像视图)。buttonPressed:是当应用程序被带到前面时用户可能首先触发的操作。我怀疑在这些情况下,应用程序没有完全初始化(回到前面)并且无法恢复。

我的怀疑是基于符号(总是与这些崩溃一起发生):(_resourceLoadLoop在主线程中执行?)和_dispatch_mgr_wakeup.

你有什么意见?您是否与 iPad 1 客户有过类似的经历?有已知的错误吗?

以下是典型崩溃堆栈的内容:

Hardware Model:      iPad1,1
Code Type:       ARM
Parent Process:  launchd [1]

Date/Time:       2012-12-04 06:35:48 +0000
OS Version:      iPhone OS 5.1.1 (9B206)
Report Version:  104

Exception Type:  SIGABRT
Exception Codes: #0 at 0x35a2f32c
Crashed Thread:  0

Application Specific Information:
*** Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'-[__NSCFDictionary buttonPressed:]: unrecognized selector sent to instance 0x40eaa0\'

Last Exception Backtrace:
0   CoreFoundation                      0x359b988f __exceptionPreprocess + 163
1   libobjc.A.dylib                     0x335dd259 objc_exception_throw + 33
2   CoreFoundation                      0x359bca9b -[NSObject doesNotRecognizeSelector:] + 175
3   CoreFoundation                      0x359bb915 ___forwarding___ + 301
4   CoreFoundation                      0x35916650 _CF_forwarding_prep_0 + 48
5   CoreFoundation                      0x359133fd -[NSObject performSelector:withObject:withObject:] + 53
6   UIKit                               0x330d4e07 -[UIApplication sendAction:to:from:forEvent:] + 63
7   UIKit                               0x330d4dc3 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 31
8   UIKit                               0x330d4da1 -[UIControl sendAction:to:forEvent:] + 45
9   UIKit                               0x330d4b11 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 493
10  UIKit                               0x330d5449 -[UIControl touchesEnded:withEvent:] + 477
11  UIKit                               0x330d392b -[UIWindow _sendTouchesForEvent:] + 319
12  UIKit                               0x330d3319 -[UIWindow sendEvent:] + 381
13  UIKit                               0x330b9695 -[UIApplication sendEvent:] + 357
14  UIKit                               0x330b8f3b _UIApplicationHandleEvent + 5827
15  GraphicsServices                    0x336ab22b PurpleEventCallback + 883
16  CoreFoundation                      0x3598d523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 39
17  CoreFoundation                      0x3598d4c5 __CFRunLoopDoSource1 + 141
18  CoreFoundation                      0x3598c313 __CFRunLoopRun + 1371
19  CoreFoundation                      0x3590f4a5 CFRunLoopRunSpecific + 301
20  CoreFoundation                      0x3590f36d CFRunLoopRunInMode + 105
21  GraphicsServices                    0x336aa439 GSEventRunModal + 137
22  UIKit                               0x330e7cd5 UIApplicationMain + 1081
23  MyApp                               0x0002411b main (main.m:14)
24  MyApp                               0x000240c0 start + 40


Thread 0 Crashed:
0   libsystem_kernel.dylib              0x35a2f32c __pthread_kill + 8
1   libsystem_c.dylib                   0x34c1029f abort + 95
2   MyApp                               0x0012d595 +[PLCrashReporter sharedReporter] + 1
3   CoreFoundation                      0x359b9957 __handleUncaughtException + 75
4   libobjc.A.dylib                     0x335dd345 _objc_terminate + 129
5   libc++abi.dylib                     0x352253c5 safe_handler_caller(void (*)()) + 77
6   libc++abi.dylib                     0x35225451 operator delete(void*) + 1
7   libc++abi.dylib                     0x35226825 __cxa_current_exception_type + 1
8   libobjc.A.dylib                     0x335dd2a9 objc_exception_rethrow + 13
9   CoreFoundation                      0x3590f50d CFRunLoopRunSpecific + 405
10  CoreFoundation                      0x3590f36d CFRunLoopRunInMode + 105
11  GraphicsServices                    0x336aa439 GSEventRunModal + 137
12  UIKit                               0x330e7cd5 UIApplicationMain + 1081
13  MyApp                               0x0002411b main (main.m:14)

Thread 1:
0   libsystem_kernel.dylib              0x35a1f3a8 kevent + 24
1   libdispatch.dylib                   0x33d52bc9 _dispatch_mgr_wakeup + 1

Thread 2:
0   libsystem_kernel.dylib              0x35a1f004 mach_msg_trap + 20
1   CoreFoundation                      0x3598d3f3 __CFRunLoopServiceMachPort + 127
2   CoreFoundation                      0x3598c12b __CFRunLoopRun + 883
3   CoreFoundation                      0x3590f4a5 CFRunLoopRunSpecific + 301
4   CoreFoundation                      0x3590f36d CFRunLoopRunInMode + 105
5   WebCore                             0x37655ca3 RunWebThread(void*) + 403
6   libsystem_c.dylib                   0x34bd8735 _pthread_start + 321

Thread 3:
0   libsystem_kernel.dylib              0x35a1f004 mach_msg_trap + 20
1   CoreFoundation                      0x3598d3f3 __CFRunLoopServiceMachPort + 127
2   CoreFoundation                      0x3598c12b __CFRunLoopRun + 883
3   CoreFoundation                      0x3590f4a5 CFRunLoopRunSpecific + 301
4   CoreFoundation                      0x3590f36d CFRunLoopRunInMode + 105
5   Foundation                          0x34d54bb9 +[NSURLConnection(Loader) _resourceLoadLoop:] + 309
6   Foundation                          0x34d54a81 -[NSThread main] + 73
7   Foundation                          0x34de8591 __NSThread__main__ + 1049
8   libsystem_c.dylib                   0x34bd8735 _pthread_start + 321

Thread 4:
0   libsystem_kernel.dylib              0x35a2f570 __select + 20
1   libsystem_c.dylib                   0x34bd8735 _pthread_start + 321

Thread 5:
0   libsystem_kernel.dylib              0x35a2fcd4 __workq_kernreturn + 8

Thread 6:
0   libsystem_kernel.dylib              0x35a2fcd4 __workq_kernreturn + 8

Thread 0 crashed with ARM Thread State:
    r0: 0x00000000     r1: 0x00000000     r2: 0x00000001     r3: 0x00000000 
    r4: 0x00000006     r5: 0x3f2dbd98     r6: 0x00000002     r7: 0x2fe20a38 
    r8: 0x00469e00     r9: 0x00000000    r10: 0x00000000    r11: 0x0040eaa0 
    ip: 0x00000148     sp: 0x2fe20a2c     lr: 0x34c1720f     pc: 0x35a2f32c 
  cpsr: 0x00080010 

Binary Images:
   0x22000 -   0x288fff +MyApp armv7  <1f677ffc81aa3ccf958c65a92cce8418> /var/mobile/Applications/1D49C89A-36EA-43FC-BE76-7B770E36491B/MyApp.app/MyApp
0x3049d000 - 0x30550fff  iTunesStore armv7  <b3c0cce5f8e632e18f841c32b68f57a1> /System/Library/PrivateFrameworks/iTunesStore.framework/iTunesStore
0x30555000 - 0x305d8fff  MapKit armv7  <e39706ac199134a497954e1f1d6d7245> /System/Library/Frameworks/MapKit.framework/MapKit
0x305d9000 - 0x305dffff  liblaunch.dylib armv7  <aa2bcba6fc7a36a191958fef2e995475> /usr/lib/system/liblaunch.dylib
0x306dd000 - 0x306f1fff  PersistentConnection armv7  <54091a638f8731cd85ccf00fa06972c3> /System/Library/PrivateFrameworks/PersistentConnection.framework/PersistentConnection
0x30745000 - 0x30824fff  RawCamera armv7  <293f818ba6533dceae8b900b6ed3c887> /System/Library/CoreServices/RawCamera.bundle/RawCamera
0x30825000 - 0x30882fff  StoreServices armv7  <6ce256d3cf433e4aa1af8d696bf1f75d> /System/Library/PrivateFrameworks/StoreServices.framework/StoreServices
0x30883000 - 0x308cffff  CoreTelephony armv7  <b8f80d5d594c31d2b5d8fba9fdedb7e1> /System/Library/Frameworks/CoreTelephony.framework/CoreTelephony
0x308f1000 - 0x30929fff  VideoToolbox armv7  <9f25f38d1cd13a1daff99cfde8884410> /System/Library/PrivateFrameworks/VideoToolbox.framework/VideoToolbox
0x3092a000 - 0x30956fff  libtidy.A.dylib armv7  <3aacc5b650e037c086a8ff6657d154bf> /usr/lib/libtidy.A.dylib
0x30ef1000 - 0x30f42fff  CoreText armv7  <5bfac4ee88d03d5b87a1f105abb7756c> /System/Library/Frameworks/CoreText.framework/CoreText
0x30f43000 - 0x30f47fff  CertUI armv7  <f503892ef60e36108d28d8f9d6144d2a> /System/Library/PrivateFrameworks/CertUI.framework/CertUI
0x30fb3000 - 0x30fb3fff  liblangid.dylib armv7  <644ff4bcfbf337b5b5859e3f0fc0a9a8> /usr/lib/liblangid.dylib
0x30fb4000 - 0x30fcafff  EAP8021X armv7  <952fcfdec0633aff923768fca1a26fcb> /System/Library/PrivateFrameworks/EAP8021X.framework/EAP8021X
0x30fcb000 - 0x30fe0fff  libresolv.9.dylib armv7  <66f7557fa4b43979b186e00271839fdb> /usr/lib/libresolv.9.dylib
0x3129d000 - 0x312bafff  libsystem_info.dylib armv7  <50863bcbf478323e96a8e5b1a83ea6f9> /usr/lib/system/libsystem_info.dylib
0x312c0000 - 0x31433fff  MediaPlayer armv7  <63cdf8f9c66d36e7a4e69e2f6cae854f> /System/Library/Frameworks/MediaPlayer.framework/MediaPlayer
0x315ea000 - 0x315eafff  vecLib armv7  <a2cfe25e77aa36bfb4a30b2d0d2dd465> 
[...]
4

2 回答 2

0

与其过早激活,不如说实现的控制器可能buttonPressed:已被释放,并且它的内存重新用于另一个对象。如果它仅限于某些设备,则可能是由于内存警告......以及已从 iOS 6 中删除的视图卸载。

于 2012-12-05T12:24:32.610 回答
0

将消息发送到完全不正确的对象的“无法识别的选择器”异常通常是由双重释放错误引起的。这意味着您的视图控制器(或任何具有该buttonPressed:方法的)已被释放,并且它的内存被另一个对象(在本例中为字典)回收。

您应该检查您的内存管理代码。如果您还没有,我强烈建议您转换为 ARC。这向后兼容 iOS 4(如果您不使用弱引用),通常会为您解决这些问题。

为了帮助调试,您可以通过编辑方案诊断设置来启用僵尸检测。您还可以使用 Instruments 中的“僵尸”乐器。这两种技术都可以帮助确认您是否有双重释放问题。

于 2012-12-05T12:26:52.797 回答