the LuaJIT binary cannot init properly, which prints
./buildroot/openresty/luajit/bin/luajit: cannot create state: not enough memory
(this can be reproduced every time)
and @dndx found if LUAJIT_USE_SYSMALLOC is enabled in that platform (which is enabled while adding --debug flag), system malloc function (realloc virtually) returns a address pointer, of which 47 bit is high, while LuaJIT uses this high bit to express some metadata so that this address failed to pass LuaJIT's address check. So, LuaJIT's solution (https://github.com/LuaJIT/LuaJIT/issues/49) is to use mmap which allow us to specific an address that high bits are zero.
So we removed DLUAJIT_USE_SYSMALLOC when the architecture is aarch64 to ensure LuaJIT get a legal address.
We (@dndx ) found that for every Mac M1 aarch64 device (running MacOS or Ubuntu) after building LuaJIT using command such as
the LuaJIT binary cannot init properly, which prints
(this can be reproduced every time)
and @dndx found if
LUAJIT_USE_SYSMALLOC
is enabled in that platform (which is enabled while adding--debug
flag), system malloc function (realloc
virtually) returns a address pointer, of which 47 bit is high, while LuaJIT uses this high bit to express some metadata so that this address failed to pass LuaJIT's address check. So, LuaJIT's solution (https://github.com/LuaJIT/LuaJIT/issues/49) is to usemmap
which allow us to specific an address that high bits are zero.So we removed
DLUAJIT_USE_SYSMALLOC
when the architecture isaarch64
to ensure LuaJIT get a legal address.