aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-08-13 14:31:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2020-08-13 14:31:27 -0300
commitf7ce7e5faae69fcab0126d8bfd34b685f1dcb019 (patch)
tree1e2aa3f512d224c58f8cc639f93582d3659bae1a /testes
parent65141832d29824ebfbf26e8af9e6e4b8549518d4 (diff)
downloadlua-f7ce7e5faae69fcab0126d8bfd34b685f1dcb019.tar.gz
lua-f7ce7e5faae69fcab0126d8bfd34b685f1dcb019.tar.bz2
lua-f7ce7e5faae69fcab0126d8bfd34b685f1dcb019.zip
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).
Diffstat (limited to 'testes')
-rw-r--r--testes/gengc.lua17
1 files changed, 17 insertions, 0 deletions
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
106end 106end
107 107
108 108
109do -- bug introduced in commit 9cf3299fa
110 local t = setmetatable({}, {__mode = "kv"}) -- all-weak table
111 collectgarbage() -- full collection
112 assert(not T or T.gcage(t) == "old")
113 t[1] = {10}
114 assert(not T or (T.gcage(t) == "touched1" and T.gccolor(t) == "gray"))
115 collectgarbage("step", 0) -- minor collection
116 assert(not T or (T.gcage(t) == "touched2" and T.gccolor(t) == "black"))
117 collectgarbage("step", 0) -- minor collection
118 assert(not T or T.gcage(t) == "old") -- t should be black, but it was gray
119 t[1] = {10} -- no barrier here, so t was still old
120 collectgarbage("step", 0) -- minor collection
121 -- t, being old, is ignored by the collection, so it is not cleared
122 assert(t[1] == nil) -- fails with the bug
123end
124
125
109if T == nil then 126if T == nil then
110 (Message or print)('\n >>> testC not active: \z 127 (Message or print)('\n >>> testC not active: \z
111 skipping some generational tests <<<\n') 128 skipping some generational tests <<<\n')