diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-05-30 13:01:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-05-30 13:01:10 -0300 |
commit | 6fcdfc6d4fab67f50a8f9e26a4f9a4cf9e1550dc (patch) | |
tree | f560cb777abbcc2f291852cd7c1ac44c7d28d849 | |
parent | b77a90681ed28ba11384ed7ad7c93ef2a1c9b7b7 (diff) | |
download | lua-6fcdfc6d4fab67f50a8f9e26a4f9a4cf9e1550dc.tar.gz lua-6fcdfc6d4fab67f50a8f9e26a4f9a4cf9e1550dc.tar.bz2 lua-6fcdfc6d4fab67f50a8f9e26a4f9a4cf9e1550dc.zip |
bug: object being moved to 'finobj' list might not be sweeped by
the collector
-rw-r--r-- | lgc.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.129 2012/05/28 20:41:00 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.130 2012/05/29 17:52:17 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 | */ |
@@ -864,10 +864,11 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { | |||
864 | else { /* move 'o' to 'finobj' list */ | 864 | else { /* move 'o' to 'finobj' list */ |
865 | GCObject **p; | 865 | GCObject **p; |
866 | GCheader *ho = gch(o); | 866 | GCheader *ho = gch(o); |
867 | lua_assert(!isdead(g, o)); | ||
867 | /* avoid removing current sweep object */ | 868 | /* avoid removing current sweep object */ |
868 | if (g->sweepgc == &ho->next) { | 869 | if (g->sweepgc == &ho->next) { |
869 | /* step to next object in the list */ | 870 | /* step to next object in the list */ |
870 | g->sweepgc = (ho->next == NULL) ? NULL : &gch(ho->next)->next; | 871 | g->sweepgc = sweeplist(L, g->sweepgc, 1); |
871 | } | 872 | } |
872 | /* search for pointer pointing to 'o' */ | 873 | /* search for pointer pointing to 'o' */ |
873 | for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ } | 874 | 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) { | |||
875 | ho->next = g->finobj; /* link it in list 'finobj' */ | 876 | ho->next = g->finobj; /* link it in list 'finobj' */ |
876 | g->finobj = o; | 877 | g->finobj = o; |
877 | l_setbit(ho->marked, SEPARATED); /* mark it as such */ | 878 | l_setbit(ho->marked, SEPARATED); /* mark it as such */ |
878 | resetoldbit(o); /* see MOVE OLD rule */ | 879 | if (!keepinvariant(g)) /* not keeping invariant? */ |
880 | makewhite(g, o); /* "sweep" object */ | ||
881 | else | ||
882 | resetoldbit(o); /* see MOVE OLD rule */ | ||
879 | } | 883 | } |
880 | } | 884 | } |
881 | 885 | ||
@@ -996,7 +1000,6 @@ static l_mem atomic (lua_State *L) { | |||
996 | clearvalues(g, g->allweak, origall); | 1000 | clearvalues(g, g->allweak, origall); |
997 | g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ | 1001 | g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ |
998 | entersweep(L); /* prepare to sweep strings */ | 1002 | entersweep(L); /* prepare to sweep strings */ |
999 | /*lua_checkmemory(L);*/ | ||
1000 | return trav; /* estimate of the objects marked by 'atomic' */ | 1003 | return trav; /* estimate of the objects marked by 'atomic' */ |
1001 | } | 1004 | } |
1002 | 1005 | ||