Handmade Hero » Forums » Code » Game Crash Handling
14 posts
#12132 Game Crash Handling
2 years ago

Hey guys,

I'm writing my own game and I've been trying to finalize the different platform layers that I have. In handmade hero, if something goes wrong in the win32 platform layer, we usually put a todo for logging. Now in a shipping game, we would probably want to display a message box with a error that tells the user what went wrong. But is there anything else we might want to do? Like would we want to capture the stack at the time of the crash and somehow send it to me (the developer) to later debug?
Mārtiņš Možeiko
1934 posts / 1 project
#12136 Game Crash Handling
2 years ago Edited by Mārtiņš Možeiko on June 6, 2017, 6:02 p.m.

What you want to capture at crash is not only call stack, but some other info too - like loaded modules, memory map and sometimes whole memory contents.

On Windows this can be done with Minidump: https://msdn.microsoft.com/en-us/...ary/windows/desktop/ms680369.aspx
You can call just one function (MiniDumpWriteDump) to write the dump file. When you will get it on your dev machine, you can open it into Visual Studio debugger and examine call stack, variable values, threads, loaded dll files and more - exactly same as you would be debugging live process (except you cannot step of course). The contents of minidump will contain whatever you specify at the time of creating dump file - https://msdn.microsoft.com/en-us/...ary/windows/desktop/ms680519.aspx.

There are actually nice ready to use solutions that will do this automatically and send dump file via e-mail or http upload. You just need to load one dll into your application at startup.
Google Breakpad: https://github.com/google/breakpad
CrashRpt: http://crashrpt.sourceforge.net/
14 posts
#12139 Game Crash Handling
2 years ago

This is awesome and exactly what I was looking for. Thanks a lot mmozeiko!!