From 350cc4bcb67e652fafbc9ef591bb79333703abee Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 3 Dec 2010 09:48:25 -0200 Subject: [PATCH] 'micro' bug: when closing state, old objects are finalized (breaking assertion) --- lgc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lgc.c b/lgc.c index 494791ed..0a59ddc7 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.104 2010/11/18 19:15:00 roberto Exp roberto $ +** $Id: lgc.c,v 2.104 2010/11/26 14:32:31 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -689,12 +689,11 @@ static void checkSizes (lua_State *L) { static GCObject *udata2finalize (global_State *g) { GCObject *o = g->tobefnz; /* get first element */ lua_assert(isfinalized(o)); - lua_assert(!isold(o)); g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */ gch(o)->next = g->allgc; /* return it to 'allgc' list */ g->allgc = o; resetbit(gch(o)->marked, SEPARATED); /* mark that it is not in 'tobefnz' */ - resetoldbit(o); /* see MOVE OLD rule */ + lua_assert(!isold(o)); /* see MOVE OLD rule */ if (!keepinvariant(g)) /* not keeping invariant? */ makewhite(g, o); /* "sweep" object */ return o; @@ -823,10 +822,14 @@ void luaC_changemode (lua_State *L, int mode) { /* -** call all pending finalizers */ +** call all pending finalizers +*/ static void callallpendingfinalizers (lua_State *L, int propagateerrors) { global_State *g = G(L); - while (g->tobefnz) GCTM(L, propagateerrors); + while (g->tobefnz) { + resetoldbit(g->tobefnz); + GCTM(L, propagateerrors); + } }