简体   繁体   English

线程1:程序收到信号:“ EXC_BAD_ACCESS”

[英]Thread 1: Program received signal : “EXC_BAD_ACCESS”

I am currently programming a iPhone-app for my maturity research. 我目前正在为我的成熟度研究编写iPhone应用程序。 But there is an behavior I don't understand: Sometimes when i compile my project there is: 但是有一种我不了解的行为:有时,当我编译项目时,有:

Thread 1: Program received signal : "EXC_BAD_ACCESS". 线程1:程序接收到信号:“ EXC_BAD_ACCESS”。

But when I compile the same code a second, or a third time the code just runs fine and i can't get why. 但是,当我第二次或第三次编译相同的代码时,代码运行良好,我无法理解为什么。 I use some MonteCarloSimulation but when it fails it fails executing one of the first 100 simulations. 我使用了一些MonteCarloSimulation,但是当它失败时,它将无法执行前100个仿真之一。 But when every thing runs fine it executes 1000000 simulations without an error.. Really strange isn't it? 但是,当一切运行良好时,它会执行1000000次仿真而不会出错。.真的很奇怪吗?

Do you have any idea? 你有什么主意吗? Can this be an issue of Xcode or arc? 这可能是Xcode或arc的问题吗? All other things just work perfect. 其他所有东西都完美地工作。 Do you have to get any further information? 您是否需要任何进一步的信息? I can also send you my code as an email. 我也可以将我的验证码作为电子邮件发送给您。

This usually means you're trying to access an object that has already been deallocated. 这通常意味着您正在尝试访问已被释放的对象。

In order to debug these things, Objective C uses something called "NSZombie" that will keep those objects around so you can at least see what it is that's trying to be called. 为了调试这些东西,Objective C使用了一个称为“ NSZombie”的东西,它将保留这些对象,因此您至少可以看到试图调用的是什么。 See this question for some details on how to use it. 有关如何使用它的一些详细信息,请参见此问题

This is typically caused by accessing some memory that's been corrupted, chances are you have a reference to an object which has been deleted. 这通常是由于访问已损坏的某些内存引起的,很可能是您引用了已删除的对象。 A lot of the time you may find that the memory where the object was located has not yet been overwritten, so when you attempt to access that memory your data is still intact and there is no problem, hence it working some of the time. 很多时候,您可能会发现对象所在的内存尚未被覆盖,因此当您尝试访问该内存时,您的数据仍然完好无损,因此没有问题,因此它有时会工作。

Another scenario would be that you've got some code writing into memory using a bad reference, so you're writing into an area you shouldn't be. 另一种情况是您已经使用错误的引用将一些代码写入内存,因此您正在写入不应该的区域。 Depending on the memory layout when the program starts, this could have no effect some of the time but cause something catastrophic at other times. 取决于程序启动时的内存布局,这在某些时候可能不会产生任何影响,但在其他时候会造成灾难性的后果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM