-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix lightud for 48bit virtual address #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Set 2 type values (~3 and ~4) to lightud type. It is enabled only for ARM64, whose kernel uses 48bit virtual address. Change-Id: I331eb1997af35c3ed63d6b15d6d59cfc5bc355e0
f686661
to
dc3bd16
Compare
This changeset is way too complex and probably incomplete. And it doesn't solve the general issue, e.g. for 52 bit VA spaces.
It's easy enough to work around the 47 bit limit. The Solaris/x64 community has had the same problem, due to their use of the negative part of the address space in user mode. Have a look what they did to change the (few) libraries that didn't play nicely:
|
Currently, we see crashes on 48-bit VA in at least :
I am afraid there will be too much work if we have to do the work around in the applications. Is it possible for us to treat lightuserdata differently and do not tag this type? |
Ignore the failure in The OpenResty author is pretty responsive. Just tell him the spots where There's not a single use of |
Thanks for your comment! |
@MikePall Can we put the limitation and the way of work around somewhere publicly on the LuaJIT website? So that it will be much easy for the users to fix the issue themselves. |
Will this work with |
Should fix problems with luajit+arm64. Fixes neovim#7879 Ref LuaJIT/LuaJIT#230
- mike: introduce emotion knob (on by default) E2K: avoid not-ported-yet BRs (libunwind, luajit) - disabled elua for aarch64 (LuaJIT/LuaJIT#230)
We can also store the address in string to solve this problem, although there will be some performance loss, but My workaround implementation: static __tb_inline__ tb_void_t xm_lua_pushpointer(lua_State* lua, tb_pointer_t ptr)
{
tb_uint64_t ptrval = (tb_uint64_t)ptr;
if ((ptrval >> 47) == 0)
lua_pushlightuserdata(lua, ptr);
else
{
tb_char_t str[64];
tb_long_t len = tb_snprintf(str, sizeof(str), "%p", ptr);
lua_pushlstring(lua, str, len);
}
} The full implmentation: |
The main point of a lightuserdata instead of a full userdata is that the allocation of one cannot fail ( |
Resolved in a different way. |
Current aarch64 (distro) kernels ship with CONFIG_ARM64_VA_BITS_48 enabled, see, e.g., [1] for Debian's kernel, resulting in a LuaJIT panic "bad light userdata pointer" on aarch64 with distro-packaged old(er) LuaJIT versions that limit lightuserdata to 47 bit pointers. One mitigation option is to use a kernel with less VA bits, ruling out using distro kernels untouched. Another mitigation is to use the latest LuaJIT as this issue has been resolved, see [2,3], ruling out using the (older) distro's LuaJIT package untouched -- until distros eventually catch up. Hence, to allow SWUpdate on systems with >47 bits VA to run on current distros' kernel and LuaJIT packages, replace lightuserdata with "full" userdata. For other systems with with <=47 bits VA, this change has no effect other than Lua's gc having to clean up the "full" userdata of sizeof(struct dict*) when it becomes unreferenced: For sw-description embedded scripts, this is happens after having interpreted sw-description. For a Lua handler, this happens at its next call as an explicit free and gc cycle call would occupy more permanent space. [1] https://salsa.debian.org/kernel-team/linux/-/blob/bullseye/debian/config/arm64/config#L13 [2] LuaJIT/LuaJIT#49 [3] LuaJIT/LuaJIT#230 Signed-off-by: Christian Storm <christian.storm@siemens.com> Signed-off-by: Michael Adler <michael.adler@siemens.com>
Set 2 type values (~3 and ~4) to lightud type. It is enabled only for
ARM64, whose kernel uses 48bit virtual address.
Change-Id: I331eb1997af35c3ed63d6b15d6d59cfc5bc355e0