mirror of https://github.com/rusefi/lua.git
bug: when closing the state, 'luaC_separateudata' might mark
userdata in the wrong phase of collection, therefore avoiding their traversal
This commit is contained in:
parent
7ba62e2985
commit
c3525610fe
8
lgc.c
8
lgc.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lgc.c,v 2.44 2008/02/19 18:55:09 roberto Exp roberto $
|
** $Id: lgc.c,v 2.45 2008/06/23 16:51:28 roberto Exp roberto $
|
||||||
** Garbage Collector
|
** Garbage Collector
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -210,7 +210,6 @@ static void markbeingfnz (global_State *g) {
|
||||||
do {
|
do {
|
||||||
u = gch(u)->next;
|
u = gch(u)->next;
|
||||||
lua_assert(testbit(gch(u)->marked, SEPARATED));
|
lua_assert(testbit(gch(u)->marked, SEPARATED));
|
||||||
lua_assert(!iswhite(u)); /* must be marked, if left from previous GC */
|
|
||||||
makewhite(g, u);
|
makewhite(g, u);
|
||||||
reallymarkobject(g, u);
|
reallymarkobject(g, u);
|
||||||
} while (u != g->tobefnz);
|
} while (u != g->tobefnz);
|
||||||
|
@ -664,12 +663,10 @@ size_t luaC_separateudata (lua_State *L, int all) {
|
||||||
while ((curr = *p) != NULL) {
|
while ((curr = *p) != NULL) {
|
||||||
lua_assert(ttisuserdata(gch(curr)) && !isfinalized(gco2u(curr)));
|
lua_assert(ttisuserdata(gch(curr)) && !isfinalized(gco2u(curr)));
|
||||||
lua_assert(testbit(gch(curr)->marked, SEPARATED));
|
lua_assert(testbit(gch(curr)->marked, SEPARATED));
|
||||||
if (all) makewhite(g, curr); /* if 'all', collect all objects */
|
if (!(all || iswhite(curr))) /* not being collected? */
|
||||||
if (!iswhite(curr)) /* not being collected? */
|
|
||||||
p = &gch(curr)->next; /* don't bother with it */
|
p = &gch(curr)->next; /* don't bother with it */
|
||||||
else {
|
else {
|
||||||
l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */
|
l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */
|
||||||
reallymarkobject(g, curr); /* won't be collected now */
|
|
||||||
deadmem += sizeudata(gco2u(curr));
|
deadmem += sizeudata(gco2u(curr));
|
||||||
*p = gch(curr)->next; /* remove 'curr' from 'tmudata' list */
|
*p = gch(curr)->next; /* remove 'curr' from 'tmudata' list */
|
||||||
/* link 'curr' at the end of 'tobefnz' list */
|
/* link 'curr' at the end of 'tobefnz' list */
|
||||||
|
@ -746,6 +743,7 @@ static void atomic (lua_State *L) {
|
||||||
traverselistofgrays(g, &g->grayagain); /* remark gray again */
|
traverselistofgrays(g, &g->grayagain); /* remark gray again */
|
||||||
convergeephemerons(g);
|
convergeephemerons(g);
|
||||||
udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
|
udsize = luaC_separateudata(L, 0); /* separate userdata to be finalized */
|
||||||
|
markbeingfnz(g); /* mark userdata that will be finalized */
|
||||||
udsize += propagateall(g); /* remark, to propagate `preserveness' */
|
udsize += propagateall(g); /* remark, to propagate `preserveness' */
|
||||||
convergeephemerons(g);
|
convergeephemerons(g);
|
||||||
/* remove collected objects from weak tables */
|
/* remove collected objects from weak tables */
|
||||||
|
|
Loading…
Reference in New Issue