[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Restricted parsing for static config files / more granular `load()` options for 5.4
- From: Martin <eden_martin_fuhrspam@...>
- Date: Mon, 13 Mar 2017 00:44:05 -0700
On 03/12/2017 12:16 PM, Rain Gloom wrote:
> The biggest problem that simple _ENV sandboxing can't avoid is
> infinitely long running code, one would need either the debug library to
> block a script after N instructions or use their own parser.
It is possible to have infinitely running code without recursions.
It's because code can create new functions and call them.
Here is an example:
local create_func =
return function() return body() end
local a = 0
a = a + 1
inc_counter = create_func(inc_counter)
local g = create_func(inc_counter)
You can see that each time new function is executed. And there is
no stack overflow due "tail recursion optimization". So this code
theoretically will run forever.