From e37b96db04b373f79661357e18a061186ceb8e5e Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 13 Jul 2020 16:35:32 -0300 Subject: Bug fix: Errors in finalizers need a valid 'pc' Errors in finalizers need a valid 'pc' to produce an error message, even if the error is not propagated. Therefore, calls to the GC (which may call finalizers) inside luaV_execute must save the 'pc'. --- lvm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lvm.c b/lvm.c index e7781dbf..a2692c2c 100644 --- a/lvm.c +++ b/lvm.c @@ -1104,7 +1104,7 @@ void luaV_finishOp (lua_State *L) { #define checkGC(L,c) \ - { luaC_condGC(L, L->top = (c), /* limit of live values */ \ + { luaC_condGC(L, (savepc(L), L->top = (c)), \ updatetrap(ci)); \ luai_threadyield(L); } @@ -1792,8 +1792,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { vmbreak; } vmcase(OP_VARARGPREP) { - luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p); - updatetrap(ci); + ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p)); if (trap) { luaD_hookcall(L, ci); L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */ -- cgit v1.2.1