Like most other Lua binding libs, hlua runs into undefined behavior whenever a call to Lua raises a memory allocation error. The undefined behavior appears as a result of longjmping across Rust stack frames.
One solution is to provide the Lua state an allocation function which aborts on failure, preventing Lua from ever raising a memory allocation error. However, this prevents valid use cases, such as running Lua code in a sandbox with restricted memory use.
A better solution is to ensure that every call into Lua that may throw an error is wrapped in lua_pcall. This won't be easy
Like most other Lua binding libs, hlua runs into undefined behavior whenever a call to Lua raises a memory allocation error. The undefined behavior appears as a result of
longjmp
ing across Rust stack frames.One solution is to provide the Lua state an allocation function which aborts on failure, preventing Lua from ever raising a memory allocation error. However, this prevents valid use cases, such as running Lua code in a sandbox with restricted memory use.
A better solution is to ensure that every call into Lua that may throw an error is wrapped in
lua_pcall
. This won't be easy