tags:

views:

1382

answers:

2

When running on the device:

Program received signal:  “EXC_BAD_ACCESS”.

Debugger:

#0  0x31e11158 in CALayerCollectLayers_
#1  0x31e11180 in CALayerCollectLayers_
#2  0x31e11180 in CALayerCollectLayers_
#3  0x31dd7428 in CALayerDisplayIfNeeded
#4  0x31dd5780 in CAContextCommitTransaction
#5  0x31dd543c in CATransactionCommit
#6  0x3026a0ec in __CFRunLoopDoObservers
#7  0x30269418 in CFRunLoopRunSpecific
#8  0x30269326 in CFRunLoopRunInMode
#9  0x306941fe in -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
#10 0x30694f9a in -[NSRunLoop(NSRunLoop) run]
#11 0x0000319e in -[AppController createInStreamThread] at AppController.m:395
#12 0x30672e08 in -[NSThread main]
#13 0x30672cd6 in __NSThread__main__
#14 0x3146178c in _pthread_body

When running in the Simulator:

modifying layer that is being finalized - 0x52f2b0
+2  A: 

It turns out that I was over-releasing a UIButton.

UIButton *button = [self buttonWith...];
...
[self addSubview:button];
[button release];

But [self buttonWith...] returned an autoreleased button, so my release shouldn't have been there. Removing that line fixed the crash.

Elliot
+1  A: 

This type of defect can be difficult to track down. I'm glad you found it so quickly. Luckily there are some good tools to help you.

first of all, use clang static language analysis it can find this sort of defect without you ever running the code.

If you hit this defect after that, turn on NSZombies, MallocStackLogging and MallocStackLoggingNoCompact then use malloc_history to find where you allocation was performed. It's not perfect but it's a great help.

Roger Nolan