Fixed some bugs around stack reallocation
Long time without using HARDSTACKTESTS...
This commit is contained in:
1
lapi.c
1
lapi.c
@@ -207,6 +207,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) {
|
|||||||
uplevel(L->openupval) == level,
|
uplevel(L->openupval) == level,
|
||||||
"no variable to close at given level");
|
"no variable to close at given level");
|
||||||
luaF_close(L, level, CLOSEKTOP, 0);
|
luaF_close(L, level, CLOSEKTOP, 0);
|
||||||
|
level = index2stack(L, idx); /* stack may be moved */
|
||||||
setnilvalue(s2v(level));
|
setnilvalue(s2v(level));
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
}
|
}
|
||||||
|
|||||||
2
ldo.c
2
ldo.c
@@ -412,12 +412,12 @@ static void moveresults (lua_State *L, StkId res, int nres, int wanted) {
|
|||||||
if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */
|
if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */
|
||||||
ptrdiff_t savedres = savestack(L, res);
|
ptrdiff_t savedres = savestack(L, res);
|
||||||
luaF_close(L, res, CLOSEKTOP, 0); /* may change the stack */
|
luaF_close(L, res, CLOSEKTOP, 0); /* may change the stack */
|
||||||
res = restorestack(L, savedres);
|
|
||||||
wanted = codeNresults(wanted); /* correct value */
|
wanted = codeNresults(wanted); /* correct value */
|
||||||
if (wanted == LUA_MULTRET)
|
if (wanted == LUA_MULTRET)
|
||||||
wanted = nres;
|
wanted = nres;
|
||||||
if (L->hookmask) /* if needed, call hook after '__close's */
|
if (L->hookmask) /* if needed, call hook after '__close's */
|
||||||
rethook(L, L->ci, nres);
|
rethook(L, L->ci, nres);
|
||||||
|
res = restorestack(L, savedres); /* close and hook can move stack */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
2
lfunc.c
2
lfunc.c
@@ -190,9 +190,11 @@ void luaF_close (lua_State *L, StkId level, int status, int yy) {
|
|||||||
UpVal *uv;
|
UpVal *uv;
|
||||||
StkId upl; /* stack index pointed by 'uv' */
|
StkId upl; /* stack index pointed by 'uv' */
|
||||||
if (unlikely(status == LUA_ERRMEM && L->ptbc != NULL)) {
|
if (unlikely(status == LUA_ERRMEM && L->ptbc != NULL)) {
|
||||||
|
ptrdiff_t levelrel = savestack(L, level);
|
||||||
upl = L->ptbc;
|
upl = L->ptbc;
|
||||||
L->ptbc = NULL; /* remove from "list" before closing */
|
L->ptbc = NULL; /* remove from "list" before closing */
|
||||||
prepcallclosemth(L, upl, status, yy);
|
prepcallclosemth(L, upl, status, yy);
|
||||||
|
level = restorestack(L, levelrel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lua_assert(L->ptbc == NULL); /* must be empty for other status */
|
lua_assert(L->ptbc == NULL); /* must be empty for other status */
|
||||||
|
|||||||
2
lvm.c
2
lvm.c
@@ -1150,6 +1150,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
|
|||||||
Instruction i; /* instruction being executed */
|
Instruction i; /* instruction being executed */
|
||||||
StkId ra; /* instruction's A register */
|
StkId ra; /* instruction's A register */
|
||||||
vmfetch();
|
vmfetch();
|
||||||
|
// low-level line tracing for debugging Lua
|
||||||
|
// printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
|
||||||
lua_assert(base == ci->func + 1);
|
lua_assert(base == ci->func + 1);
|
||||||
lua_assert(base <= L->top && L->top < L->stack_last);
|
lua_assert(base <= L->top && L->top < L->stack_last);
|
||||||
/* invalidate top for instructions not expecting it */
|
/* invalidate top for instructions not expecting it */
|
||||||
|
|||||||
Reference in New Issue
Block a user