From 9d6556fd87900d1af408eb180ee9052619c990ea Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 25 Jun 2002 16:17:42 -0300 Subject: [PATCH] userdata are removed from weaktables before invoking their GC fallbacks --- lgc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lgc.c b/lgc.c index 8e83fec2..c7429c26 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 1.137 2002/06/20 20:41:46 roberto Exp roberto $ +** $Id: lgc.c,v 1.138 2002/06/24 17:19:43 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -215,7 +215,7 @@ static void traversetable (GCState *st, Table *h) { int weakvalue = 0; marktable(st, h->metatable); lua_assert(h->lsizenode || h->node == G(st->L)->dummynode); - mode = fasttm(st->L, h->metatable, TM_WEAKMODE); + mode = fasttm(st->L, h->metatable, TM_MODE); if (mode && ttype(mode) == LUA_TSTRING) { /* weak table? */ h->mark = st->toclear; /* must be cleared after GC, ... */ st->toclear = h; /* ...put in the appropriate list */ @@ -458,10 +458,10 @@ void luaC_collectgarbage (lua_State *L) { st.toclear = NULL; markstacks(&st); /* mark all stacks */ propagatemarks(&st); /* mark all reachable objects */ + cleartables(st.toclear); separateudata(L); /* separate userdata to be preserved */ marktmu(&st); /* mark `preserved' userdata */ propagatemarks(&st); /* remark */ - cleartables(st.toclear); luaC_collect(L, 0); checkMbuffer(L); G(L)->GCthreshold = 2*G(L)->nblocks; /* new threshold */