This module dumps the lua stack if the server segfaults.
It also allows you to define a crash handler in lua able to inspect the stack and write to the dump file.
Read lua/gcrash.lua for information on function behavior.
The dump format is a simple text file containing a stack trace and any extra data generated by the crash handler. Dump files are saved under garrysmod/gcrash/ with a name containing the date and time of the crash.
Update on x64 Builds for GCrash Testing the x64 builds on Linux proved to be unstable and resulted in random crashes. As a result, I've decided to simplify the x64 version of GCrash to focus solely on the Watchdog feature (freeze/hang detection and auto-restart).
As of 2025, Garry's Mod now supports dumping its state to text files. While this feature isn't as comprehensive as GCrash's stack dumps, it helps retain useful information. Additionally, Garry's Mod offers a console buffer for error logs, which can provide further insights in case of crashes.
With this in mind, I've removed the full GCrash functionality from the x64 build and kept only the infinite loop and server freeze detection, with automatic restart. This change is aimed at improving stability for x64 servers.
Please note that if you're re-compiling, you’ll need to adjust the source files accordingly. The x86 version will remain unchanged and retain all previous features.
Get the released (or build from source) gmsv_gcrash_linux.dll and put it in
SERVER_ROOT/garrysmod/lua/bin/, You may have to create the bin folder.
If you want to use the default lua handler, you can put gcrash.lua in lua/autorun/server/.
If you wish to build the module yourself, the build files are included in this repo.
- Get
premake5and place it next toBuildProjects.bat - Acquire an up-to-date version of
lua_shared.soand copy it tolibs/garrysmod/bin(32 bit) orlibs/bin/linux64(64 bit) - Run
premake5 --os=linux gmake2 - CD into
projects/linux/ makeoptionally withconfig=(debug|release|debug64|release64)- Output is
build/gmsv_gcrash_linux.dllorbuild/gmsv_gcrash_linux64.dll(the makefile renames the created .so to the GMod module format)
Windows is not yet supported.
- Improve the default lua handler