Warning
HERE BE DRAGONS
VERY EXPERIMENTAL (and old) Garry's Mod server binary module for crash signal handling and debugging. Used on Metastruct and partner servers for past ~10 years for the (very frequent) crash reason debugging.
Catches fatal signals (SIGSEGV, SIGABRT, SIGBUS, SIGILL, SIGQUIT, SIGHUP, SIGUSR1, SIGUSR2) and dumps:
- Signal info and fault address
- CPU register state
- C++ backtrace via libunwind (with demangled symbols)
- Lua stack trace and stack contents
- Thread crash detection
Example crash dump: example_crash.log
Also includes:
- physics crash mitigation (requires additional cursed stuff)
Custom signals to send to SRCDS
- SIGUSR1: Lua watchdog to break infinite loops
- SIGUSR2: to dump manually.
Crash log is written to $PWD/logs/<timestamp>.log with a symlink at logs/latest.log.
Build
- Install premake
- Install dependencies
apt-get install libunwind-dev binutils-dev liblzma-dev build-essential
- Copy this repo inside the gbins alongside all the other binary modules (or really just rewrite build, please)
Install
- Put
gmsv_segfault_linux.dllintogarrysmod/lua/bin/(there is a precompiled version in Releases). - install autorun lua to server.
-
Debug builds (
#define CRASH_DEBUG) register:Lua function C function Description docrashlua_dosegfaultTriggers a SIGSEGV docrash_stacklua_dostackTriggers a stack overflow docrash_nullptrlua_docrash_nullptrCalls through a null pointer docrash_threadlua_docrash_threadCrashes in a separate thread -
Originally extracted from gitlab.com/metastruct/internal/gbins (internal)
-
Depends on
gmsv_physframe_linux.dllfor stopping physics in a way that (sometimes) prevents further crashing to allow the occasional countdown while players can save their dupes.
Garry, Metastruct, FreezeBug, BlueShank, MetaMan, SpiralP, CapsAdmin, etc, etc etc