iOS EXC_BAD_ACCESS crash how to read errors - ios

Testing my app which gets location data from an api and displays in a table view. Was testing something else today and app crashed - EXC_BAD_ACCESS (code=1, address=0X0). What does this mean and how do I read the information provided by Xcode to figure out how to fix?

EXEC_BAD_ACCESS usually means that you are trying to access an object which is not in memory or probably not properly initialized.
Check in your code,
if you are accessing your Dictionary variable after it is somehow removed?
is your variable properly initialized? You might have declared the variable but did not initialize it and accessing it.
There could be a ton of reasons and cant say much without seeing any code.
Try to turn on NSZombieOjects - this might provide you more debug information. Refer to here How to enable NSZombie in Xcode?
IF you would like to know where and when exactly is the error occurring, you could check for memory leaks using instruments. This might be helpful http://www.raywenderlich.com/2696/instruments-tutorial-for-ios-how-to-debug-memory-leaks

Based on the information you provided. My guess is that the library is calling out to a block you provided. Inside that block is a Dictionary which has something wrong with it.
Good luck!

Related

Random crash EXC_BAD_ACCESS on core data object entities comparison

I am facing this weird random crash where I get EXC_BAD_ACCESS on an object that exists. I am totally stumped on why this is happening. The code in the image executes without any issues 99.99% of the time. I saw this crash second time and that when I thought I should figure out what might be going wrong. I am executing this code on the main thread and the crash line has two core data objects. This shouldn't be a concurrency issue because it's only used in this class. Scary part is that object is there, values are there, still, I am getting EXC_BAD_ACCESS. Any ideas why this might be happening?
Let me know if you guys need more info. And thanks in advance for your help. :)
EDIT 1
Definition of Employee and EmployeeForTask (the class declarations are empty and has no variable defined in it, it just inherits from NSManagedObject)
You should enable NSZombies. Zombies helps to detect these kind of crashes by logging problem in console. you can enable zombies by :Click on Product⇒Edit Scheme to open the sheet and set the Enable Zombie Objects check box
When building app on real device then disable Zombies. Otherwise app will not run on device.

EXC_BAD_ACCESS around Springboard-snapshotting

From time to time, Xcode Crashes comes up with a crash that i cannot understand. I pasted the xccrashpoint to gist
It states, that Thread 12 crashed somewhere in CoreGraphics called by CorePDF, called by QuartzCore drawing some layers. This seems like OS-called code, maybe via thread 1 which is doing _saveSnapshotWithName. So i assume, that this happens when closing the app.
Does anyone have at least a rough idea what is going on here? Maybe someone saw something similar before and can give a hint about what is crashing…
There is nothing special in the app that would cause dramatically wrong behaviour when leaving the app (-> when a screenshot ist taken).
Exec bad errors occur when an attempt is made to access a object or memory location which is not yet initialized.
There might be a problem with an object which you are not defining global.
Check if there is any object you defining and initializing in a method and trying to access out of the scope.
For more details related to errors and crashes, please go through below link.
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1

EXC_BAD_ACCESS with MKNetworkEngine

I'm using MKNetworkkit to parse XML data to the server. Before Entering into the success block its gets crash with EXC_BAD_ACCESS with out any reason and am already done with NSZombieEnabled like all the stuffs.![Below is the screen shot of where its getting crash.][1][1]: http://i.stack.imgur.com/FL3l9.png
You may find this useful to help debug http://subhb.org/2012/07/02/how-to-debug-exc_bad_access-error/
You will get EXC_BAD_ACCESS error mostly in the following scenarios:
You are trying to access an object that is not initialized.
You are trying to access an object that no longer exists. Either it’s being released or it’s nil. In ARC mode, make sure you take
ownership of the object that you want to use.
You are passing an message to an object that the object doesn’t understand. It can also happen for bad typecast.
Have you tried running breakpoints on your code and stepping through your program line by line and seeing if any of the above match the result?

Alternative to NSZombie

I'm trying to debug an EXC_BAD_ACCESS crash using NSZombie. My app creates lots of large objects though and with NSZombie enabled they aren't getting released causing the app to crash in seconds. This means I can't even cause the EXC_BAD_ACCESS crash before the app crashes due to low memory.
Is there an alternative? Can I enable NSZombie on specific file instead of the entire project? How else could I debug this crash (I know it's caused by UIGestureRecognizer but I use them a lot so it doesn't narrow down the issue significantly).
Thanks.
Edit:
Thanks for the advice. I think I may have solved the issue and will report back after more testing.
Edit 2: Sovled the issue myself but selected the answer which seems like it would be a good solution to any similar issues in the future.
All I can think of is implementing it manually; create a proxy container that holds an object of type id and nominates that as -forwardingTargetForSelector: as well as getting it to respond to -isKindOfClass:, etc.
Disable ARC for the proxy and have it retain itself during init and check its own retainCount when nominating a forwarding target.
If the count is 1 then raise an exception or log a warning or whatever.
Have suspect classes wrap themselves in and return a proxy as the last line of their unit.
For possible bonus points, store [NSThread callStackSymbols] somewhere (probably on disk) during the proxy's unit so you can at least find out where the incorrectly managed object was created.
NSZombies was/is for apps that use their own memory management. If your app uses ARC then this won't help.
Create a new Breakpoint: All Exceptions
That should usually show you where you trigger the bad access.

How to know the object name based on memory address in objective c

Hi one of my app is crashing repeatedly and giving below error.
*** -[CFString release]: message sent to deallocated instance 0x1b7a3b70
Is there any way to get the object name by using memory address. I used instruments (Zombie) and even i enabled zombies in Xcode but no luck. Can you please help me in this issue i stuck please help me.
It's clearly a string. Likely a CFString but could be bridged from NSString.
With that knowledge, use the debugger and breakpoints.
With break points you can step through the code, and use QuickLook to see details about objects.
Most Objective-C objects don't have names. (There are a few exception, like NSOperationQueue).
It's always a good idea to use the static analyser, to look at all warnings and fix them, etc. Especially if your code uses CoreFoundation which isn't handled automatically by ARC, but the static analyser usually finds incorrect uses.
Showing the stack trace where this happened might also be helpful.

Resources