Understanding an assertion failure in a crash log

Last night my iPhone game crashed while running in debug mode on my iPhone. I just plugged it into my Mac, and was able to find the ips file. The stack trace shows the function in my app where it crashed, and then a couple of frames in libswiftCore.dylib before an assertion failure.

My question is - I've got absolutely no idea what the assertion failure actually was, all I have is...

0   libswiftCore.dylib 0x1921412a0 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 228
1   libswiftCore.dylib  0x192141178 closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 327
2   libswiftCore.dylib 0x192140b4c _assertionFailure(_:_:file:line:flags:) + 183
3   MyGame.debug.dylib 0x104e52818 SentryBrain.takeTurn(actor:) + 1240
...

How do I figure out what the assertion failure was that triggered the crash? How do I figure out what line of code in takeTurn(...) triggered the failing assertion failure?

Answered by Developer Tools Engineer in 843380022

_assertionFailure() usually puts its error message, which includes a filename and line number, in the "Application Specific Information" section near the top of the crash log. You might want to check for information there.

Another thing that might help is to open the crash log with Xcode. If the debug info for that build of your game is available, the backtrace in the Debug Navigator may point to the specific line of the code that crashed.

If neither of those ideas helps, your best bet might be to run your game from Xcode and try to reproduce the crash while the debugger is attached.

The trace you provided doesn't convey the line number. For more information about how to parse a crash report, see Backtraces.

Frame 3 indicates that the crash was triggered from SentryBrain.takeTurn(actor:) + 1240, where 1240 is an address offset from takeTurn(actor:). Unless you know Swift compiler really well, it will be difficult to map the offset to the line number.

Frame 2 indicates a Swift language exception, a force unwrapping on an address that has nil value, for example.

You can probably start with finding the code paths in takeTurn(actor:) that force unwrap on an Optional type, and then checking if the value can be nil.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

_assertionFailure() usually puts its error message, which includes a filename and line number, in the "Application Specific Information" section near the top of the crash log. You might want to check for information there.

Another thing that might help is to open the crash log with Xcode. If the debug info for that build of your game is available, the backtrace in the Debug Navigator may point to the specific line of the code that crashed.

If neither of those ideas helps, your best bet might be to run your game from Xcode and try to reproduce the crash while the debugger is attached.

Understanding an assertion failure in a crash log
 
 
Q