Skip to content

Commit 31b8c2d

Browse files
committed
Fixed bug of access violation in finalizers
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'.
1 parent eb41999 commit 31b8c2d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lvm.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,9 +1101,9 @@ void luaV_finishOp (lua_State *L) {
11011101
/* idem, but without changing the stack */
11021102
#define halfProtectNT(exp) (savepc(L), (exp))
11031103

1104-
1104+
/* 'c' is the limit of live values in the stack */
11051105
#define checkGC(L,c) \
1106-
{ luaC_condGC(L, L->top = (c), /* limit of live values */ \
1106+
{ luaC_condGC(L, (savepc(L), L->top = (c)), \
11071107
updatetrap(ci)); \
11081108
luai_threadyield(L); }
11091109

@@ -1791,8 +1791,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
17911791
vmbreak;
17921792
}
17931793
vmcase(OP_VARARGPREP) {
1794-
luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p);
1795-
updatetrap(ci);
1794+
ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p));
17961795
if (trap) {
17971796
luaD_hookcall(L, ci);
17981797
L->oldpc = pc + 1; /* next opcode will be seen as a "new" line */

0 commit comments

Comments
 (0)