[Question]Why luajit feature not support memory_limit
Related code: https://github.com/khvzak/mlua/blob/cfb5d3fd45a810e5cde6811b039d154241d1444c/src/lua.rs#L332-L399
fn allocator include luajit feature, but it is not used when new lua state.
It's quite interesting question.
Mostly because In Lua 5.1/JIT lua_pushcfunction api call can trigger memory errors. Our protection mechanism to intercept Lua exceptions heavy relies on resilient lua_pushcfunction call. There is a way how to fail it and trigger uncought exception that would crash the program -- is enable memory limits for 5.1/JIT.
In Lua >= 5.2 this function never triggers memory errors.
Unfortunately I don't see a simple way how to enable memory limits in Lua 5.1/JIT 🤔
Thank you for your reply.
It's a little complicated for me, maybe I should use unsafe rust to call luajit c api directly😢
maybe I should use unsafe rust to call luajit c api directly
it does not matter actually, you would get crash unless wrap it to lua_cpcall.
I believe I found a good workaround, so memory limits will be supported for any Lua in v0.9