diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2026-01-11 15:36:03 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2026-01-11 15:36:03 -0300 |
| commit | 2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded (patch) | |
| tree | a99a8361664b0adda83186f04e2e9c98afd86b44 /testes/tracegc.lua | |
| parent | 5cfc725a8b61a6f96c7324f60ac26739315095ba (diff) | |
| download | lua-2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded.tar.gz lua-2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded.tar.bz2 lua-2a7cf4f319fc276f4554a8f6364e6b1ba4eb2ded.zip | |
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/tracegc.lua')
| -rw-r--r-- | testes/tracegc.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/testes/tracegc.lua b/testes/tracegc.lua index a8c929df..c1154f90 100644 --- a/testes/tracegc.lua +++ b/testes/tracegc.lua | |||
| @@ -1,10 +1,15 @@ | |||
| 1 | -- track collections | 1 | -- track collections |
| 2 | 2 | ||
| 3 | |||
| 3 | local M = {} | 4 | local M = {} |
| 4 | 5 | ||
| 5 | -- import list | 6 | -- import list |
| 6 | local setmetatable, stderr, collectgarbage = | 7 | local stderr, collectgarbage = io.stderr, collectgarbage |
| 7 | setmetatable, io.stderr, collectgarbage | 8 | |
| 9 | -- the debug version of setmetatable does not create any object (such as | ||
| 10 | -- a '__metatable' string), and so it is more appropriate to be used in | ||
| 11 | -- a finalizer | ||
| 12 | local setmetatable = require"debug".setmetatable | ||
| 8 | 13 | ||
| 9 | global none | 14 | global none |
| 10 | 15 | ||
