views:

204

answers:

3

From times to times, while debugging an Application, I see this error on Xcode:

Program received signal: “EXC_BAD_ACCESS”.

and the debugger does not stop on the problematic line. In fact the debugger just shows me a page with a bunch assembly language code and that's it.

I have to have paranormal powers to figure out where the exact problem is.

Is there a way to force Xcode to give me more "nutritive" error messages – that can detail the problem – and stop on the offending line when such errors occur?

thanks for any help.

+2  A: 

You can enable NSZombies see here and I've found a good way to see where the actual problem is, is to run and debug the program with the debugger open.

This way when the program stops executing it more often then shows the line that was executing when the program crashed.

James Raybould
Thanks. I have enabled this but I don't see any open execution. The error message changed from EXC_BAD_ACCESS to ...-[CALayer retain]: message sent to deallocated instance 0x182200... but I don't see how can this help because there's no clue of what this object is in my code... I have many CALayers... This was the only line printed on console.
Digital Robot
If you have the debugger open you should be able to see the stack trace which should provide more information
James Raybould
+5  A: 

When the crash happens, open the Debugger in Xcode (Run -> Debugger). There should be 3 to 4 panes like this:

On the top-left pane (the "stack trace"), select the topmost row which is not gray.

(Note: Sometimes the stack trace can only find internal functions because of bad memory management triggered in the run loop. Try to Build -> Build and Analyze to eliminate all potential memory management bugs first.)

KennyTM
thanks!!!!!!!!!
Digital Robot
A: 

I wrote up a blog that tells you how to use some compiler switches that help a lot in finding crashes that are the result of releasing objects before you are done with them.

http://loufranco.com/blog/files/debugging-memory-iphone.html

Build and Analyze is ok, but not as good as scan-build (which it is based on). Instructions for installing that are here:

http://loufranco.com/blog/files/scan-build-better-than-build-analyze.html

Lou Franco