aboutsummaryrefslogtreecommitdiff
path: root/testes/events.lua
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2026-07-13 15:55:36 -0300
committerRoberto I <roberto@inf.puc-rio.br>2026-07-13 15:55:36 -0300
commit0f781f836ab348716eb9232d3831a871b9821a3c (patch)
tree2bdc431f9d920ae418c5ce6fb1569fb984234ed4 /testes/events.lua
parent934fdd481ced3a9d4a7aaace4479ce889ab23582 (diff)
downloadlua-0f781f836ab348716eb9232d3831a871b9821a3c.tar.gz
lua-0f781f836ab348716eb9232d3831a871b9821a3c.tar.bz2
lua-0f781f836ab348716eb9232d3831a871b9821a3c.zip
Bug: Issues with write barrier for __newindex
In 'luaV_finishset', there is an update on a table that is a field on another table. If the first table is the same as the one with the field (e.g., after 't.__newindex = t'), the update can change the value on that field (if the field being updated is '__newindex' itself). After that, the barrier is called with the table stored in that field, which is not the correct table anymore.
Diffstat (limited to 'testes/events.lua')
-rw-r--r--testes/events.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/testes/events.lua b/testes/events.lua
index def13dc8..d0a48c66 100644
--- a/testes/events.lua
+++ b/testes/events.lua
@@ -382,6 +382,16 @@ do
382end 382end
383 383
384 384
385do -- bug in 5.4
386 local parent = {}
387 parent.__newindex = parent
388 collectgarbage()
389 local child = setmetatable({}, parent)
390 child.__newindex = {x = "hello"}
391 collectgarbage("step")
392 assert(parent.__newindex.x == "hello")
393end
394
385 395
386-- concat metamethod x numbers (bug in 5.1.1) 396-- concat metamethod x numbers (bug in 5.1.1)
387c = {} 397c = {}