mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
open upvalues cannot be old if thread is not old; when thread is old,
their list is not traversed anymore, and therefore can contain dead elements.
This commit is contained in:
parent
fdae4b9453
commit
86b39206d9
4
lfunc.c
4
lfunc.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lfunc.c,v 2.28 2012/01/20 22:05:50 roberto Exp roberto $
|
** $Id: lfunc.c,v 2.29 2012/05/08 13:53:33 roberto Exp roberto $
|
||||||
** Auxiliary functions to manipulate prototypes and closures
|
** Auxiliary functions to manipulate prototypes and closures
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -52,12 +52,12 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
|
|||||||
while (*pp != NULL && (p = gco2uv(*pp))->v >= level) {
|
while (*pp != NULL && (p = gco2uv(*pp))->v >= level) {
|
||||||
GCObject *o = obj2gco(p);
|
GCObject *o = obj2gco(p);
|
||||||
lua_assert(p->v != &p->u.value);
|
lua_assert(p->v != &p->u.value);
|
||||||
|
lua_assert(!isold(o) || isold(obj2gco(L)));
|
||||||
if (p->v == level) { /* found a corresponding upvalue? */
|
if (p->v == level) { /* found a corresponding upvalue? */
|
||||||
if (isdead(g, o)) /* is it dead? */
|
if (isdead(g, o)) /* is it dead? */
|
||||||
changewhite(o); /* resurrect it */
|
changewhite(o); /* resurrect it */
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
resetoldbit(o); /* may create a newer upval after this one */
|
|
||||||
pp = &p->next;
|
pp = &p->next;
|
||||||
}
|
}
|
||||||
/* not found: create a new one */
|
/* not found: create a new one */
|
||||||
|
6
ltests.c
6
ltests.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 2.132 2012/07/04 15:52:38 roberto Exp roberto $
|
** $Id: ltests.c,v 2.133 2012/08/16 17:34:28 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -469,9 +469,7 @@ int lua_checkmemory (lua_State *L) {
|
|||||||
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
|
||||||
lua_assert(uv->v != &uv->u.value); /* must be open */
|
lua_assert(uv->v != &uv->u.value); /* must be open */
|
||||||
lua_assert(!isblack(obj2gco(uv))); /* open upvalues are never black */
|
lua_assert(!isblack(obj2gco(uv))); /* open upvalues are never black */
|
||||||
if (isdead(g, obj2gco(uv)))
|
if (!isdead(g, obj2gco(uv)))
|
||||||
lua_assert(issweepphase(g));
|
|
||||||
else
|
|
||||||
checkvalref(g, obj2gco(uv), uv->v);
|
checkvalref(g, obj2gco(uv), uv->v);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user