aboutsummaryrefslogtreecommitdiff
path: root/testes
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-06-16 16:33:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-06-16 16:33:02 -0300
commit1b0f943da7dfb25987456a77259edbeea0b94edc (patch)
tree6d095ff675b6779078e4368db338ad57562d7651 /testes
parent6e22fedb74cf0c9b6656e9fce8b7331db847c605 (diff)
downloadlua-v5.4.tar.gz
lua-v5.4.tar.bz2
lua-v5.4.zip
Bug: new metatable in weak table can fool the GCv5.4
All-weak tables are not being revisited after being visited during propagation; if it gets a new metatable after that, the new metatable may not be marked.
Diffstat (limited to 'testes')
-rw-r--r--testes/gc.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 03093e34..f017f330 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -301,6 +301,16 @@ collectgarbage()
301assert(next(a) == string.rep('$', 11)) 301assert(next(a) == string.rep('$', 11))
302 302
303 303
304if T then -- bug since 5.3: all-weak tables are not being revisited
305 T.gcstate("propagate")
306 local t = setmetatable({}, {__mode = "kv"})
307 T.gcstate("atomic") -- 't' was visited
308 setmetatable(t, {__mode = "kv"})
309 T.gcstate("pause") -- its new metatable is not being visited
310 assert(getmetatable(t).__mode == "kv")
311end
312
313
304-- 'bug' in 5.1 314-- 'bug' in 5.1
305a = {} 315a = {}
306local t = {x = 10} 316local t = {x = 10}