Tracking EXC_BAD_ACCESS without NSZombie?

I spent two days on it, and I still can not find the cause of the accident.

I know this has something to do with trying to access an object that has been freed, but I don't know what access or which object.

Whenever I try to find the source of EXC_BAD_ACCESS, people suggest using NSZombies. The problem is when I include zombies (either in xcode via an environment variable or in tools using ObjectAlloc properties), the program does not crash where it usually happens and the zombies do not report anything (nothing is displayed in the logs and nothing not marked in tools). Is something missing in NSZombie?

I tried to use some information from the xcode debugger and from ObjectAlloc in tools, but all the information is very mysterious and actually does not help me.

I installed a debugger to stop in objective-c exceptions. When this happens, it shows the call stack:

0 objc_msgSend 1 ?? 2 -[UITableViewCell removeFromSuperView] 3 -[UIView dealloc] ... etc ... 

First of all, what is the deal with '1 ??'? What do question marks mean? Secondly, how can I find out where this was called in my code? All the operations described are too general (for example, UIView dealloc, but which UIView? And where?).

Also, when an exception occurs, it points to the assembly code, which again does not bring me any benefit if I do not spend hours trying to understand what the code does. I know some assembly, but there must be a better way ... right?

Is there a way to get meaningful information about what was the last line that was executed in my code before the exception occurred?

I tried to spray some NSLogs and breakpoints, but that doesn't help much because the crash happens after I pulled the view controller out of the navigation controller. Wherever I place breakpoints, breakpoints are reached accurate (I cannot find a breakpoint after the crash). This is only when I "continue" in the debugger that this is an exception. It is as if an accident occurred outside of my code, so I have no idea where to get the pen.

I looked at my code and double-checked that I adhered to all the rules of memory management (at least as far as I know). I am sure this is something very subtle, but I cannot find it.

If anyone has ideas on how to find such errors without NSZombie, please share.

Thanks.

+1
source share
1 answer

Well, I found a problem. I had my own class of table cells, in which I first called [super dealloc] the dealloc method (and not the last). I guess I wrote this class in a hurry and didn’t really think about it. I guess that in the parental release it was released that the child should have released?

So, I don't have a real answer to my own question, but basically I found the problem using a combination of ad-hoc code tracing and various debugging methods (breakpoints, NSLogs trying to decrypt cryptographic stack trace, etc.).

In fact, the main strategy that helped me was to comment the code in half, until I divided the problem area as easily as I get, while maintaining a loss of integrity. This allowed me to understand that the problem is not where I thought it would be, but in a thinner area (for example, in the second-class dealloc method in this case).

I hope this can help someone help. I will leave this question unanswered so that someone more carefully debugs the strategy without relying on NSZombies. Also, if someone can clarify what these two question marks mean in the stack trace, that would be helpful.

+1
source

All Articles