Thread 1: EXC_BAD_ACCESS (code=1, address=0xf1759018)

匆匆过客 提交于 2019-12-10 20:53:43

问题


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

Let me know if i can post anything else that can help figure out what is causing this!


回答1:


For any EXC_BAD_ACCESS errors, you are usually trying to send a message to a released object. The BEST way to track these down is use 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 NOTE however, 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:

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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/20913394/thread-1-exc-bad-access-code-1-address-0xf1759018

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!