diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-29 18:43:36 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-29 18:43:36 -0300 |
commit | 23001d860789860ef53fc86f1a2a4af63c44e03f (patch) | |
tree | 4f9dda4def7e173355fd019edcbb28097910fe7a | |
parent | 5d79c6684b185888319d46837394a0fbcfde921f (diff) | |
download | lua-23001d860789860ef53fc86f1a2a4af63c44e03f.tar.gz lua-23001d860789860ef53fc86f1a2a4af63c44e03f.tar.bz2 lua-23001d860789860ef53fc86f1a2a4af63c44e03f.zip |
nasty GC bug: upvalue must be turned white when not keeping invariant,
but barrier was not being called when uv->v were already white.
-rw-r--r-- | lfunc.c | 8 | ||||
-rw-r--r-- | lgc.c | 22 | ||||
-rw-r--r-- | lgc.h | 5 |
3 files changed, 26 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 2.21 2010/03/26 20:58:11 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.22 2010/04/29 17:34:35 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 | */ |
@@ -101,11 +101,7 @@ void luaF_close (lua_State *L, StkId level) { | |||
101 | uv->v = &uv->u.value; /* now current value lives here */ | 101 | uv->v = &uv->u.value; /* now current value lives here */ |
102 | gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */ | 102 | gch(o)->next = g->allgc; /* link upvalue into 'allgc' list */ |
103 | g->allgc = o; | 103 | g->allgc = o; |
104 | lua_assert(!isblack(o)); /* open upvalues are never black */ | 104 | luaC_checkupvalcolor(g, uv); |
105 | if (isgray(o)) { /* is it marked? */ | ||
106 | gray2black(o); /* could not be black; now it can */ | ||
107 | luaC_barrier(L, uv, uv->v); | ||
108 | } | ||
109 | } | 105 | } |
110 | } | 106 | } |
111 | } | 107 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.80 2010/04/26 17:58:00 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.81 2010/04/29 17:32:40 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -147,6 +147,26 @@ void luaC_barrierback (lua_State *L, Table *t) { | |||
147 | 147 | ||
148 | 148 | ||
149 | /* | 149 | /* |
150 | ** check color (and invariants) for an upvalue that was closed, | ||
151 | ** i.e., moved into the 'allgc' list | ||
152 | */ | ||
153 | void luaC_checkupvalcolor (global_State *g, UpVal *uv) { | ||
154 | GCObject *o = obj2gco(uv); | ||
155 | lua_assert(!isblack(o)); /* open upvalues are never black */ | ||
156 | if (isgray(o)) { | ||
157 | if (keepinvariant(g)) { | ||
158 | gray2black(o); /* it is being visited now */ | ||
159 | markvalue(g, uv->v); | ||
160 | } | ||
161 | else { | ||
162 | lua_assert(issweepphase(g)); | ||
163 | makewhite(g, o); | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | |||
168 | |||
169 | /* | ||
150 | ** create a new collectable object (with given type and size) and link | 170 | ** create a new collectable object (with given type and size) and link |
151 | ** it to '*list'. 'offset' tells how many bytes to allocate before the | 171 | ** it to '*list'. 'offset' tells how many bytes to allocate before the |
152 | ** object itself (used only by states). | 172 | ** object itself (used only by states). |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.30 2010/03/25 13:06:36 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.31 2010/04/29 17:32:40 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -9,6 +9,7 @@ | |||
9 | 9 | ||
10 | 10 | ||
11 | #include "lobject.h" | 11 | #include "lobject.h" |
12 | #include "lstate.h" | ||
12 | 13 | ||
13 | 14 | ||
14 | /* | 15 | /* |
@@ -120,6 +121,6 @@ LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, | |||
120 | LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); | 121 | LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); |
121 | LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); | 122 | LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); |
122 | LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u); | 123 | LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u); |
123 | 124 | LUAI_FUNC void luaC_checkupvalcolor (global_State *g, UpVal *uv); | |
124 | 125 | ||
125 | #endif | 126 | #endif |