NSZombieEnabled 不报告导致 EXC_BAD_ACCESS 错误的对象类型
由于某种原因,我在 UIKit 内部发生了一次崩溃; EXC_BAD_ACCESS 错误正在发生,例如在解雇ModalViewController调用中进行了8次调用。我尝试为我的可执行文件启用 NSZombieEnabled,但无论是否打开僵尸,控制台日志都会打印相同的错误,并且我不知道哪个对象导致了问题。为了让控制台打印正确的信息,我是否缺少一些东西?
I have a crash that is happening deep within UIKit for some reason; an EXC_BAD_ACCESS error is happening something like 8 calls deep into a dismissModalViewController call. I tried enabling NSZombieEnabled for my executable, but the console log prints the same error regardless of whether or not zombies are turned on and i don't know which object is causing the issue. Is there something i'm missing that i need to do to get the console to print the correct information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
此处了解有关使用僵尸的信息。
在 gdb 中运行它。当您获得 EXC_BAD_ACCESS 时,请查看此时的堆栈(使用 gdb 的 where 命令或运行 Xcode GUI 调试器)。如果您仍然遇到问题,请将堆栈发布到您原来的问题中。
另外,只有当你处理 NSObject 时,僵尸才会帮助你。如果您使用低级 malloc/free 例程,僵尸不会为这些分配购买任何东西。
Read about using Zombies here.
Run this in gdb. When you get the
EXC_BAD_ACCESS
look at the stack at that point (use gdb's where command or run the Xcode GUI debugger). If you are still having issues, post the stack in your original question.Also zombies will only help you if you're dealing with NSObjects. If you're using low level malloc/free routines zombies buy you nothing for those allocations.
上周末,当 NSZombieEnabled 似乎根本不起作用时,我学到了一件事 - 确保您没有向某些代码传递非对象。
就我而言,我返回的 NSString 只是“string”而不是@“string”。这意味着我正在用 c 字符串覆盖 NSString 对象。当我后来尝试在该对象中写入新值时,我得到了 BAD_ACCESS。 NSZombie 无法帮助 b/c 它不是我试图覆盖的对象,而是那个 c 字符串。
顺便说一句,在 XCode 中将所有警告视为错误 - 希望我能让它们在 IDE GUI 中以红色显示 - 有时很容易错过它们。
One thing I learned last weekend when NSZombieEnabled didn't seem to be working at all - make sure you're not passing in a non-object to some code.
In my case, I was returning an NSString as just "string" instead of @"string". That meant I was overwriting an NSString object with the c-string. When I later tried to write a new value in that object I was getting a BAD_ACCESS. NSZombie's couldn't help b/c it was not an object I was trying to overwrite, but that c-string.
As an aside, treat all warnings as errors in XCode - wish I could make them show up in RED in the IDE GUI - they are easy to miss sometimes.
听起来你的模态视图控制器中有些东西被过度释放了。首先注释掉新的行,直到它停止破坏。
Sounds like something is over-released in your Modal View Controller. Start by commenting out newish lines until it stops breaking.