diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-08-13 14:31:27 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-08-13 14:31:27 -0300 |
| commit | f7ce7e5faae69fcab0126d8bfd34b685f1dcb019 (patch) | |
| tree | 1e2aa3f512d224c58f8cc639f93582d3659bae1a /testes | |
| parent | 65141832d29824ebfbf26e8af9e6e4b8549518d4 (diff) | |
| download | lua-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.lua | 17 |
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 | |||
| 106 | end | 106 | end |
| 107 | 107 | ||
| 108 | 108 | ||
| 109 | do -- 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 | ||
| 123 | end | ||
| 124 | |||
| 125 | |||
| 109 | if T == nil then | 126 | if 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') |
