在“Edit Schema-> Diagnostic”中启用“Guard malloc”时,我找到了以下问题的解决方案。第三方代码以不正确的方式使用内存。
我的iOS应用程序出现了几次随机崩溃(使用ARC,见下文)。它对我来说是由于过度释放的物体造成的。
我尝试在xCode中启用NSZombie
,但在控制台崩溃之前没有收到任何警告。
与 Zombies 仪器相同的问题 - 未检测到错误。 “所有异常”的断点在objc_msgSend
或类似的东西上停止。
我无法在此处粘贴任何代码或执行逐行调试,因为我不了解崩溃的位置。
那么,有没有人知道在iOS上找到错误来源的任何其他高级技术? 回溯样本:
#0 0x3c2e1cda in realizeClass(class_t*) ()
#1 0x3c2e1d46 in realizeClass(class_t*) ()
#2 0x3c2e1d46 in realizeClass(class_t*) ()
#3 0x3c2dc094 in prepareForMethodLookup ()
#4 0x3c2dbf9a in lookUpMethod ()
#5 0x3c2dbf66 in _class_lookupMethodAndLoadCache3 ()
#6 0x3c2db61a in objc_msgSend_uncached ()
#7 0x3627784c in -[UIButtonContent dealloc] ()
#8 0x34388310 in CFRelease ()
#9 0x34463434 in __CFBasicHashDrain ()
#10 0x343883d0 in CFRelease ()
#11 0x3627dee6 in -[UIButton dealloc] ()
#12 0x3627e0b4 in -[UIView dealloc] ()
#13 0x34388310 in CFRelease ()
#14 0x3439295c in -[__NSArrayM dealloc] ()
#15 0x3c2dd488 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#16 0x3438a440 in _CFAutoreleasePoolPop ()
#17 0x34cbb782 in -[NSAutoreleasePool drain] ()
#18 0x341ce2ca in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] ()
#19 0x341cd10e in _performRunLoopAction ()
#20 0x3441c6cc in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#21 0x3441a9c0 in __CFRunLoopDoObservers ()
#22 0x3441ad16 in __CFRunLoopRun ()
#23 0x3438debc in CFRunLoopRunSpecific ()
#24 0x3438dd48 in CFRunLoopRunInMode ()
#25 0x37f402ea in GSEventRunModal ()
#26 0x362a3300 in UIApplicationMain ()
#27 0x000a879c in main at main.m:16
#0 0x3c2db5be in objc_msgSend ()
#1 0x34388aaa in CFDictionaryGetValue ()
#2 0x362656cc in -[UIButton(UIButtonContentLookup) _contentForState:] ()
#3 0x36274f38 in -[UIButton(UIButtonContentLookup) _backgroundForState:usesBackgroundForNormalState:] ()
#4 0x36274e54 in -[UIButton contentRectForBounds:] ()
#5 0x362954c4 in -[UIButton layoutSubviews] ()
#6 0x36252802 in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#7 0x35ffcd8a in -[CALayer layoutSublayers] ()
#8 0x35ffc928 in CA::Layer::layout_if_needed(CA::Transaction*) ()
#9 0x35ffd85c in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#10 0x35ffd242 in CA::Context::commit_transaction(CA::Transaction*) ()
#11 0x35ffd050 in CA::Transaction::commit() ()
#12 0x35ffceb0 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
#13 0x3441c6cc in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#14 0x3441a9c0 in __CFRunLoopDoObservers ()
#15 0x3441ad16 in __CFRunLoopRun ()
#16 0x3438debc in CFRunLoopRunSpecific ()
#17 0x3438dd48 in CFRunLoopRunInMode ()
#18 0x37f402ea in GSEventRunModal ()
#19 0x362a3300 in UIApplicationMain ()
#20 0x0007479c in main at main.m:16
#0 0x33750f78 in objc_msgSend ()
#1 0x35a7b2e6 in CFRelease ()
#2 0x35af7b36 in __CFDictionaryStandardReleaseValue ()
#3 0x35b4b3bc in __CFBasicHashDrain ()
#4 0x35a7b39a in CFRelease ()
#5 0x332a0c88 in -[UIButton dealloc] ()
#6 0x33752174 in _objc_rootRelease ()
#7 0x35a7b2e6 in CFRelease ()
#8 0x35a9106a in -[__NSArrayM dealloc] ()
#9 0x33752174 in _objc_rootRelease ()
#10 0x33753e56 in objc_release ()
#11 0x33752eac in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#12 0x33752dc8 in _objc_autoreleasePoolPop ()
#13 0x35a82cfe in _CFAutoreleasePoolPop ()
#14 0x34f5898c in __NSFireDelayedPerform ()
#15 0x35b06a32 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#16 0x35b06698 in __CFRunLoopDoTimer ()
#17 0x35b0526e in __CFRunLoopRun ()
#18 0x35a884a4 in CFRunLoopRunSpecific ()
#19 0x35a8836c in CFRunLoopRunInMode ()
#20 0x33823438 in GSEventRunModal ()
#21 0x33260cd4 in UIApplicationMain ()
#22 0x001185b8 in main at main.m:16
#23 0x000f7d78 in start ()
答案 0 :(得分:3)
这不是一个可捕捉的例外;没有扔。这是一次艰难的崩溃。很可能由于内存损坏而进一步确认,因为NSZombie
没有帮助。
虽然这通常是Debugging over-released objects, problem with NSZombie的欺骗,但有一些特定于可能有帮助的崩溃的背景。
在这两种情况下,UIButtonContent
的操纵都会崩溃。 UIButtonContent
是UIKit的内部实现细节,最终引用了按钮使用的各种图像,标题等。
如果图像数据过早释放(或损坏),则可能导致此类崩溃。我建议您仔细查看如何管理图像数据。
答案 1 :(得分:1)
概述ThisDarkTao说的话。
如果你去断点菜单:
然后点击左下角的加号:
您将看到一个断点菜单。所有选项都应默认为适当的值(您可以仔细检查下面的图像)。按完了。这应该导致导致问题/崩溃程序的代码行中断。它并不总是有帮助,但往往提供一些很好的方向。