Fixed bug for emergency collection in upvalue creation
When creating an upvalue, an emergency collection can collect the previous upvalue where the new one would be linked. The following code can trigger the bug, using valgrind on Lua compiled with the -DHARDMEMTESTS option: local x; local y (function () return y end)(); (function () return x end)()
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? */
|
||||
ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
|
||||
luaF_setupval(L, base + uv[i].idx, &ncl->upvals[i]);
|
||||
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