diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-03-17 14:32:08 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-03-17 14:32:08 -0300 |
commit | 921832be8d7f687d2cd891654c8680c6e9d6584c (patch) | |
tree | 0a2ec0b675d289feea0da26c8082450bdb18aaf8 /testes | |
parent | 205f9aa67b43b3d9b5059769cfc1ed0265341586 (diff) | |
download | lua-921832be8d7f687d2cd891654c8680c6e9d6584c.tar.gz lua-921832be8d7f687d2cd891654c8680c6e9d6584c.tar.bz2 lua-921832be8d7f687d2cd891654c8680c6e9d6584c.zip |
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.)
Diffstat (limited to 'testes')
-rw-r--r-- | testes/coroutine.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 680fc605..17f6ceba 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -505,6 +505,25 @@ assert(not pcall(a, a)) | |||
505 | a = nil | 505 | a = nil |
506 | 506 | ||
507 | 507 | ||
508 | do | ||
509 | -- bug in 5.4: thread can use message handler higher in the stack | ||
510 | -- than the variable being closed | ||
511 | local c = coroutine.create(function() | ||
512 | local clo <close> = setmetatable({}, {__close=function() | ||
513 | local x = 134 -- will overwrite message handler | ||
514 | error(x) | ||
515 | end}) | ||
516 | -- yields coroutine but leaves a new message handler for it, | ||
517 | -- that would be used when closing the coroutine (except that it | ||
518 | -- will be overwritten) | ||
519 | xpcall(coroutine.yield, function() return "XXX" end) | ||
520 | end) | ||
521 | |||
522 | assert(coroutine.resume(c)) -- start coroutine | ||
523 | local st, msg = coroutine.close(c) | ||
524 | assert(not st and msg == 134) | ||
525 | end | ||
526 | |||
508 | -- access to locals of erroneous coroutines | 527 | -- access to locals of erroneous coroutines |
509 | local x = coroutine.create (function () | 528 | local x = coroutine.create (function () |
510 | local a = 10 | 529 | local a = 10 |