Skip to content

Commit

Permalink
Bug: finalizers can be called with an invalid stack
Browse files Browse the repository at this point in the history
The call to 'checkstackGC' can run finalizers, which will find an
inconsistent CallInfo, as 'ci' is half updated at the point of call.
  • Loading branch information
roberto-ieru committed Dec 15, 2021
1 parent 066e0f9 commit cf613cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ldo.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
int fsize = p->maxstacksize; /* frame size */
int nfixparams = p->numparams;
int i;
checkstackGCp(L, fsize - delta, func);
ci->func -= delta; /* restore 'func' (if vararg) */
for (i = 0; i < narg1; i++) /* move down function and arguments */
setobjs2s(L, ci->func + i, func + i);
checkstackGC(L, fsize);
func = ci->func; /* moved-down function */
for (; narg1 <= nfixparams; narg1++)
setnilvalue(s2v(func + narg1)); /* complete missing arguments */
Expand Down

0 comments on commit cf613cd

Please sign in to comment.