【问题标题】:Debugging a SIGSEGV crash [closed]调试 SIGSEGV 崩溃 [关闭]
【发布时间】:2012-10-20 03:38:39
【问题描述】:

用户一直在报告我很难重现的 SIGSEGV 崩溃 - 这对他们来说相对经常发生,但我从未能够重现它。通过阅读其他 StackOverflow 帖子,我知道我应该打开 NSZombies 来查找僵尸对象,但无论我在 Instruments 中做什么,我都无法让任何僵尸出现。

请注意,我使用的是 ARC。

谁能从这两个崩溃报告中找出任何意义,这样我至少知道从哪里开始寻找僵尸?有没有人有关于如何让僵尸出现在 Instruments 中的任何提示?谢谢!

崩溃报告 #1:

0 MyApp 0x000e4972 testflight_backtrace + 238
1 MyApp 0x000e565c TFSignalHandler + 264
2 libsystem_c.dylib 0x31cd37ec _sigtramp + 48
3 UIKit 0x33e47bde -[UIViewController unloadViewForced:] + 250
4 UIKit 0x33f8f498 -[UIViewController purgeMemoryForReason:] + 64
5 Foundation 0x37f264fe __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 18
6 CoreFoundation 0x376c8546 ___CFXNotificationPost_block_invoke_0 + 70
7 CoreFoundation 0x37654096 _CFXNotificationPost + 1406
8 Foundation 0x37e9a3ea -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
9 Foundation 0x37e9bc1a -[NSNotificationCenter postNotificationName:object:] + 30
10 UIKit 0x33f5a270 -[UIApplication _performMemoryWarning] + 80
11 UIKit 0x33f5a36a -[UIApplication _receivedMemoryNotification] + 174
12 libdispatch.dylib 0x349572e0 _dispatch_source_invoke + 516
13 libdispatch.dylib 0x34954b80 _dispatch_queue_invoke$VARIANT$mp + 52
14 libdispatch.dylib 0x34954ec0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 156
15 CoreFoundation 0x376cf2ac __CFRunLoopRun + 1268
16 CoreFoundation 0x376524a4 CFRunLoopRunSpecific + 300
17 CoreFoundation 0x3765236c CFRunLoopRunInMode + 104
18 GraphicsServices 0x3255f438 GSEventRunModal + 136
19 UIKit 0x33dd6e7c UIApplicationMain + 1080
20 MyApp 0x0001b65e main (main.m:16)
21 MyApp 0x000115af start + 39

崩溃报告 #2:

0 MyApp 0x0018e972 testflight_backtrace + 238
1 MyApp 0x0018f65c TFSignalHandler + 264
2 libsystem_c.dylib 0x31d067ec _sigtramp + 48
3 UIKit 0x33e7abde -[UIViewController unloadViewForced:] + 250
4 UIKit 0x33fc2498 -[UIViewController purgeMemoryForReason:] + 64
5 MyApp 0x000ec988 -[MyTableController didReceiveMemoryWarning] (MyTableController.m:129)
6 MyApp 0x0010a8a8 -[FeaturedViewController didReceiveMemoryWarning] (FeaturedViewController.m:65)
7 Foundation 0x37f594fe __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 18
8 CoreFoundation 0x376fb546 ___CFXNotificationPost_block_invoke_0 + 70
9 CoreFoundation 0x37687096 _CFXNotificationPost + 1406
10 Foundation 0x37ecd3ea -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
11 Foundation 0x37ecec1a -[NSNotificationCenter postNotificationName:object:] + 30
12 UIKit 0x33f8d270 -[UIApplication _performMemoryWarning] + 80
13 UIKit 0x33f8d36a -[UIApplication _receivedMemoryNotification] + 174
14 libdispatch.dylib 0x3498a2e0 _dispatch_source_invoke + 516
15 libdispatch.dylib 0x34987b80 _dispatch_queue_invoke$VARIANT$mp + 52
16 libdispatch.dylib 0x34987ec0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 156
17 CoreFoundation 0x377022ac __CFRunLoopRun + 1268
18 CoreFoundation 0x376854a4 CFRunLoopRunSpecific + 300
19 CoreFoundation 0x3768536c CFRunLoopRunInMode + 104
20 GraphicsServices 0x32592438 GSEventRunModal + 136
21 UIKit 0x33e09e7c UIApplicationMain + 1080
22 MyApp 0x000c565e main (main.m:16)
23 MyApp 0x000bb5af start + 39

【问题讨论】:

  • 仅从回溯中几乎无法分辨。分段违规的根本原因可能是完全不相关的代码。它双重释放一个指针或覆盖一个缓冲区,这会留下一个定时炸弹,一段时间后就会爆炸。即使它在代码中,在堆栈跟踪中,如果不查看源代码,我们也无法判断它可能是什么。
  • 这就是我害怕的。不幸的是,我的应用程序有成千上万行代码。关于如何强制它显示在我的一台设备或模拟器中的任何想法?
  • 我实际上并不是在建议您发布它。这不是我们真正可以帮助您的事情。

标签: objective-c ios crash segmentation-fault


【解决方案1】:

当您的应用收到内存警告时,您似乎做错了什么。您可以使用调试菜单在模拟器上强制执行此操作,或者通过发送(生产代码中的非法)_performMemoryWarning 方法在设备上强制执行此操作:

[[UIApplication sharedApplication] _performMemoryWarning];

您可以将此设置在重复计时器上,以定期发送警告。我建议将其包装在 #IFDEF DEBUG 中,以防止其投入生产。

这不会解决您的问题,但它可以帮助您重现崩溃,这是至关重要的第一步。

【讨论】:

  • 这至少可以解释为什么它会在旧设备上发生,而不是在我的 iPhone 5 上。我会调查一下,谢谢!
猜你喜欢
  • 2019-11-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-06
  • 2015-03-28
  • 2011-06-25
相关资源
最近更新 更多