mirror of
https://github.com/lua/lua
synced 2024-12-29 13:49:44 +03:00
Bug when growing a stack
When a stack grows, its extra area can be in use, and it becomes part of the common area. So, the extra area must be kept correct all the times. (Bug introduced by commit 5aa36e894f5.)
This commit is contained in:
parent
58216600eb
commit
d282652561
2
ldo.c
2
ldo.c
@ -192,7 +192,7 @@ int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) {
|
||||
else return 0; /* do not raise an error */
|
||||
}
|
||||
for (; lim < newsize; lim++)
|
||||
setnilvalue(s2v(newstack + lim)); /* erase new segment */
|
||||
setnilvalue(s2v(newstack + lim + EXTRA_STACK)); /* erase new segment */
|
||||
correctstack(L, L->stack, newstack);
|
||||
L->stack = newstack;
|
||||
L->stack_last = L->stack + newsize;
|
||||
|
4
lgc.c
4
lgc.c
@ -632,8 +632,8 @@ static int traversethread (global_State *g, lua_State *th) {
|
||||
for (uv = th->openupval; uv != NULL; uv = uv->u.open.next)
|
||||
markobject(g, uv); /* open upvalues cannot be collected */
|
||||
if (g->gcstate == GCSatomic) { /* final traversal? */
|
||||
for (; o < th->stack_last; o++) /* clear not-marked stack slice */
|
||||
setnilvalue(s2v(o));
|
||||
for (; o < th->stack_last + EXTRA_STACK; o++)
|
||||
setnilvalue(s2v(o)); /* clear dead stack slice */
|
||||
/* 'remarkupvals' may have removed thread from 'twups' list */
|
||||
if (!isintwups(th) && th->openupval != NULL) {
|
||||
th->twups = g->twups; /* link it back to the list */
|
||||
|
2
lstate.c
2
lstate.c
@ -181,7 +181,7 @@ static void stack_init (lua_State *L1, lua_State *L) {
|
||||
int i; CallInfo *ci;
|
||||
/* initialize stack array */
|
||||
L1->stack = luaM_newvector(L, BASIC_STACK_SIZE + EXTRA_STACK, StackValue);
|
||||
for (i = 0; i < BASIC_STACK_SIZE; i++)
|
||||
for (i = 0; i < BASIC_STACK_SIZE + EXTRA_STACK; i++)
|
||||
setnilvalue(s2v(L1->stack + i)); /* erase new stack */
|
||||
L1->top = L1->stack;
|
||||
L1->stack_last = L1->stack + BASIC_STACK_SIZE;
|
||||
|
Loading…
Reference in New Issue
Block a user