lua

A copy of the Lua development repository
Log | Files | Refs | README

commit d28265256110a0c5437247d443ddedc2a7aab116
parent 58216600eba27d472de33dbb89e2f3e629bf8a59
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Sun,  8 Nov 2020 11:51:59 -0300

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.)

Diffstat:
Mldo.c | 2+-
Mlgc.c | 4++--
Mlstate.c | 2+-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ldo.c b/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; diff --git a/lgc.c b/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 */ diff --git a/lstate.c b/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;