在iPhone应用程序中调试EXC_BAD_ACCESS [英] Debugging EXC_BAD_ACCESS in an iPhone app
问题描述
这是我的堆栈跟踪。我从哪里开始弄清楚?我尝试了一大堆NSLog(),我无法追踪它。
Here's my stack trace. Where do I start to figure this out? I've tried a ton of NSLog()s and I can't track it down.
#0 0x94e9ced7 in objc_msgSend ()
#1 0x04936318 in ?? ()
#2 0x0259b252 in __CFRunLoopDoObservers ()
#3 0x0259a65f in CFRunLoopRunSpecific ()
#4 0x02599c48 in CFRunLoopRunInMode ()
#5 0x02ae7615 in GSEventRunModal ()
#6 0x02ae76da in GSEventRun ()
#7 0x0061dfaf in UIApplicationMain ()
#8 0x000051cc in main
推荐答案
这是我如何跟踪这个。
首先,我使用以下方式遍历了这个地方: p>
First, I went all over the place using:
NSLog(@"%s", __PRETTY_FUNCTION__, nil);
为了尽可能接近崩溃。就像我这样做,我碰巧注意到,它看起来像一个对象变成null,不应该是。
in order to get as close as possible to the crash. As I did that I happened to notice that it looked like an object was becoming null that shouldn't have been.
在这一点上,NSDBombieEnabled和Instruments的GDB都报告没有僵尸。
At this point, GDB with NSZombieEnabled and Instruments both reported NO zombies.
我将NSLog-ing添加到dealloc并释放了我遇到问题的对象的方法。最后,我能够获得足够的感觉,在这些方法中添加断点,并在每次查找stacktrace时发现自动释放池被调用。
I added the NSLog-ing to the dealloc and release methods of the object I was having a problem with. Finally I was able to get enough sense to add a breakpoint in those methods and look at the stacktrace each time, when I found that release was being called by the autorelease pool.
我终于明白,我没有保留我应该去的东西。一旦我保留它,宾果,问题解决了。
I finally figured out that I wasn't retaining something that I should have been. Once I retained it, bingo, problem solved.
那就是说,NSZombieEnabled和Instruments的建议都帮助了自那以后出现的其他一些bug,所以感谢大家。
That said, the NSZombieEnabled and Instruments recommendations have both helped with some other bugs that have cropped up since then, so thanks everyone.
这篇关于在iPhone应用程序中调试EXC_BAD_ACCESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!