- Joined
- Feb 14, 2015
- Messages
- 5,641
- Solutions
- 559
- Reaction score
- 3,966
put this code in a lib file (global.lua if tfs 1.x):
example output:
reason: i forced this infinite loop to hang server
if this script is producing false positives, change linecount >= 30000 to linecount >= 1000000, there should be no way other than an infinite loop to produce 1,000,000 line executions in 1 second
LUA:
local start = os.time()
local linecount = 0
debug.sethook(function(event, line)
linecount = linecount + 1
if os.time() - start >= 1 then
if linecount >= 30000 then
print(string.format("possible infinite loop in file %s near line %s", debug.getinfo(2).source, line))
debug.sethook()
end
linecount = 0
start = os.time()
end
end, "l")
example output:
Code:
possible infinite loop in file @data/global.lua near line 83
reason: i forced this infinite loop to hang server
LUA:
local i = 1
while true do
i = i + 1
end
if this script is producing false positives, change linecount >= 30000 to linecount >= 1000000, there should be no way other than an infinite loop to produce 1,000,000 line executions in 1 second
Last edited: