-
Notifications
You must be signed in to change notification settings - Fork 37
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
luajit light userdata incompatibility #223
Comments
What sort of variables can't be used? Should we be avoiding global vars? pointers to the stack? pointers as returned by |
Judging by the fact that it failed when requiring cqueues, it's probably pushing As I don't have access to an arm64 platform, could you verify the above by adding prints on either side of lua_pushlightuserdata(L, CQUEUE__POLL); |
Well, generally there's probably no guarantee which pointers get allocated too high. From aarch64 linux experience, stack is bad and static variables (inside C functions) are OK. I believe you're right that's the first place to violate the condition:
|
I think the memory layout ends up the same as on x86_64, only using (usually) 48 bits instead of 47. Notably I see that so-libs are placed on the high end – so the |
I'm not sure what to replace that code with.... a lightuserdata of Maybe for LuaJIT we should mask off the high bits? Would be a bit risky that a collision occurs. |
If it's just about collisions in the most common case when one bit is missing, I expect it's possible to hack around this without too much risk:
These hacks might even work luajit-wide... it's just about choosing a better part of the space to reject. |
@vcunat thoughts on https://github.com/Kong/openresty-patches/pull/47/files to (mostly) fix things from the luajit side? |
That sounds nice in principle. Still, any solution not accepted into luajit upstream might have a hard time getting into distributions, etc. I can't immediately see if this this couple lines fix everything; I don't know luajit internals. |
Chiming in here and happy to help the best I can (at least from the point of view of having seen this general problem before, and having seen it solved a couple of times). |
Closed via #225 |
This comment has been minimized.
This comment has been minimized.
Yes, let's continue on the newly open ticket. |
Typical test case: aarch64 running Linux configured with
ARM64_VA_BITS >= 48
Other platforms don't commonly run into this AFAIK, but on aarch64 this kernel configuration now seems to be typical. Note that upstream luajit seems very unlikely to fix this incompatibility (and it would probably be hard without caveats).
I don't know code internals of cqueues, so I can't guess how hard this will be, but I recently did this transformation for Knot Resolver codebase, so I might be able to help, though I'm typically overloaded with higher-priority work.
The text was updated successfully, but these errors were encountered: