[Tarantool-patches] [PATCH luajit 1/2] Fix lua_yield() from C hook.

Igor Munkin imun at tarantool.org
Sat Jul 1 14:44:16 MSK 2023


Sergey,

Thanks for the patch! LGTM, considering the fixes for the comments left
by Max.

On 22.06.23, Sergey Kaplun wrote:
> From: Mike Pall <mike>
> 
> Reported by Jason Carr.
> 
> (cherry picked from commit dd5032ed844c56964347c7916db66b0eb11d8091)
> 
> When we call `lua_yield()` from the C hook the additional continuation
> frame is added. This frame contains a continuation function, PC where we
> should return, thread GC object to continue, and this frame type and
> size (see details in <src/lj_frame.h>). For non-GC64 mode, when we set
> the GC thread on the Lua stack, stack top isn't incremented, so the GC
> thread overwrites the PC to return. For the GC64 mode the increment is
> missing before setting frame type and size.
> 
> This patches fixes the behaviour by adding missing slot incrementing.
> Also, it hardens the conditions of using `lj_err_throw()`, according the
> availability of external unwinder.
> 
> The behaviour for the GC64 mode is still wrong due to miscalculation of
> the slot of the GC thread object. This will be fixed in the next
> commit.
> 
> Sergey Kaplun:
> * added the description and the test for the problem
> 
> Part of tarantool/tarantool#8516
> ---
>  src/lj_api.c                                  |  5 +-
>  .../fix-yield-c-hook-script.lua               | 19 +++++++
>  .../tarantool-c-tests/fix-yield-c-hook.test.c | 53 +++++++++++++++++++
>  3 files changed, 75 insertions(+), 2 deletions(-)
>  create mode 100644 test/tarantool-c-tests/fix-yield-c-hook-script.lua
>  create mode 100644 test/tarantool-c-tests/fix-yield-c-hook.test.c
> 

<snipped>

> -- 
> 2.34.1
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list