Skip to content

Comments

enforce lua version compatibility#298

Merged
SinisterRectus merged 1 commit intoluvit:masterfrom
truemedian:version-compat
Oct 8, 2024
Merged

enforce lua version compatibility#298
SinisterRectus merged 1 commit intoluvit:masterfrom
truemedian:version-compat

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
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