aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-10-03 09:36:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-10-03 09:36:46 -0300
commit86b39206d998a184a105bfb63b630ed28e1c81bc (patch)
tree8d4cad30114addb437265532007e3b40db10eebd
parentfdae4b9453fa7432f5b1a88c55dca33f1c861263 (diff)
downloadlua-86b39206d998a184a105bfb63b630ed28e1c81bc.tar.gz
lua-86b39206d998a184a105bfb63b630ed28e1c81bc.tar.bz2
lua-86b39206d998a184a105bfb63b630ed28e1c81bc.zip
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.
-rw-r--r--lfunc.c4
-rw-r--r--ltests.c6
2 files changed, 4 insertions, 6 deletions
diff --git a/lfunc.c b/lfunc.c
index 746f388c..68e064b2 100644
--- a/lfunc.c
+++ b/lfunc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lfunc.c,v 2.28 2012/01/20 22:05:50 roberto Exp roberto $ 2** $Id: lfunc.c,v 2.29 2012/05/08 13:53:33 roberto Exp roberto $
3** Auxiliary functions to manipulate prototypes and closures 3** Auxiliary functions to manipulate prototypes and closures
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -52,12 +52,12 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
52 while (*pp != NULL && (p = gco2uv(*pp))->v >= level) { 52 while (*pp != NULL && (p = gco2uv(*pp))->v >= level) {
53 GCObject *o = obj2gco(p); 53 GCObject *o = obj2gco(p);
54 lua_assert(p->v != &p->u.value); 54 lua_assert(p->v != &p->u.value);
55 lua_assert(!isold(o) || isold(obj2gco(L)));
55 if (p->v == level) { /* found a corresponding upvalue? */ 56 if (p->v == level) { /* found a corresponding upvalue? */
56 if (isdead(g, o)) /* is it dead? */ 57 if (isdead(g, o)) /* is it dead? */
57 changewhite(o); /* resurrect it */ 58 changewhite(o); /* resurrect it */
58 return p; 59 return p;
59 } 60 }
60 resetoldbit(o); /* may create a newer upval after this one */
61 pp = &p->next; 61 pp = &p->next;
62 } 62 }
63 /* not found: create a new one */ 63 /* not found: create a new one */
diff --git a/ltests.c b/ltests.c
index 1bbeac1c..17833ec5 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.132 2012/07/04 15:52:38 roberto Exp roberto $ 2** $Id: ltests.c,v 2.133 2012/08/16 17:34:28 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -469,9 +469,7 @@ int lua_checkmemory (lua_State *L) {
469 lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv); 469 lua_assert(uv->u.l.next->u.l.prev == uv && uv->u.l.prev->u.l.next == uv);
470 lua_assert(uv->v != &uv->u.value); /* must be open */ 470 lua_assert(uv->v != &uv->u.value); /* must be open */
471 lua_assert(!isblack(obj2gco(uv))); /* open upvalues are never black */ 471 lua_assert(!isblack(obj2gco(uv))); /* open upvalues are never black */
472 if (isdead(g, obj2gco(uv))) 472 if (!isdead(g, obj2gco(uv)))
473 lua_assert(issweepphase(g));
474 else
475 checkvalref(g, obj2gco(uv), uv->v); 473 checkvalref(g, obj2gco(uv), uv->v);
476 } 474 }
477 return 0; 475 return 0;