views:

111

answers:

1

I'm having a bug in my Objective C program which causes the machine to crash hip deep in some library methods, and it's all library methods down the stack to main (Which I haven't touched from the one XCode gave me). So, I have a bit of a mystery.

The error I'm getting is:

Program received signal:  “EXC_BAD_ACCESS”.

Now, I'm sure that this means that somewhere I'm releasing something too many times, or something like that. This is the objective C version of a seg-fault, right?

My question is: Since it's not happening in my own code, is there some clever way of tracking down what I'm double releasing? or is code inspection the best bet?

thanks.

+2  A: 

EXC_BAD_ACCESS essentially means that you're trying to access or use a specific chunk of memory in an unexpected way. For example, if you try to send a message to a memory reference that no longer represents a valid object. It's different from a segmentation fault, but related.

See this related SO question for suggestions on debugging over-released objects. NSZombie will work wonders for you. Once you get your hands on Snow Leopard (you're getting it this Friday, right?) use the Zombies instrument to simplify the process, and use the Xcode static analyzer to help you find such errors at compile time.

Also visit: http://www.cocoadev.com/index.pl?DebuggingTechniques and this Apple Tech Note.

Quinn Taylor
You can also get EXC_BAD_ACCESS errors if you have a non-null-terminated char* c string and attempt to use it as if it were null-terminated. That took me *forever* to track down.
Dave DeLong
Ah, yes, NSZombie, I'd forgotten about that! thanks!
Brian Postow