From f7ce7e5faae69fcab0126d8bfd34b685f1dcb019 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 13 Aug 2020 14:31:27 -0300 Subject: TOUCHED2 objects are not always black This commit fixes a bug introduced in commit 9cf3299fa. TOUCHED2 objects are always black while the mutator runs, but they can become temporarily gray inside a minor collection (e.g., if the object is a weak table). --- testes/gengc.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'testes') diff --git a/testes/gengc.lua b/testes/gengc.lua index 93b5afd7..3d4f67f8 100644 --- a/testes/gengc.lua +++ b/testes/gengc.lua @@ -106,6 +106,23 @@ do -- another bug in 5.4.0 end +do -- bug introduced in commit 9cf3299fa + local t = setmetatable({}, {__mode = "kv"}) -- all-weak table + collectgarbage() -- full collection + assert(not T or T.gcage(t) == "old") + t[1] = {10} + assert(not T or (T.gcage(t) == "touched1" and T.gccolor(t) == "gray")) + collectgarbage("step", 0) -- minor collection + assert(not T or (T.gcage(t) == "touched2" and T.gccolor(t) == "black")) + collectgarbage("step", 0) -- minor collection + assert(not T or T.gcage(t) == "old") -- t should be black, but it was gray + t[1] = {10} -- no barrier here, so t was still old + collectgarbage("step", 0) -- minor collection + -- t, being old, is ignored by the collection, so it is not cleared + assert(t[1] == nil) -- fails with the bug +end + + if T == nil then (Message or print)('\n >>> testC not active: \z skipping some generational tests <<<\n') -- cgit v1.2.3-55-g6feb