commit 23001d860789860ef53fc86f1a2a4af63c44e03f
parent 5d79c6684b185888319d46837394a0fbcfde921f
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 29 Apr 2010 18:43:12 -0300
nasty GC bug: upvalue must be turned white when not keeping invariant,
but barrier was not being called when uv->v were already white.
Diffstat:
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/lfunc.c b/lfunc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lfunc.c,v 2.21 2010/03/26 20:58:11 roberto Exp roberto $
+** $Id: lfunc.c,v 2.22 2010/04/29 17:34:35 roberto Exp roberto $
** Auxiliary functions to manipulate prototypes and closures
** See Copyright Notice in lua.h
*/
@@ -101,11 +101,7 @@ void luaF_close (lua_State *L, StkId level) {
uv->v = &uv->u.value; /* now current value lives here */
gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */
g->allgc = o;
- lua_assert(!isblack(o)); /* open upvalues are never black */
- if (isgray(o)) { /* is it marked? */
- gray2black(o); /* could not be black; now it can */
- luaC_barrier(L, uv, uv->v);
- }
+ luaC_checkupvalcolor(g, uv);
}
}
}
diff --git a/lgc.c b/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.80 2010/04/26 17:58:00 roberto Exp roberto $
+** $Id: lgc.c,v 2.81 2010/04/29 17:32:40 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -147,6 +147,26 @@ void luaC_barrierback (lua_State *L, Table *t) {
/*
+** check color (and invariants) for an upvalue that was closed,
+** i.e., moved into the 'allgc' list
+*/
+void luaC_checkupvalcolor (global_State *g, UpVal *uv) {
+ GCObject *o = obj2gco(uv);
+ lua_assert(!isblack(o)); /* open upvalues are never black */
+ if (isgray(o)) {
+ if (keepinvariant(g)) {
+ gray2black(o); /* it is being visited now */
+ markvalue(g, uv->v);
+ }
+ else {
+ lua_assert(issweepphase(g));
+ makewhite(g, o);
+ }
+ }
+}
+
+
+/*
** create a new collectable object (with given type and size) and link
** it to '*list'. 'offset' tells how many bytes to allocate before the
** object itself (used only by states).
diff --git a/lgc.h b/lgc.h
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.h,v 2.30 2010/03/25 13:06:36 roberto Exp roberto $
+** $Id: lgc.h,v 2.31 2010/04/29 17:32:40 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -9,6 +9,7 @@
#include "lobject.h"
+#include "lstate.h"
/*
@@ -120,6 +121,6 @@ LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz,
LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u);
-
+LUAI_FUNC void luaC_checkupvalcolor (global_State *g, UpVal *uv);
#endif