fixing 'lua_status' in panic.

'luaD_throw' may call 'luaE_resetthread', which returns an error code
but clears 'L->status'; so, 'luaD_throw' should set that status again.
This commit is contained in:
Roberto Ierusalimschy
2025-01-16 16:07:39 -03:00
parent 2d8d5c74b5
commit 664bda02ba
3 changed files with 28 additions and 2 deletions

View File

@@ -416,6 +416,10 @@ do
-- trivial error
assert(T.checkpanic("pushstring hi; error") == "hi")
-- thread status inside panic (bug in 5.4.4)
assert(T.checkpanic("pushstring hi; error", "threadstatus; return 2") ==
"ERRRUN")
-- using the stack inside panic
assert(T.checkpanic("pushstring hi; error;",
[[checkstack 5 XX
@@ -433,6 +437,21 @@ do
assert(T.checkpanic("newuserdata 20000") == MEMERRMSG)
T.totalmem(0) -- restore high limit
-- memory error + thread status
local x = T.checkpanic(
[[ alloccount 0 # force a memory error in next line
newtable
]],
[[
alloccount -1 # allow free allocations again
pushstring XX
threadstatus
concat 2 # to make sure message came from here
return 1
]])
T.alloccount()
assert(x == "XX" .. "not enough memory")
-- stack error
if not _soft then
local msg = T.checkpanic[[