Skip to content
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

enforce lua version compatibility #298

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

truemedian
Copy link
Member

A portion of Luvi code is embedded into the binary as bytecode. This poses an issue in builds with shared libluv (and therefore shared luajit) where the version of Lua(JIT) used to compile Luvi may be different from the version present on the target machine.

Both LuaJIT and PUC Lua 5.2 provide mechanisms to emit an error when this occurs. In PUC Lua this is done via luaL_checkversion(L) which throws a Lua error when it fails. We call this as soon as we create a new state to ensure that the error is fatal.

In LuaJIT this is done via an exported symbol LUAJIT_VERSION_SYM that matches the version of LuaJIT during compilation. The dynamic loader will fail if this symbol cannot be found in the LuaJIT dynamic library.

These checks happen on a best effort basis: some distributions (like Ubuntu) use patched versions of LuaJIT that is missing LUAJIT_VERSION_SYM, and luaL_checkversion(L) was implemented in 5.2, and as such is missing in 5.1.

@SinisterRectus SinisterRectus merged commit 32b274b into luvit:master Oct 8, 2024
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants