summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-04-26 15:22:05 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-04-26 15:22:05 -0300
commitdcd35b45955b3ffe8e1f9670d625a69c646ac748 (patch)
tree13b89bd78dfba51cf77c72b4d138bdd4c04d1c19
parentc2ea18726a466fd3c84446eb002e060c04815521 (diff)
downloadlua-github-dcd35b45955b3ffe8e1f9670d625a69c646ac748.tar.gz
bug: garbage collector can trigger too many times in recursive loops,
because it was not computing the size of CallInfo structures in threads
-rw-r--r--lgc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lgc.c b/lgc.c
index 535e988a..7ee19881 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
/*
-** $Id: lgc.c,v 2.140 2013/03/16 21:10:18 roberto Exp $
+** $Id: lgc.c,v 2.140.1.1 2013/04/12 18:48:47 roberto Exp roberto $
** 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;
}