在“Edit Schema->Diagnostic”中启用“Guard malloc”时,我在下面找到了问题的解决方案。第三方代码以不正确的方式使用内存。
我的 iOS 应用程序发生了几次随机崩溃(使用 ARC,见下文)。在我看来,这是由于过度释放的对象。
我尝试NSZombie
在 xCode 中启用,但在控制台崩溃之前没有收到任何警告。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 ()