archive by month
Skip to content

thou shalt not divide by zero

Steamhammer is mostly reliable, but does crash occasionally. When SSCAIT catches a crash, it saves a couple of low-level dump files that offer a hope of tracing the cause.

Today I got a game with a division by zero crash, which was infuriating. Division by zero must die! Zero tolerance of zero! I decided to eliminate all bad divisions by inspecting every division “/” and mod “%” in the code, though it was a little tricky when the comment delimiter is “//” and “%” is used in strings.

	// don't even enter the same city as division by zero

I did it, and shored up a few weak spots. No direct division by zero should be possible in Steamhammer. I also added error checks in the hope of catching bad parameters before they are passed to BWAPI, which looks like the cause of other rare crashes that I have never been able to trace.

I tell the story as an example. If you want to write reliable software, you have to be thorough. I fix all reproducible crashes immediately, so that (so far) crashes on the server are unreproducible and difficult to solve, but I don’t let that stop me.

Trackbacks

No Trackbacks

Comments

LetaBot on :

Make sure to always check if the pointers are null as well. The replay page of the SSCAI ( http://www.sscaitournament.com/Replays/ ) also contains the error logs, and a lot of those errors are null pointers.

krasi0 on :

Good news!
Steamhammer is now the official reference as a foundation to code C++ based bots in: http://sscaitournament.com/index.php?action=tutorialCpp
Please let me know if any amendments to the text in the link should be made. Also, it'd be good to have something like a an easy to find ticketing system / issues tracker / points of contact, etc. for questions and feedback related to Steamhammer.
Keep up the good work! :)

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.