Skip to content

Draft: Limit memory and CPU usage for Lua scripts

Petr Mikheev requested to merge ptmikheev/openmw:lua_limits into master

Adds configurable limits for memory and CPU usage in Lua scripts.

So even

while true do end

in a script can not freeze the game.

But we have a problem. With default build options LuaJIT doesn't allow to pass a custom allocator. Lua 5.1 C API has such function, but in LuaJIT it returns an error if LuaJIT was built without GC64.

So we have the following options:

  1. Do not limit memory for Lua scripts.
  2. Compile LuaJIT with -DLUAJIT_ENABLE_GC64 and never use the LuaJIT provided by the system.
  3. Sacrifice performance and switch to mainstream Lua. In this case we can also upgrade to Lua 5.3 or Lua 5.4 and have benefits of new language features (it particular it would automatically resolve #6505 (closed)).

Merge request reports