aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-15 17:00:30 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-04-15 17:00:30 -0300
commit3dbb1a4b894c0744a331d4319d8d1704dc4ad943 (patch)
tree53ca693828759df1f56f7adabdeaa022a0db0fc7 /lgc.c
parent3dd8ea54daa77345a8f193e871f6792722d8e131 (diff)
downloadlua-3dbb1a4b894c0744a331d4319d8d1704dc4ad943.tar.gz
lua-3dbb1a4b894c0744a331d4319d8d1704dc4ad943.tar.bz2
lua-3dbb1a4b894c0744a331d4319d8d1704dc4ad943.zip
In gen. GC, some gray objects stay in gray listsHEADmaster
In generational collection, objects marked as touched1 stay in gray lists between collections. This commit fixes a bug introduced in commit 808976bb59.
Diffstat (limited to '')
-rw-r--r--lgc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lgc.c b/lgc.c
index cada07d9..c0d68377 100644
--- a/lgc.c
+++ b/lgc.c
@@ -465,6 +465,8 @@ static void restartcollection (global_State *g) {
465** TOUCHED1 objects need to be in the list. TOUCHED2 doesn't need to go 465** TOUCHED1 objects need to be in the list. TOUCHED2 doesn't need to go
466** back to a gray list, but then it must become OLD. (That is what 466** back to a gray list, but then it must become OLD. (That is what
467** 'correctgraylist' does when it finds a TOUCHED2 object.) 467** 'correctgraylist' does when it finds a TOUCHED2 object.)
468** This function is a no-op in incremental mode, as objects cannot be
469** marked as touched in that mode.
468*/ 470*/
469static void genlink (global_State *g, GCObject *o) { 471static void genlink (global_State *g, GCObject *o) {
470 lua_assert(isblack(o)); 472 lua_assert(isblack(o));
@@ -480,7 +482,8 @@ static void genlink (global_State *g, GCObject *o) {
480** Traverse a table with weak values and link it to proper list. During 482** Traverse a table with weak values and link it to proper list. During
481** propagate phase, keep it in 'grayagain' list, to be revisited in the 483** propagate phase, keep it in 'grayagain' list, to be revisited in the
482** atomic phase. In the atomic phase, if table has any white value, 484** atomic phase. In the atomic phase, if table has any white value,
483** put it in 'weak' list, to be cleared. 485** put it in 'weak' list, to be cleared; otherwise, call 'genlink'
486** to check table age in generational mode.
484*/ 487*/
485static void traverseweakvalue (global_State *g, Table *h) { 488static void traverseweakvalue (global_State *g, Table *h) {
486 Node *n, *limit = gnodelast(h); 489 Node *n, *limit = gnodelast(h);
@@ -501,6 +504,8 @@ static void traverseweakvalue (global_State *g, Table *h) {
501 linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */ 504 linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */
502 else if (hasclears) 505 else if (hasclears)
503 linkgclist(h, g->weak); /* has to be cleared later */ 506 linkgclist(h, g->weak); /* has to be cleared later */
507 else
508 genlink(g, obj2gco(h));
504} 509}
505 510
506 511