简体   繁体   中英

Troubleshooting cryptic EXC_BAD_ACCESS on IOS app

When I run my IOS application (on either the IPad simulator or real device) I get a EXC_BAD_ACCESS error. Normally I would have no problem troubleshooting this, but the error is coming deep from within the system itself, and after searching around I'm stuck how to proceed with the troubleshooting.

Can anyone give me some ideas what is going on or how to troubleshoot this? I am working with a huge project and without some indication from the error message I don't know where to start.

Thanks!

#0  0x0230609b in objc_msgSend ()
#1  0x0206943d in CFRetain ()
#2  0x0214e9c0 in +[__NSArrayI __new::] ()
#3  0x020a200a in -[__NSPlaceholderArray initWithObjects:count:] ()
#4  0x009aa2dc in -[CALayerArray copyWithZone:] ()
#5  0x02164bd9 in -[NSObject copy] ()
#6  0x016bb0fa in -[UIView dealloc] ()
#7  0x02306e4d in _objc_rootRelease ()
#8  0x0206e435 in CFRelease ()
#9  0x0214fe94 in -[__NSArrayM dealloc] ()
#10 0x02306e4d in _objc_rootRelease ()
#11 0x02306e10 in objc_release ()
#12 0x02307c60 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
#13 0x02096ed8 in _CFAutoreleasePoolPop ()
#14 0x012619f9 in -[NSAutoreleasePool release] ()
#15 0x0168af78 in _UIApplicationHandleEvent ()
#16 0x035dffa9 in PurpleEventCallback ()
#17 0x021361c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#18 0x0209b022 in __CFRunLoopDoSource1 ()
#19 0x0209990a in __CFRunLoopRun ()
#20 0x02098db4 in CFRunLoopRunSpecific ()
#21 0x02098ccb in CFRunLoopRunInMode ()
#22 0x016872a7 in -[UIApplication _run] ()
#23 0x01688a9b in UIApplicationMain ()
#24 0x0020f2a4 in main at /..../main.m:17

From the stack trace you can work out the following :

1) It's to do with the autorelease pool

2) An array is being released

3) I guess that array contains some UIViews (maybe)

4) As part of UIView dealloc, something is going horribly wrong

That's not that helpful, sorry :)

The autorelease at the start of the stack trace tells you that it's almost certainly something that you have not retained something enough :)

Is there any particular view in which this error occurs?

My first guess would be that you are releasing a view that's already autoreleased. For example:

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[self.view addSubview:myButton]
[myButton release];

You could also be releasing a view twice or perhaps releasing a view whose superview has gone away.

If possible, you might consider moving the project to ARC since it solves most (but not all!) of these issues. Otherwise, your best bet to debugging it is probably to #ifdef out portions of your code until the crash goes away and then put the code back in until it crashes again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM