无法让僵尸在 XCode 中工作

发布于 2024-09-30 04:13:52 字数 820 浏览 1 评论 0原文

我正在尝试解决我的第一个非常困难的 EXC_BAD_ACCESS 问题。我从很多教程和博客中看到,我可以使用僵尸来帮助我找出哪里出错了。但我不认为我的僵尸正在工作,而且我肯定没有从控制台中得到任何有用的东西。

当我启动程序时,我看到这个:This GDB wasconfigured as "x86_64-apple-darwin".Settingenvironmentvariable"NSZombieEnabled" to null value.

最终,我看到了我使用的几个 NSLog 跟踪然后:

Program received signal:  “EXC_BAD_ACCESS”.

根本没有帮助。有什么想法吗?我暗自怀疑,即使僵尸在工作,它也无法告诉我错误访问发生在哪里。 Objective C 让我伤心——这在 ActionScript 中需要 3 秒:(


你说崩溃就在这里(下次编辑问题):

- (IBAction) toggleView{
if(switchableView.subviews.count != 0)
    [[switchableView.subviews objectAtIndex:0] removeFromSuperview];
UIViewController* newView = (viewSelector.selectedSegmentIndex == 0) ? [Login new] : [UserRegistration new];
[switchableView addSubview:newView.view];
//[newView release];
}

I'm trying to solve my first really hard EXC_BAD_ACCESS problem. I see from a lot of tutorials and blogs that I can use Zombies to help me figure out where I'm going wrong. But I don't think my zombies are working, and I'm DEFINATELY not getting anything useful out of the console.

When I start the program I see this: This GDB was configured as "x86_64-apple-darwin".Setting environment variable "NSZombieEnabled" to null value.

Eventually, I see a couple of NSLog traces I used and then:

Program received signal:  “EXC_BAD_ACCESS”.

No help at all. Any ideas? I have a sneaking suspicion that even with the zombies working it won't be able to tell me where the bad access happened. Objective C makes me sad--This would have taken 3 seconds in ActionScript :(


You say the crash is here (edit the question next time):

- (IBAction) toggleView{
if(switchableView.subviews.count != 0)
    [[switchableView.subviews objectAtIndex:0] removeFromSuperview];
UIViewController* newView = (viewSelector.selectedSegmentIndex == 0) ? [Login new] : [UserRegistration new];
[switchableView addSubview:newView.view];
//[newView release];
}

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

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

发布评论

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

评论(2

蓝天 2024-10-07 04:13:52

实际上你从控制台得到了一些有用的东西。它告诉您尚未启用 NSZombie - “将环境变量“NSZombieEnabled”设置为空值。”

该值必须为 YES,不能为空。

可执行文件 ->您的目标名称 ->参数 ->要在环境中设置的变量

即使没有启用 NSZombies,也应该很容易从调用堆栈中看到错误访问的位置。动作脚本是一种脚本语言。

Actually you are getting something useful from the console. It's telling you that you haven't enabled NSZombie - "Setting environment variable "NSZombieEnabled" to null value."

The value needs to be YES not null.

Executables -> Your Target Name -> Arguments -> Variables to be set in the environment

Even without NSZombies enabled it should be very straightforward to see where your bad access is from your call stack. Action script is a scripting language.

似梦非梦 2024-10-07 04:13:52

没有理由说这个错误一定是由过度释放的对象引起的。还有很多其他原因可能会导致您崩溃。

程序收到信号:“EXC_BAD_ACCESS”。

好的——那么它在哪里崩溃了?什么是回溯?它应该已经崩溃到调试器,并且调试器应该向您显示有关崩溃的一堆详细信息。

发布回溯以及恰好位于该回溯中的任何代码。


这不是回溯,但它确实提供了更多上下文。回溯会很有帮助,因为它会准确显示崩溃发生的位置。

就僵尸而言,我发现使用 Run ->; 更容易。使用性能工具运行 -> Zombies 菜单项可在僵尸检测模式下启动仪器。

当您注释掉 release 时,崩溃就会消失,这肯定表明存在内存管理问题。假设您没有覆盖 new,您发布的代码看起来不错。

您尝试过“构建和分析”吗?

您得到一个意外的表表明您的代码中[显然]存在其他问题。这可能还包含内存管理问题?

另外,如果 removeFromSuperview: 导致稍后查询所选段的视图释放&解除分配,这也可能导致崩溃。


目标 C 让我伤心——这会
在 ActionScript 中花费了 3 秒

任何你不知道的事情都会让你感到悲伤,当你试图将它当作你确实知道的无关的事情时。任何语言、工具或新环境的成功都取决于您的态度以及工具的细节。

我建议您退后一步,做一些教程和/或 阅读一些有关调试应用程序的文档

There is no reason why this error has to be caused by an over-released object. There are plenty of other reasons why you might be crashing.

Program received signal: “EXC_BAD_ACCESS”.

OK -- so where is it crashing? What is the backtrace? It should have crashed to the debugger and the debugger should be showing you a bunch of details about the crash.

Post the backtrace and any of your code that happens to be in that backtrace.


That isn't a backtrace, but it does give some more context. A backtrace would be helpful in that it'll show exactly where the crash is happening.

As far as zombies are concerned, I find it easier to use the Run -> Run With Performance Tool -> Zombies menu item to fire up Instruments in Zombie detection mode.

That the crash goes away when you comment out the release certainly indicates a memory management problem. The code you posted looks OK, under the assumption that you didn't override new.

Have you tried "Build and Analyze"?

That you are getting an unexpected table indicates that there are [obviously] other problems in your code. That might also contain memory management issues, too?

Also -- if the removeFromSuperview: causes the view that is later queried for selected segment to release & deallocate, that could cause the crash, too.


Objective C makes me sad--This would
have taken 3 seconds in ActionScript

Anything you don't know makes you sad when you try to treat it like something unrelated that you do know. Success with any language, tool, or new environment is as much about your attitude as it is the details of the tool.

I'd suggest you take a step back, do a few tutorials and/or read some documentation about debugging applications.

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