@@ -8,6 +8,37 @@ var/global/regex/actual_error_file_line
88 log_world (" \[ [ time_stamp()] ] Uncaught exception: [ E] " )
99 return .. ()
1010
11+ // this is snowflake because of a byond bug (ID:2306577), do not attempt to call non-builtin procs in this block OR BEFORE IT
12+ if (copytext(E. name, 1 , 32 ) == " Maximum recursion level reached" )// 32 == length() of that string + 1
13+ var /list /proc_path_to_count = list ()
14+ var /crashed = FALSE
15+ try
16+ var /callee/stack_entry = caller
17+ while (! isnull(stack_entry))
18+ proc_path_to_count[stack_entry. proc ] += 1
19+ stack_entry = stack_entry. caller
20+ catch
21+ // union job. avoids crashing the stack again
22+ // I just do not trust this construct to work reliably
23+ crashed = TRUE
24+
25+ var /list /split = splittext(E. desc, " \n " )
26+ for (var /i in 1 to split. len)
27+ if (split[i] != " " || copytext(split[1 ], 1 , 2 ) != " " )
28+ split[i] = " [ split[i]] "
29+ split += " --Stack Info [ crashed ? " (Crashed, may be missing info)" : " " ] :"
30+ for (var /path in proc_path_to_count)
31+ split += " [ path] = [ proc_path_to_count[path]] "
32+ E. desc = jointext(split, " \n " )
33+ // expanding the first line of log_world to avoid hitting the stack limit again
34+ to_file (world . log, " \[ [ time2text(station_time_in_ticks, " hh:mm:ss" )] ] Runtime Error: [ E. name] \n [ E. desc] " )
35+ // log to world while intentionally triggering the byond bug. this does not DO anything, it just errors
36+ // (seemingly because of the extra proc call to logger inside log_world interestingly enough)
37+ log_world (" runtime error: [ E. name] \n [ E. desc] " )
38+ // if we got to here without silently ending, the byond bug has been fixed.
39+ log_world (" The \" bug \" with recursion runtimes has been fixed. Please remove the snowflake check from world/Error in [ __FILE__ ] : [ __LINE__ ] " )
40+ return // this will never happen.
41+
1142 if (! global . actual_error_file_line)
1243 global . actual_error_file_line = regex(" ^%% (.*?),(.*?) %% " )
1344
0 commit comments