Add a Byond OOM check

This commit is contained in:
CHOMPStation2
2020-07-18 20:04:09 -07:00
committed by GitHub
parent 7410fde395
commit a80cc3b74c

View File

@@ -7,12 +7,29 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
// The ifdef needs to be down here, since the error viewer references total_runtimes // The ifdef needs to be down here, since the error viewer references total_runtimes
#ifdef DEBUG #ifdef DEBUG
/world/Error(var/exception/e, var/datum/e_src) /world/Error(var/exception/e, var/datum/e_src)
GLOB.total_runtimes++ //CHOMPEdit just moving this here to start counting right away
if(!istype(e)) // Something threw an unusual exception if(!istype(e)) // Something threw an unusual exception
log_error("\[[time_stamp()]] Uncaught exception: [e]") log_error("\[[time_stamp()]] Uncaught exception: [e]")
return ..() return ..()
//CHOMP Edit Stealing this bit from TGS to try to record OOM issues.
//this is snowflake because of a byond bug (ID:2306577), do not attempt to call non-builtin procs in this if
if(copytext(E.name,1,32) == "Maximum recursion level reached")
//log to world while intentionally triggering the byond bug.
log_world("runtime error: [E.name]\n[E.desc]")
//if we got to here without silently ending, the byond bug has been fixed.
log_world("The bug with recursion runtimes has been fixed. Please remove the snowflake check from world/Error in [__FILE__]:[__LINE__]")
return //this will never happen.
else if(copytext(E.name,1,18) == "Out of resources!")
log_world("BYOND out of memory.")
log_game("BYOND out of memory.")
return ..()
//CHOMP Edit end
if(!GLOB.error_last_seen) // A runtime is occurring too early in start-up initialization if(!GLOB.error_last_seen) // A runtime is occurring too early in start-up initialization
return ..() return ..()
GLOB.total_runtimes++
var/erroruid = "[e.file][e.line]" var/erroruid = "[e.file][e.line]"
var/last_seen = GLOB.error_last_seen[erroruid] var/last_seen = GLOB.error_last_seen[erroruid]
@@ -115,4 +132,4 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
else else
e.desc = " [extra_info]\n\n" + e.desc e.desc = " [extra_info]\n\n" + e.desc
world.Error(e, e_src) world.Error(e, e_src)