问题
I am using xcode Instruments to track Allocations and Leaks. My app is crashing though. It does not crash when running the regular debug or release builds standalone, only when under Instruments:
Any thoughts ideas very gratefully received....
Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x0002b2e0 Crashed Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libobjc.A.dylib 0x34499c96 objc_msgSend + 14 1 ZZZ Test Suite 0x000a3d74 0x95000 + 60788 2 CoreFoundation 0x308e4c3c -[NSObject(NSObject) release] + 24 3 CoreFoundation 0x308e519a CFRelease + 62 4 CoreFoundation 0x308e7eb4 _CFAutoreleasePoolPop + 140 5 Foundation 0x341b41c4 -[NSAutoreleasePool release] + 92 6 UIKit 0x309e5f08 _UIApplicationHandleEvent + 5784 7 GraphicsServices 0x30269e70 PurpleEventCallback + 660 8 CoreFoundation 0x30957a90 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20 9 CoreFoundation 0x30959838 __CFRunLoopDoSource1 + 160 10 CoreFoundation 0x3095a606 __CFRunLoopRun + 514 11 CoreFoundation 0x308eaebc CFRunLoopRunSpecific + 224 12 CoreFoundation 0x308eadc4 CFRunLoopRunInMode + 52 13 GraphicsServices 0x30269418 GSEventRunModal + 108 14 GraphicsServices 0x302694c4 GSEventRun + 56 15 UIKit 0x30a10d62 -[UIApplication _run] + 398 16 UIKit 0x30a0e800 UIApplicationMain + 664 17 ZZZ Test Suite 0x0009665c 0x95000 + 5724 18 ZZZ Test Suite 0x00096604 0x95000 + 5636
回答1:
Try running it through the analyser first. You can run it from xcode from the |product| menu then select Analyze. It's a static analyser (clang) that analyses your code when it builds so any problems causing your code to crash at runtime could well be visible through static analysis. Give it a try and fix any problems it throws up then try instruments again.
回答2:
As a complement to what Ian says above: set the Environment variable "NSZombieEnabled" to YES and you will hopefully have a more informative fail.
(In XCode 4 the Environment Variables is found under "Edit Scheme" and select "Debug")
来源:https://stackoverflow.com/questions/6372553/xcode-instruments-causing-app-crash