Do not collect open upvalues

Open upvalues are kept alive together with their corresponding
stack. This change makes a simpler and safer fix to the issue in
commit 440a5ee78c, about upvalues in the list of open upvalues
being collected while others are being created. (That previous fix
may not be correct.)
This commit is contained in:
Roberto Ierusalimschy
2019-07-22 09:41:10 -03:00
parent 2f22c6bb79
commit 9e6807c3c9
4 changed files with 11 additions and 14 deletions

6
lgc.c
View File

@@ -569,10 +569,8 @@ static int traversethread (global_State *g, lua_State *th) {
th->openupval == NULL || isintwups(th));
for (; o < th->top; o++) /* mark live elements in the stack */
markvalue(g, s2v(o));
for (uv = th->openupval; uv != NULL; uv = uv->u.open.next) {
if (uv->tbc) /* to be closed? */
markobject(g, uv); /* cannot be collected */
}
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? */
StkId lim = th->stack + th->stacksize; /* real end of stack */
for (; o < lim; o++) /* clear not-marked stack slice */