From 664bda02ba4bd167728a2acbe658cc4a9dd9b0b5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 16 Jan 2025 16:07:39 -0300 Subject: 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. --- testes/api.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'testes') diff --git a/testes/api.lua b/testes/api.lua index b7e34f7f..21f703fd 100644 --- a/testes/api.lua +++ b/testes/api.lua @@ -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[[ -- cgit v1.2.3-55-g6feb