xcode 线程 1:EXC_BAD_ACCESS(代码=1,地址=0xf1759018)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20913394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Thread 1: EXC_BAD_ACCESS (code=1, address=0xf1759018)
提问by Charlie
So I am getting this error (picture below). What is happening when I get this error is going through my core data data base and averaging out results based on battery statistics that I have collected. This was working fine until I took a break and then came back, plugged it in and it started getting this error. I have an exception breakpoint, but it is still not showing me anything other than the crash in the image.
所以我收到这个错误(下图)。当我收到此错误时,正在查看我的核心数据库并根据我收集的电池统计数据对结果进行平均。这一直工作正常,直到我休息一下然后回来,将其插入并开始出现此错误。我有一个异常断点,但除了图像中的崩溃之外,它仍然没有向我显示任何内容。
Anyone know what i should do?
有谁知道我应该怎么做?
xcode Version 5.0
Xcode 5.0 版
Let me know if i can post anything else that can help figure out what is causing this!
让我知道我是否可以发布其他任何可以帮助找出导致这种情况的原因的内容!
回答by coneybeare
For any EXC_BAD_ACCESS
errors, you are usually trying to send a message to a released object. The BESTway to track these down is use NSZombieEnabled.
对于任何EXC_BAD_ACCESS
错误,您通常会尝试向已发布的对象发送消息。追踪这些的最好方法是使用NSZombieEnabled。
This works by never actually releasing an object, but by wrapping it up as a "zombie" and setting a flag inside it that says it normally would have been released. This way, if you try to access it again, it still know what it was before you made the error, and with this little bit of information, you can usually backtrack to see what the issue was.
这是通过从不实际释放对象,而是通过将其包装为“僵尸”并在其中设置一个标志,表明它通常会被释放来工作。这样,如果您再次尝试访问它,它仍然会在您出错之前知道它是什么,有了这些信息,您通常可以回溯以查看问题所在。
It especially helps in background threads when the Debugger sometimes craps out on any useful information.
当调试器有时会处理任何有用的信息时,它特别有助于后台线程。
VERY IMPORTANT TO NOTEhowever, is that you need to 100% make sure this is only in your debug code and not any code you are testing outside of XCode. Because nothing is ever released, your app will leak and leak and leak. To remind me to do this, I put this log in my appdelegate:
然而,非常重要的一点是,您需要 100% 确保这仅在您的调试代码中,而不是您在 XCode 之外测试的任何代码。因为没有任何东西被发布,你的应用程序会泄漏,泄漏和泄漏。为了提醒我这样做,我把这个日志放在我的 appdelegate 中:
if (getenv("NSZombieEnabled"))
NSLog(@"NSZombieEnabled!");
If you need help finding the exact line, Build-and-Run. When the app crashes, the debugger will show you exactly which line and in combination with NSZombieEnabled, you should be able to find out exactly why and what type of object is being accessed after being released.
如果您需要帮助找到确切的线路,请构建并运行。当应用程序崩溃时,调试器会准确显示哪一行,并结合 NSZombieEnabled,您应该能够准确找出释放后访问的对象的原因和类型。
回答by user2387149
Sometimes a quick fix is to delete your app from the device and run it again. If this works it means you changed your core data model or something similar.
有时,快速修复是从设备中删除您的应用程序并再次运行它。如果这有效,则意味着您更改了核心数据模型或类似的东西。
回答by amirkrd
This happened for me when, I was calling a createMessage function from my Firebase worker and returning the Firebase Document as a whole. The firebase document shouldnt be returned as a whole, that is bad coding practice, instead, you should take the document and parse it and get what you need from it down to the basic types and then return that. Hopefully this helps anyone that might run into this in the future.
当我从 Firebase 工作人员调用 createMessage 函数并将 Firebase 文档作为一个整体返回时,这发生在我身上。firebase 文档不应该作为一个整体返回,这是不好的编码实践,相反,您应该获取文档并解析它并从中获取所需的基本类型,然后返回。希望这可以帮助将来可能遇到此问题的任何人。