启用僵尸后 EXC_BAD_ACCESS 消失

发布于 2024-12-06 11:29:45 字数 145 浏览 5 评论 0原文

我在启动时遇到 EXC_BAD_ACCESS 崩溃,Xcode 表示崩溃发生在 main.m 文件中的 NSApplicationMain 行。 99% 的情况下都会发生崩溃,当我启用僵尸运行时,崩溃永远不会发生。有人见过这个吗?我怎样才能调试这个?

I'm getting an EXC_BAD_ACCESS crash at startup and Xcode says the crash is at the NSApplicationMain line in my main.m file. The crash happens 99% of the time and when I run it with zombies enabled the crash never happens. Has anyone seen this before? How can I possibly debug this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

有木有妳兜一样 2024-12-13 11:29:45

如果您运行的是 Xcode4,默认情况下会显示很少的调用堆栈,请将底部的滑块向右移动。您很可能找不到任何代码,但您应该能够很好地了解发生了什么。如果它是延迟后的通知或选择器,您将看到 Runloop 调度,这也将为您提供线索。

最后,回到老派,就像我们在编码论坛、打孔卡和每天只编译几次的时代所做的那样:研究你的代码。了解每一行代码的作用及其原因。

正如 @Danra 所说,请运行 Xcode 分析器并修复所有投诉。

If you are running Xcode4 there default is to show very little of the call stack, move the slider at the bottom to the right. You may well not find any of your code but you should be able to get a good idea of what was going on. If it was a notification or selector after delay you will see that the Runloop dispatch and that will also give you a clue.

Finally, go old school, the way we did it in the day of coding forums, punch cards and only a couple of compiles a day: study your code. Know what every line of code does and why it is there.

As @Danra said, do run the Xcode Analyzer and fix all complaints.

寄意 2024-12-13 11:29:45

启用僵尸运行可以解决错误访问的原因可能是:a) 在这种模式下,当对象的保留计数达到零时,对象不会真正被释放;b) 最初的崩溃是由于访问已经释放的对象而导致的。

然而,启用僵尸后,我认为您应该在调试控制台中看到对已释放对象的访问,而不是崩溃。

我还建议使用静态分析器(XCode 菜单中的“分析”),希望它能找到罪魁祸首。

The reason why running with zombies enabled resolves the bad access is probably that a) In this mode objects don't really get deallocated when their retain count reaches zero, and b) That your original crash is due to accessing an already deallocated object.

However with zombies enabled, instead of the crash I think you should see in the debug console the access to the deallocated object.

I also recommend using the static analyzer ("Analyze" in the XCode menus) in hope that it finds the culprit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文