【问题标题】:App Crashes without going through my code应用程序崩溃而不通过我的代码
【发布时间】:2012-05-07 14:31:31
【问题描述】:

在分析我们的崩溃日志时,我发现一个相当常见的崩溃是在我自己的课程中甚至没有发生的。这些是外部崩溃日志,因此我无法重现该问题。

由于我无法调试我想知道的框架,解决此问题的可行方法是什么。

我唯一的线索是 SIGSEGV 可能是分段错误或无效指针。但就像我说的,因为我的课程似乎没有直接参与,这对我没有多大帮助。

崩溃:

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x6b636f6c
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x365c7f94 objc_msgSend + 43
1   CoreFoundation                      0x31cd23fd -[NSObject performSelector:withObject:withObject:] + 52
2   UIKit                               0x3291cfaf -[UIApplication sendAction:to:from:forEvent:] + 62
3   UIKit                               0x3291cf6b -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
4   UIKit                               0x3291cf49 -[UIControl sendAction:to:forEvent:] + 44
5   UIKit                               0x3291ccb9 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 492
6   UIKit                               0x3291d5f1 -[UIControl touchesEnded:withEvent:] + 476
7   UIKit                               0x3291bad3 -[UIWindow _sendTouchesForEvent:] + 318
8   UIKit                               0x3291b4c1 -[UIWindow sendEvent:] + 380
9   UIKit                               0x3290183d -[UIApplication sendEvent:] + 356
10  UIKit                               0x329010e3 _UIApplicationHandleEvent + 5826
11  GraphicsServices                    0x3572d22b PurpleEventCallback + 882
12  CoreFoundation                      0x31d4c523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
13  CoreFoundation                      0x31d4c4c5 __CFRunLoopDoSource1 + 140
14  CoreFoundation                      0x31d4b313 __CFRunLoopRun + 1370
15  CoreFoundation                      0x31cce4a5 CFRunLoopRunSpecific + 300
16  CoreFoundation                      0x31cce36d CFRunLoopRunInMode + 104
17  GraphicsServices                    0x3572c439 GSEventRunModal + 136
18  UIKit                               0x3292fe7d UIApplicationMain + 1080
19  MyApp                               0x0000321f main (main.m:14)

【问题讨论】:

  • 也许是一些静态构造函数?静态块在主应用程序之前执行(至少在 C++ 中,但我确实怀疑 Objective C 没有什么不同)
  • 似乎 UIControl/UIButton 的目标设置为按下按钮时不再存在的对象。
  • 您的问题解决了吗?问题的原因是什么?
  • @foogry 这是两年多以前的事了,所以我不知道确切的问题是什么,但我接受了下面的答案,所以这可能会给你一个提示。

标签: objective-c ios crash uikit segmentation-fault


【解决方案1】:

此崩溃可能是您的错误造成的。如果您查看堆栈跟踪顶部的几行,它应该会提示您出了什么问题。

1   CoreFoundation   0x31cd23fd -[NSObject performSelector:withObject:withObject:] + 52
2   UIKit            0x3291cfaf -[UIApplication sendAction:to:from:forEvent:] + 62
3   UIKit            0x3291cf6b -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
4   UIKit            0x3291cf49 -[UIControl sendAction:to:forEvent:] + 44

看起来你有一个对象(可能是一个视图控制器)为事件注册但过早地被释放。最好的办法是在连接到调试器时尝试重现它。首先检查处理 UIControl 回调的代码,例如 UIButtons。

【讨论】:

  • 我不太清楚您所说的“UIControl 回调,例如 UIButtons”是什么意思
  • UIControls 通常通过处理用户输入然后回调您的代码来工作。因此,按下时UIButton 将回调您的方法(如果使用 IB,则为 IBAction,例如 -(IBAction)buttonPressed:(id)sender)。如果包含buttonPressed: 的类在事件触发之前被释放,那么这将导致您的应用程序崩溃。 UISwitchUISlider 等也是如此。
  • 我在 ApplicationDidFinishLaunching 方法中展示了一个视图控制器,但它没有被保留。这解决了我的问题,谢谢!!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-25
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多