From 0f781f836ab348716eb9232d3831a871b9821a3c Mon Sep 17 00:00:00 2001 From: Roberto I Date: Mon, 13 Jul 2026 15:55:36 -0300 Subject: 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. --- testes/events.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'testes') 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 end +do -- bug in 5.4 + local parent = {} + parent.__newindex = parent + collectgarbage() + local child = setmetatable({}, parent) + child.__newindex = {x = "hello"} + collectgarbage("step") + assert(parent.__newindex.x == "hello") +end + -- concat metamethod x numbers (bug in 5.1.1) c = {} -- cgit v1.2.3-55-g6feb