No more LUA_ERRGCMM errors
Errors in finalizers (__gc metamethods) are never propagated. Instead, they generate a warning.
This commit is contained in:
@@ -114,13 +114,12 @@ end
|
||||
|
||||
-- testing warnings
|
||||
T.testC([[
|
||||
warning "*This "
|
||||
warning "warning "
|
||||
warning "should be in a"
|
||||
warning " single line
|
||||
warning "#This shold be a"
|
||||
warning " single "
|
||||
warning "warning
|
||||
"
|
||||
warning "*This should be "
|
||||
warning "another warning
|
||||
warning "#This should be "
|
||||
warning "another one
|
||||
"
|
||||
]])
|
||||
|
||||
@@ -896,24 +895,15 @@ do -- testing errors during GC
|
||||
a[i] = T.newuserdata(i) -- creates several udata
|
||||
end
|
||||
for i=1,20,2 do -- mark half of them to raise errors during GC
|
||||
debug.setmetatable(a[i], {__gc = function (x) error("error inside gc") end})
|
||||
debug.setmetatable(a[i],
|
||||
{__gc = function (x) error("@expected error in gc") end})
|
||||
end
|
||||
for i=2,20,2 do -- mark the other half to count and to create more garbage
|
||||
debug.setmetatable(a[i], {__gc = function (x) load("A=A+1")() end})
|
||||
end
|
||||
a = nil
|
||||
_G.A = 0
|
||||
a = 0
|
||||
while 1 do
|
||||
local stat, msg = pcall(collectgarbage)
|
||||
if stat then
|
||||
break -- stop when no more errors
|
||||
else
|
||||
a = a + 1
|
||||
assert(string.find(msg, "__gc"))
|
||||
end
|
||||
end
|
||||
assert(a == 10) -- number of errors
|
||||
|
||||
collectgarbage()
|
||||
assert(A == 10) -- number of normal collections
|
||||
collectgarbage("restart")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user