SyntaxBomb - Indie Coders

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

Title: Can bmx app generate crash report?
Post by: wookie22 on November 12, 2020, 02:10:51 PM
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, 04:25:02 PM
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, 05:12:13 PM
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, 06:56:06 PM
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, 02:29:29 PM
Thanks, I will try this
Title: Re: Can bmx app generate crash report?
Post by: Derron on November 17, 2020, 09:13:28 AM
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
  1. #!/bin/bash
  2. ulimit -c unlimited
  3. "$@"
  4. if [[ $? -eq 139 ]]; then
  5.         BASEDIR=$(dirname "$0")
  6.     gdb -q $1 core -x "$BASEDIR/segfaultwrapper_gdbcommands.txt"
  7. fi
  8.  

Code:  (Unknown Language)
  1. backtrace
  2. quit
  3.  

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
SimplePortal 2.3.6 © 2008-2014, SimplePortal