Robin des Bois
Robin des Bois

Reputation: 355

Thread 1: Program received signal : "EXC_BAD_ACCESS"

I am currently programming a iPhone-app for my maturity research. But there is an behavior I don't understand: Sometimes when i compile my project there is:

Thread 1: Program received signal : "EXC_BAD_ACCESS".

But when I compile the same code a second, or a third time the code just runs fine and i can't get why. I use some MonteCarloSimulation but when it fails it fails executing one of the first 100 simulations. But when every thing runs fine it executes 1000000 simulations without an error.. Really strange isn't it?

Do you have any idea? Can this be an issue of Xcode or arc? All other things just work perfect. Do you have to get any further information? I can also send you my code as an email.

Upvotes: 1

Views: 604

Answers (2)

Matt Lacey
Matt Lacey

Reputation: 8255

This is typically caused by accessing some memory that's been corrupted, chances are you have a reference to an object which has been deleted. A lot of the time you may find that the memory where the object was located has not yet been overwritten, so when you attempt to access that memory your data is still intact and there is no problem, hence it working some of the time.

Another scenario would be that you've got some code writing into memory using a bad reference, so you're writing into an area you shouldn't be. Depending on the memory layout when the program starts, this could have no effect some of the time but cause something catastrophic at other times.

Upvotes: 0

Sean McMains
Sean McMains

Reputation: 59273

This usually means you're trying to access an object that has already been deallocated.

In order to debug these things, Objective C uses something called "NSZombie" that will keep those objects around so you can at least see what it is that's trying to be called. See this question for some details on how to use it.

Upvotes: 1

Related Questions