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:
2
lvm.c
2
lvm.c
@@ -697,7 +697,7 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
|
||||
setclLvalue2s(L, ra, ncl); /* anchor new closure in stack */
|
||||
for (i = 0; i < nup; i++) { /* fill in its upvalues */
|
||||
if (uv[i].instack) /* upvalue refers to local variable? */
|
||||
luaF_setupval(L, base + uv[i].idx, &ncl->upvals[i]);
|
||||
ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
|
||||
else /* get upvalue from enclosing function */
|
||||
ncl->upvals[i] = encup[uv[i].idx];
|
||||
luaC_objbarrier(L, ncl, ncl->upvals[i]);
|
||||
|
||||
Reference in New Issue
Block a user