SyntaxBomb - Indie Coders

Languages & Coding => BlitzMax / BlitzMax NG => Topic started by: wookie22 on November 12, 2020, 14:10:51

Title: Can bmx app generate crash report?
Post by: wookie22 on November 12, 2020, 14:10:51
If yes, how? I mean if I give my app to someone and he got crash.
Title: Re: Can bmx app generate crash report?
Post by: Matty on November 12, 2020, 16:25:02
Almost every command that can be responsible for a crash can be caught before it does so with good design.

If an image handle fails to load for example you can catch this at the point of load.

If a division by zero error can occur then its possible to test the denominator first.

If an array index goes out of bounds you can test the value of the index first.

If an object is null unexpectedly you can check for that too.

In theory crashes should never happen with good design.  And areas where failure might occur can be tested and dealt with.

Title: Re: Can bmx app generate crash report?
Post by: wookie22 on November 12, 2020, 17:12:13
It is not that simple. The game code is quite big, it would be hard to add try/catch to every part of it. Thing is that 99% don't have a problem but that 1% have and I cannot reproduce it.
Title: Re: Can bmx app generate crash report?
Post by: Matty on November 12, 2020, 18:56:06
Well the next best thing if you can't do that is this:

In a separate thread do the following:
Open a file for appending.
Every key block of code in your main loop send a signal to the other thread to write a comment to the text file.
When the user's game crashes ask for the text file back.
Note you have to open close and reopen the file to ensure it exists on crash.
Potentially write key debug info to the file about the current game state.
When you get the text file back you will see the last state before crash.

It might help locate the error and conditions.
Title: Re: Can bmx app generate crash report?
Post by: wookie22 on November 16, 2020, 14:29:29
Thanks, I will try this
Title: Re: Can bmx app generate crash report?
Post by: Derron on November 17, 2020, 09:13:28
Compile with "gdb" information ... and run the exe through "gdb" (provided by MinGW packages)

For linux I have this shell script which I let bmk execute (modified bmk) when I experience random segfaults the blitzmax debugger does not catch (so something in the C code):

Code (Blitzmax) Select

#!/bin/bash
ulimit -c unlimited
"$@"
if [[ $? -eq 139 ]]; then
BASEDIR=$(dirname "$0")
    gdb -q $1 core -x "$BASEDIR/segfaultwrapper_gdbcommands.txt"
fi


Code (txt) Select

backtrace
quit


Maybe you could simply provide something similar as "debug.bat" together with a "gdb.exe" (dunno if it has any dependencies ...).


You might be able to output the backtrace into a file.

bye
Ron