Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to track down cause of SIGABRT

I'm showing the code to this problem for example purposes, but really my question is: how am I supposed to track down and understand SIGABRT errors? I read this question: sigabrt with no error message, however I don't think this pertains to my problem.

The example I'll show below is obviously not a xib problem, and prior times getting SIGABRT seemed more to do with unhandled exceptions. I have tried using GDB's bt but this does not help. Is there not a more comprehensive dump to view? I have also used NSZombie, but I really don't understand how to use it, so if that is your answer, please provide a link to documentation on how I'm supposed to get relevant data from it.

Here's my example: I'm trying to use Core Data. My project was not originally set up with it, so I have had to manually add it, which I did by going to my project>Build Phases>Link Binary with Libraries>clicking the plus and adding CoreData.framework

Then I created my data model by going to File>New>Data Model. I created quite a few attributes and that's it

After that, I added the proper methods to the app delegate (I did this by creating a new project with Core Data, then copying the methods over):

//code removed, as its not needed for the question/answer 

After this I just tried to save a value to the managed object (once again, code copied from the default implementation with a new project):

//code removed, as its not needed for the question/answer 

But all I get when I execute the addTime method is the SIGABRT error.

xcode error

like image 699
owen gerig Avatar asked Nov 09 '11 21:11

owen gerig


People also ask

What triggers SIGABRT?

SIGABRT errors are caused by your program aborting due to a fatal error. In C++, this is normally due to an assert statement in C++ not returning true, but some STL elements can generate this if they try to store too much memory.

How do you debug a SIGABRT?

For SIGABRT errors, run in debug until the program crashes. Then, there should be a little black button with the text "GDB" in yellow over it above your code editor in your mini-debugging bar. Click it, and it will bring up your debugger console.

What is SIGABRT signal?

Signal 5 ( SIGTRAP ) = “General crash” Signal 6 ( SIGABRT ) = SIGABRT is commonly used by libc and other libraries to abort the program in case of critical errors. For example, glibc sends an SIGABRT in case of a detected double-free or other heap corruptions.

What is a SIGABRT error?

A SIGABRT (signal abort) error means that the app was deliberately crashed due to some really bad problem, like a runtime error during the start-up sequence or a bad or unreadable user interface file.


1 Answers

SIGABRT rises when an object receives unimplemented message. How many warnings does your app have? Try surfing through them and find the ones that warn you "some object may not respond to some selector", if you clean your app from all of these, you'll most probably get it working correctly.

EDIT: Answer from comments below which are very helpful:

ok, here goes heavy artillery - have you tried using breakpoints? Open the sixth tab in your project explorer, in the bottom left corner tap + -> Add exception breakpoint -> Done. This will add an exception handler that will stop your app on the very method call that crashes the app.

EDIT: As of xCode 5.0 > You no longer need to specify which exception is your breakpoint is going to catch while the breakpoint is being created. You just need to hit + -> Add exception breakpoint and you're good.

enter image description here

like image 119
Eugene Avatar answered Sep 23 '22 08:09

Eugene