lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Dec 18, 2018 at 6:21 PM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:

> Lua avoids stack overflows by counting the number of recursive callsit makes. The constant LUAI_MAXCCALLS sets this limit, but it is hard to find the "perfect" value for each system.

On many systems the Lua host can control the stack size of each thread it creates, so it might be rather small and indeterminate at the compile time. Even if the amount of the stack space used by Lua itself is carefully controlled, no such control (by Lua) is possible if C functions (of the host or third party libs) are called.

So I am afraid there is no way to avoid stack overflows without imposing some constraints on the execution environment, which may end up being quite arcane.

Cheers,
V.