|
> Nice idea with __gc !!!So, we are still in the game :-)
> But unfortunately, "memory usage limiter" fails to stop this simple
> malicious one-liner until all available memory has been exhausted:
>
> -- track memory use
> do
> -- maximum memory (in KB) that can be used
> local memlimit = 1000
> local mt = {__gc = function (u)
> if collectgarbage("count") > memlimit then
> error("script uses too much memory")
> else
> setmetatable({}, getmetatable(u))
> end
> end}
> setmetatable({}, mt)
> end
>
> -- memory eater
> local t={}; while t do t[#t+1] = t end
>
>
> Nevertheless, it will be stopped by "CPU usage limiter".
Anyway, one way to improve this sandbox is to check memory in function
'step', too.
-- Roberto