mirror of
https://github.com/lua/lua.git
synced 2025-01-28 06:03:00 +08:00
bug: GC step could loop forever under very particular circumstances
This commit is contained in:
parent
1ceec74370
commit
5298392c5a
16
lapi.c
16
lapi.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lapi.c,v 2.65 2008/02/14 16:02:58 roberto Exp roberto $
|
||||
** $Id: lapi.c,v 2.66 2008/02/19 18:55:09 roberto Exp roberto $
|
||||
** Lua API
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -907,14 +907,14 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
|
||||
}
|
||||
case LUA_GCSTEP: {
|
||||
lu_mem a = (cast(lu_mem, data) << 10);
|
||||
if (a <= g->totalbytes)
|
||||
g->GCthreshold = g->totalbytes - a;
|
||||
else
|
||||
g->GCthreshold = 0;
|
||||
while (g->GCthreshold <= g->totalbytes)
|
||||
g->GCthreshold = (a <= g->totalbytes) ? g->totalbytes - a : 0;
|
||||
while (g->GCthreshold <= g->totalbytes) {
|
||||
luaC_step(L);
|
||||
if (g->gcstate == GCSpause) /* end of cycle? */
|
||||
res = 1; /* signal it */
|
||||
if (g->gcstate == GCSpause) { /* end of cycle? */
|
||||
res = 1; /* signal it */
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LUA_GCSETPAUSE: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user