New function 'resetCI'
New function 'resetCI' resets the CallInfo list of a thread, ensuring a proper state when creating a new thread, closing a thread, or closing a state, so that we can run code after that. (When closing a thread, we need to run its __close metamethods; when closing a state, we need to run its __close metamethods and its finalizers.)
This commit is contained in:
@@ -505,6 +505,25 @@ assert(not pcall(a, a))
|
||||
a = nil
|
||||
|
||||
|
||||
do
|
||||
-- bug in 5.4: thread can use message handler higher in the stack
|
||||
-- than the variable being closed
|
||||
local c = coroutine.create(function()
|
||||
local clo <close> = setmetatable({}, {__close=function()
|
||||
local x = 134 -- will overwrite message handler
|
||||
error(x)
|
||||
end})
|
||||
-- yields coroutine but leaves a new message handler for it,
|
||||
-- that would be used when closing the coroutine (except that it
|
||||
-- will be overwritten)
|
||||
xpcall(coroutine.yield, function() return "XXX" end)
|
||||
end)
|
||||
|
||||
assert(coroutine.resume(c)) -- start coroutine
|
||||
local st, msg = coroutine.close(c)
|
||||
assert(not st and msg == 134)
|
||||
end
|
||||
|
||||
-- access to locals of erroneous coroutines
|
||||
local x = coroutine.create (function ()
|
||||
local a = 10
|
||||
|
||||
Reference in New Issue
Block a user