aboutsummaryrefslogtreecommitdiff
path: root/testes/memerr.lua
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2026-01-11 15:36:03 -0300
committerRoberto I <roberto@inf.puc-rio.br>2026-01-11 15:36:03 -0300
commit2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded (patch)
treea99a8361664b0adda83186f04e2e9c98afd86b44 /testes/memerr.lua
parent5cfc725a8b61a6f96c7324f60ac26739315095ba (diff)
downloadlua-2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded.tar.gz
lua-2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded.tar.bz2
lua-2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded.zip
More effort in avoiding errors in finalizersHEADmaster
Before calling a finalizer, Lua not only checks stack limits, but actually ensures that a minimum number of slots are already allocated for the call. (If it cannot ensure that, it postpones the finalizer.) That avoids finalizers not running due to memory errors that the programmer cannot control.
Diffstat (limited to 'testes/memerr.lua')
-rw-r--r--testes/memerr.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/testes/memerr.lua b/testes/memerr.lua
index 9c940ca7..a55514a9 100644
--- a/testes/memerr.lua
+++ b/testes/memerr.lua
@@ -282,6 +282,25 @@ testamem("growing stack", function ()
282 return foo(100) 282 return foo(100)
283end) 283end)
284 284
285
286collectgarbage()
287collectgarbage()
288global io, T, setmetatable, collectgarbage, print
289
290local Count = 0
291testamem("finalizers", function ()
292 local X = false
293 local obj = setmetatable({}, {__gc = function () X = true end})
294 obj = nil
295 T.resetCI() -- remove extra CallInfos
296 T.reallocstack(18) -- remove extra stack slots
297 Count = Count + 1
298 io.stderr:write(Count, "\n")
299 T.trick(io)
300 collectgarbage()
301 return X
302end)
303
285-- }================================================================== 304-- }==================================================================
286 305
287 306