How to debug a crash?

My app has a crash that is very hard to reproduce, but every round of user testing at least two or three users report it.

Today I managed to reproduce on my own =D

And there was no Lua error, only a crash, and a crash log generated on the iPad (I never managed to cause the bug to happen in neither Windows or Mac OS X… also my associate crashed once on the Android but we had no SDK installed and we are failing to do it again).

So, since the App is Corona generated it has no symbols, so how I debug a crash that give no errors, just a crash log? [import]uid: 142895 topic_id: 28816 reply_id: 328816[/import]

Well there are a few approaches.

First, once you narrow down the likely location put in a bunch of print statements and see where it’s crashing.

Next, the crash log should tell you some useful information like UI KIt crashed, ALMixer crashed, what thread. If you see the ALMixer thread crashed you can assume it’s an audio problem.

It should also give you a crash signal, like Bus Error (SIGBUS(, Segment Violation (SIGSEGV), Broken Pipe (SIGPIPE) and usually an address that it happened at.

Bus and segment violations are generally trying to access protected memory. Look at this bit of code:

[/code]
local function fred()
print(“barney”)
end

fred = 10

fred()
[/code]

In this case, we have errantly written over the variable name that holds our function. The last line tries to jump to fred’s location in memory and run the code there. Unfortunately, that address is now 10 instead of 0x28374833 (or whatever real memory location) and 10 isn’t a valid memory location and your system will generate a Bus error.

This would be considered a common cause of these errors. So the next bit of advice is to look at the common causes of these which include:

a timer trying to call a function that is no longer around. This happens a lot with with Director or StoryBoard based apps where you have scene files that you are loading and unloading …

So you have SceneA and SceneA fires off a timer, or a transition that calls a function when it’s done, or things like network.request(), audio.play() any thing that can call another function when it’s finished… The player hits a button that loads SceneB and SceneA is purged from memory. That timer is still set to fire and it tries to execute that call back function which isn’t around any more. SIGSEGV…

You basically have to dig through your code and try to isolate places where you didn’t cancel a timer, etc. before the module gets removed. [import]uid: 19626 topic_id: 28816 reply_id: 116109[/import]

Not much helpful that info :frowning:

I mean, those parts I already mostly knew…

It is a SIGFAULT on UIKit so kinda not much obvious. [import]uid: 142895 topic_id: 28816 reply_id: 117776[/import]