Mirror of the LuaJIT git repository
Go to file
Igor Munkin d969cb9c31
Prevent Lua VM re-entry through JIT trace.
JIT recording semantics assumes FFI calls are leaf regarding the LuaJIT
VM: if the execution exited Lua world through FFI machinery it is not
re-entering Lua world again.

However, there is a way to break this assumption via FFI: one can
re-enter LuaJIT VM via Lua C API used within the particular C routine
called via FFI. As a result the following host stack mix is created:
| Lua-FFI -> C routine -> Lua-C API -> Lua VM

This sort of re-entrancy is not supported by LuaJIT tracing compiler.
@mraleph named such kind of the call stack an "FFI sandwich" in the
tarantool/tarantool#4427.

This changeset introduces the mechanism for Lua-C API callbacks similar
to the one implemented for Lua-FFI: trace recording is aborted when the
execution re-enters LuaJIT VM. If re-enter is detected while running the
particular mcode, the runtime finishes its execution with EXIT_FAILURE
code and calls panic routine prior to the exit.

Co-authored-by: Vyacheslav Egorov <vegorov@google.com>
Co-authored-by: Sergey Ostanevich <sergos@tarantool.org>
Signed-off-by: Igor Munkin <imun@cpan.org>
2024-02-21 19:30:34 +03:00
doc Merge branch 'master' into v2.1 2024-01-26 23:18:02 +01:00
dynasm DynASM/x86: Add endbr instruction. 2024-01-22 19:17:45 +01:00
etc Merge branch 'master' into v2.1 2023-08-21 03:18:35 +02:00
src Prevent Lua VM re-entry through JIT trace. 2024-02-21 19:30:34 +03:00
.gitattributes Add .gitattributes to dynamically resolve .relver. 2023-08-22 15:30:27 +02:00
.gitignore RELEASE LuaJIT-2.0.0-beta1 2009-12-08 19:46:35 +01:00
.relver Add .gitattributes to dynamically resolve .relver. 2023-08-22 15:30:27 +02:00
COPYRIGHT Bump copyright date. 2023-08-20 21:25:30 +02:00
Makefile Fix typo. 2023-08-22 17:06:34 +02:00
README Merge branch 'master' into v2.1 2023-08-21 02:38:56 +02:00

README for LuaJIT 2.1
---------------------

LuaJIT is a Just-In-Time (JIT) compiler for the Lua programming language.

Project Homepage: https://luajit.org/

LuaJIT is Copyright (C) 2005-2023 Mike Pall.
LuaJIT is free software, released under the MIT license.
See full Copyright Notice in the COPYRIGHT file or in luajit.h.

Documentation for LuaJIT is available in HTML format.
Please point your favorite browser to:

 doc/luajit.html