lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 6fcdfc6d4fab67f50a8f9e26a4f9a4cf9e1550dc
parent b77a90681ed28ba11384ed7ad7c93ef2a1c9b7b7
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed, 30 May 2012 13:00:46 -0300

bug: object being moved to 'finobj' list might not be sweeped by
the collector

Diffstat:
Mlgc.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lgc.c b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.129 2012/05/28 20:41:00 roberto Exp roberto $ +** $Id: lgc.c,v 2.130 2012/05/29 17:52:17 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -864,10 +864,11 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { else { /* move 'o' to 'finobj' list */ GCObject **p; GCheader *ho = gch(o); + lua_assert(!isdead(g, o)); /* avoid removing current sweep object */ if (g->sweepgc == &ho->next) { /* step to next object in the list */ - g->sweepgc = (ho->next == NULL) ? NULL : &gch(ho->next)->next; + g->sweepgc = sweeplist(L, g->sweepgc, 1); } /* search for pointer pointing to 'o' */ for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ } @@ -875,7 +876,10 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { ho->next = g->finobj; /* link it in list 'finobj' */ g->finobj = o; l_setbit(ho->marked, SEPARATED); /* mark it as such */ - resetoldbit(o); /* see MOVE OLD rule */ + if (!keepinvariant(g)) /* not keeping invariant? */ + makewhite(g, o); /* "sweep" object */ + else + resetoldbit(o); /* see MOVE OLD rule */ } } @@ -996,7 +1000,6 @@ static l_mem atomic (lua_State *L) { clearvalues(g, g->allweak, origall); g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ entersweep(L); /* prepare to sweep strings */ - /*lua_checkmemory(L);*/ return trav; /* estimate of the objects marked by 'atomic' */ }