How to debug signal SIGABRT

Home Forum Learning iPhone Game Development with Cocos2D 3.0 How to debug signal SIGABRT

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #295
    rolfchopper
    Participant

    To be a bit more specific I’m using the Kindle app and copying/pasting from it. It always adds a space before filenames ie:

    birdImageName = @” bird_small.png”;

    The above will break the app, the correct syntax is:

    birdImageName = @”bird_small.png”;

    #294
    rolfchopper
    Participant

    I found the error by adding the all exception breakpoint. I also read both of Ray’s posts, which were a bit above my head in areas but super helpful. So thank you!

    For anyone interested – I’ve been copying and pasting code from the book, which is resulting in odd line breaks and spaces. This was causing errors.

    Thanks for the help!

    #293
    Kirill Muzykov
    Keymaster

    Hi,

    First of all, the answer to the question on how to debug errors like this. There is a nice tutorial by Matthijs Hollemans on RayWenderlich.com on debugging iOS apps:
    http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
    http://www.raywenderlich.com/10505/my-app-crashed-now-what-part-2

    I strongly advise to read it, since it will save you many hours in the future. However, few most important things to do right now is:

    1. Add “All exceptions” breakpoint.
    Right now you only see exception on its final stop on the way out. To see the exact line causing this exception you need to add “All Exceptions” breakpoint, that will stop execution right when your game is only going to throw an exception.

    adding all exceptions breakpoint

    2. Decompress the thread list
    By default Xcode compresses the stack trace of exception, removing intermediate function calls, which Xcode finds unimportant. However, they can be important to developers. So it is always better to make sure you see the full stack.

    Seeing full stack trace in Xcode

    3. Find the place in your code causing the exception.
    High chances that the code that you wrote yourself is not throwing an exception. In most cases it is thrown by some internal function of cocos2d which you call indirectly.

    Here is an example:

    I’ve modified the code to cause an exception (passing nil as image name). This is what you will see when Xcode will stop (because of “All Exceptions” breakpoint).

    finding place in your code caused the exception

    As you can see Xcode shows the line that throws the exception and full stack trace. However, this line is not in your code. The line that throws exception is an internal line of Cocos2D that checks that the image name must be non nil.

    There is only a small portion of your code in the stack trace (marked in green). So to see the line of your code that causing the exception you should check methods in the stack trace that you wrote. Since there is a very low chance that the error is in iOS system code or Cocos2D code (marked in Red).

    To do this. You select the last of your methods executed before the exception. Most likely the code causing the exception is in this method. I say most likely, because, maybe, you’ve passed incorrect parameter to your method which just passed it to Cocos2D, so you should fix the original caller method instead.

    Now you can see the line in the code you wrote that causes the exception. In this case I’ve intentionally passed nil as image name to get the exception.

    4. Pay attention to console output.
    Cocos2D logs errors and warnings in the console. So even if you don’t get the exception you might see a warning that some image was not found or other warnings.

    5. Compare you code with the one that comes with the book
    If you just can’t find the code causing the error you might compare your code with the code that comes with the book. When learning programming and can’t find where the bug is I’ve used following technique.

    I’ve replaced my code with the code from the book, but saved my code somewhere. Then I checked that everything works and replaced the working code method by method with my code until I get the error. When I get it I’ve compared methods line by line or even symbol by symbol and found what causing errors.

    If the method is big I might even replaced half of the method with my code, checked and then replaced the other half, or even line by line (actually did this once, and found that the error was I’ve put Russian “o” instead of English “o” in the file name and that caused error which I wasn’t able to find by only reviewing the code).

    Hope it helps you to find your bug!

    #287
    rolfchopper
    Participant

    I’ve gotten a “signal SIGABRT” when trying to build my app on a few different occasions. Screen shot of the current one is from the “Time for action — adding the player character” section of the book.

    In general how do I debug this error and specifically where should I poke around to investigate this time?

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Learning iPhone Game Development with Cocos2D 3.0’ is closed to new topics and replies.