mirror of
https://github.com/lua/lua
synced 2025-02-16 21:23:58 +03:00
bug: garbage collector can trigger too many times in recursive loops,
because it was not computing the size of CallInfo structures in threads
This commit is contained in:
parent
f79584faca
commit
c37b7b3cca
13
lgc.c
13
lgc.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lgc.c,v 2.139 2013/03/15 18:33:36 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 2.140.1.2 2013/04/26 18:22:05 roberto Exp $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -493,17 +493,24 @@ static lu_mem traverseLclosure (global_State *g, LClosure *cl) {
|
||||
|
||||
|
||||
static lu_mem traversestack (global_State *g, lua_State *th) {
|
||||
int n = 0;
|
||||
StkId o = th->stack;
|
||||
if (o == NULL)
|
||||
return 1; /* stack not completely built yet */
|
||||
for (; o < th->top; o++)
|
||||
for (; o < th->top; o++) /* mark live elements in the stack */
|
||||
markvalue(g, o);
|
||||
if (g->gcstate == GCSatomic) { /* final traversal? */
|
||||
StkId lim = th->stack + th->stacksize; /* real end of stack */
|
||||
for (; o < lim; o++) /* clear not-marked stack slice */
|
||||
setnilvalue(o);
|
||||
}
|
||||
return sizeof(lua_State) + sizeof(TValue) * th->stacksize;
|
||||
else { /* count call infos to compute size */
|
||||
CallInfo *ci;
|
||||
for (ci = &th->base_ci; ci != th->ci; ci = ci->next)
|
||||
n++;
|
||||
}
|
||||
return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
|
||||
sizeof(CallInfo) * n;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user