aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-04-26 15:26:49 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-04-26 15:26:49 -0300
commitc37b7b3cca3f58389aefb3903b58fd213bae2b16 (patch)
tree089937735d590b917b542abab88a0f1c07dcd418
parentf79584facab6a11cd036b5f12dbfa80460eee146 (diff)
downloadlua-c37b7b3cca3f58389aefb3903b58fd213bae2b16.tar.gz
lua-c37b7b3cca3f58389aefb3903b58fd213bae2b16.tar.bz2
lua-c37b7b3cca3f58389aefb3903b58fd213bae2b16.zip
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 64df6c14..52460dcd 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.139 2013/03/15 18:33:36 roberto Exp roberto $ 2** $Id: lgc.c,v 2.140.1.2 2013/04/26 18:22:05 roberto Exp $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -493,17 +493,24 @@ static lu_mem traverseLclosure (global_State *g, LClosure *cl) {
493 493
494 494
495static lu_mem traversestack (global_State *g, lua_State *th) { 495static lu_mem traversestack (global_State *g, lua_State *th) {
496 int n = 0;
496 StkId o = th->stack; 497 StkId o = th->stack;
497 if (o == NULL) 498 if (o == NULL)
498 return 1; /* stack not completely built yet */ 499 return 1; /* stack not completely built yet */
499 for (; o < th->top; o++) 500 for (; o < th->top; o++) /* mark live elements in the stack */
500 markvalue(g, o); 501 markvalue(g, o);
501 if (g->gcstate == GCSatomic) { /* final traversal? */ 502 if (g->gcstate == GCSatomic) { /* final traversal? */
502 StkId lim = th->stack + th->stacksize; /* real end of stack */ 503 StkId lim = th->stack + th->stacksize; /* real end of stack */
503 for (; o < lim; o++) /* clear not-marked stack slice */ 504 for (; o < lim; o++) /* clear not-marked stack slice */
504 setnilvalue(o); 505 setnilvalue(o);
505 } 506 }
506 return sizeof(lua_State) + sizeof(TValue) * th->stacksize; 507 else { /* count call infos to compute size */
508 CallInfo *ci;
509 for (ci = &th->base_ci; ci != th->ci; ci = ci->next)
510 n++;
511 }
512 return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
513 sizeof(CallInfo) * n;
507} 514}
508 515
509 516