Handmade Hero»Forums»Code
14 posts
Game Crash Handling
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
2559 posts / 2 projects
Game Crash Handling
Edited by Mārtiņš Možeiko on
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
Game Crash Handling
This is awesome and exactly what I was looking for. Thanks a lot mmozeiko!!