Skip to content

Commit 3dbb1a4

Browse files
committed
In gen. GC, some gray objects stay in gray lists
In generational collection, objects marked as touched1 stay in gray lists between collections. This commit fixes a bug introduced in commit 808976b.
1 parent 3dd8ea5 commit 3dbb1a4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Diff for: lgc.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ static void restartcollection (global_State *g) {
465465
** TOUCHED1 objects need to be in the list. TOUCHED2 doesn't need to go
466466
** back to a gray list, but then it must become OLD. (That is what
467467
** '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.
468470
*/
469471
static void genlink (global_State *g, GCObject *o) {
470472
lua_assert(isblack(o));
@@ -480,7 +482,8 @@ static void genlink (global_State *g, GCObject *o) {
480482
** Traverse a table with weak values and link it to proper list. During
481483
** propagate phase, keep it in 'grayagain' list, to be revisited in the
482484
** 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.
484487
*/
485488
static void traverseweakvalue (global_State *g, Table *h) {
486489
Node *n, *limit = gnodelast(h);
@@ -501,6 +504,8 @@ static void traverseweakvalue (global_State *g, Table *h) {
501504
linkgclist(h, g->grayagain); /* must retraverse it in atomic phase */
502505
else if (hasclears)
503506
linkgclist(h, g->weak); /* has to be cleared later */
507+
else
508+
genlink(g, obj2gco(h));
504509
}
505510

506511

Diff for: lstrlib.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,10 @@ static KOption getdetails (Header *h, size_t totalsize, const char **fmt,
15441544
else {
15451545
if (align > h->maxalign) /* enforce maximum alignment */
15461546
align = h->maxalign;
1547-
if (l_unlikely(!ispow2(align))) /* not a power of 2? */
1547+
if (l_unlikely(!ispow2(align))) { /* not a power of 2? */
1548+
*ntoalign = 0; /* to avoid warnings */
15481549
luaL_argerror(h->L, 1, "format asks for alignment not power of 2");
1550+
}
15491551
else {
15501552
/* 'szmoda' = totalsize % align */
15511553
unsigned szmoda = cast_uint(totalsize & (align - 1));

0 commit comments

Comments
 (0)