aboutsummaryrefslogtreecommitdiff
path: root/testes/gc.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-06-16 16:29:32 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-06-16 16:29:32 -0300
commit9386e49a3173b68e8b5a7ba882c4c2faf557b61e (patch)
tree01de173acfac35de39aec9d4398dc0395a080ce5 /testes/gc.lua
parent8cd7ae7da06f54b97f95d6994d6bf47086e4e7eb (diff)
downloadlua-9386e49a3173b68e8b5a7ba882c4c2faf557b61e.tar.gz
lua-9386e49a3173b68e8b5a7ba882c4c2faf557b61e.tar.bz2
lua-9386e49a3173b68e8b5a7ba882c4c2faf557b61e.zip
New metatable in an all-weak table can fool the GC
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/gc.lua')
-rw-r--r--testes/gc.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/testes/gc.lua b/testes/gc.lua
index 5d2b3085..62713dac 100644
--- a/testes/gc.lua
+++ b/testes/gc.lua
@@ -294,6 +294,16 @@ do -- invalid mode
294end 294end
295 295
296 296
297if T then -- bug since 5.3: all-weak tables are not being revisited
298 T.gcstate("propagate")
299 local t = setmetatable({}, {__mode = "kv"})
300 T.gcstate("enteratomic") -- 't' was visited
301 setmetatable(t, {__mode = "kv"})
302 T.gcstate("pause") -- its new metatable is not being visited
303 assert(getmetatable(t).__mode == "kv")
304end
305
306
297-- 'bug' in 5.1 307-- 'bug' in 5.1
298a = {} 308a = {}
299local t = {x = 10} 309local t = {x = 10}