Crash Handler
What is Physgun Crash Handler
Physgun Crash Handler is a module of Physgun Utils that gives you the ability to get low level information about crashes, recover from them, and prevent them.
Some key notes:
- You can find the configuration file in the Physgun Utils tab on your game panel
- You can use the Lua API to greatly extend the ability's of the crash handler, default handlers will be released at a later date.
Features
- Detect Infinite Loops in Lua
- Detect Segmentation Faults
- Detect Lua Stack Over/Underflow
- Detect IVP Hangs
- Detect Crashes in external modules
- Recover From Crashes
- Crash Screen
Crash Recovery
The crash handler has the ability to rollback the game a few frames if a crash occurs, this can recover from Segfaults, Lua Loops, and more.
It is enabled by default, but can be replaced with the crash screen recovery method by adjusting the settings in the Physgun Utils tab.
Crash Screen
The crash screen is fully customizable via lua, it is located in lua/autorun/crashphys.lua
. To restore the default one, just delete the file.
The crash screen will automatically reconnect players when your server is fully back online after a crash that was detected by the crash handler.
Creating a custom Crash Screen
To create a custom crash screen, you can edit the file located in lua/autorun/crashphys.lua
.
Developer API Functions
PhysgunCrashHandler.RestartWithCrashScreen()
Restarts the server and dispatches the crashscreen payload to auto-reconnect players.PhysgunCrashHandler.SetIVPSimulationToggle(bool toggleState)
Toggles IVP simulation entirely, allows you to disable physics simulationPhysgunCrashHandler.GetIVPSimulationToggle() -> number
Returns the current toggle state of IVP simulationPhysgunCrashHandler.SetIVPUpdateInterval(number updateTime)
Sets how often to run a IVP simulation in seconds (default 0.01)PhysgunCrashHandler.GetIVPUpdateInterval() -> number
Returns the current IVP simulation time
Developer Hooks
Physgun:CrashHandler:RecoveredFromSegmentationFault
Called after the crash handler recovers the Lua state and engine from a segfault
hook.Add("Physgun:CrashHandler:RecoveredFromSegmentationFault", "HookID", function()
print("Recovered from segmentation fault")
-- your logic here
end)
Physgun:CrashHandler:RecoveredFromInfiniteLoop
Called after the crash handler recovers the Lua state and engine from a infinite loop
hook.Add("Physgun:CrashHandler:RecoveredFromInfiniteLoop", "HookID", function()
print("Recovered from infinite loop")
-- your logic here
end)
Physgun:CrashHandler:IVPSimulationTookLong
Called if IVP takes longer then30ms
for a single simulation
hook.Add("Physgun:CrashHandler:IVPSimulationTookLong", "HookID", function(time)
print("IVP Simulation took " .. time)
-- your logic here
end)
Updated on: 08/01/2024
Thank you!