From 690ab5519504edef7971b6e8ab759681d8d34cea Mon Sep 17 00:00:00 2001 From: fly_fzc <2385803914@qq.com> Date: Wed, 8 May 2024 11:43:12 +0800 Subject: [PATCH] add lua_closethread to adapt interfacechange --- backport-Emergency-new-version-5.4.6.patch | 95 ++++++++++++++++++++++ lua.spec | 7 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 backport-Emergency-new-version-5.4.6.patch diff --git a/backport-Emergency-new-version-5.4.6.patch b/backport-Emergency-new-version-5.4.6.patch new file mode 100644 index 0000000..476d09f --- /dev/null +++ b/backport-Emergency-new-version-5.4.6.patch @@ -0,0 +1,95 @@ +From 6443185167c77adcc8552a3fee7edab7895db1a9 Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy +Date: Tue, 2 May 2023 16:41:43 -0300 +Subject: [PATCH] "Emergency" new version 5.4.6 + +'lua_resetthread' is back to its original signature, to avoid +incompatibilities in the ABI between releases of the same version. +New function 'lua_closethread' added with the "correct" signature. +--- + src/lcorolib.c | 4 ++-- + src/lstate.c | 10 +++++++++- + lua-5.4.3-tests/ltests/ltests.c | 2 +- + src/lua.h | 3 ++- + 4 files changed, 13 insertions(+), 6 deletions(-) + +diff --git a/src/lcorolib.c b/src/lcorolib.c +index 40b880b1..c64adf08 100644 +--- a/src/lcorolib.c ++++ b/src/lcorolib.c +@@ -76,7 +76,7 @@ static int luaB_auxwrap (lua_State *L) { + if (l_unlikely(r < 0)) { /* error? */ + int stat = lua_status(co); + if (stat != LUA_OK && stat != LUA_YIELD) { /* error in the coroutine? */ +- stat = lua_resetthread(co, L); /* close its tbc variables */ ++ stat = lua_closethread(co, L); /* close its tbc variables */ + lua_assert(stat != LUA_OK); + lua_xmove(co, L, 1); /* copy error message */ + } +@@ -172,7 +172,7 @@ static int luaB_close (lua_State *L) { + int status = auxstatus(L, co); + switch (status) { + case COS_DEAD: case COS_YIELD: { +- status = lua_resetthread(co, L); ++ status = lua_closethread(co, L); + if (status == LUA_OK) { + lua_pushboolean(L, 1); + return 1; +diff --git a/src/lstate.c b/src/lstate.c +index 1fbefb4b..1e925e5a 100644 +--- a/src/lstate.c ++++ b/src/lstate.c +@@ -339,7 +339,7 @@ int luaE_resetthread (lua_State *L, int status) { + } + + +-LUA_API int lua_resetthread (lua_State *L, lua_State *from) { ++LUA_API int lua_closethread (lua_State *L, lua_State *from) { + int status; + lua_lock(L); + L->nCcalls = (from) ? getCcalls(from) : 0; +@@ -349,6 +349,14 @@ LUA_API int lua_resetthread (lua_State *L, lua_State *from) { + } + + ++/* ++** Deprecated! Use 'lua_closethread' instead. ++*/ ++LUA_API int lua_resetthread (lua_State *L) { ++ return lua_closethread(L, NULL); ++} ++ ++ + LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) { + int i; + lua_State *L; +diff --git a/lua-5.4.3-tests/ltests/ltests.c b/lua-5.4.3-tests/ltests/ltests.c +index 4a0a6af1..7d184c0d 100644 +--- a/lua-5.4.3-tests/ltests/ltests.c ++++ b/lua-5.4.3-tests/ltests/ltests.c +@@ -1533,7 +1533,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { + lua_newthread(L1); + } + else if EQ("resetthread") { +- lua_pushinteger(L1, lua_resetthread(L1, L)); ++ lua_pushinteger(L1, lua_resetthread(L1)); /* deprecated */ + } + else if EQ("newuserdata") { + lua_newuserdata(L1, getnum); +diff --git a/src/lua.h b/src/lua.h +index 01927c6d..fd16cf80 100644 +--- a/src/lua.h ++++ b/src/lua.h +@@ -163,7 +163,8 @@ extern const char lua_ident[]; + LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); + LUA_API void (lua_close) (lua_State *L); + LUA_API lua_State *(lua_newthread) (lua_State *L); +-LUA_API int (lua_resetthread) (lua_State *L, lua_State *from); ++LUA_API int (lua_closethread) (lua_State *L, lua_State *from); ++LUA_API int (lua_resetthread) (lua_State *L); /* Deprecated! */ + + LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); + +-- +2.33.0 + diff --git a/lua.spec b/lua.spec index 59db09f..356712f 100644 --- a/lua.spec +++ b/lua.spec @@ -6,7 +6,7 @@ Name: lua Version: 5.4.3 -Release: 13 +Release: 14 Summary: A powerful, efficient, lightweight, embeddable scripting language License: MIT URL: http://www.lua.org/ @@ -41,6 +41,7 @@ Patch6014: backport-CVE-2021-45985.patch Patch6015: backport-Bug-stack-overflow-with-nesting-of-coroutine.close.patch Patch6016: backport-Bug-Loading-a-corrupted-binary-file-can-segfault.patch Patch6017: backport-Bug-Recursion-in-getobjname-can-stack-overflow.patch +Patch6018: backport-Emergency-new-version-5.4.6.patch BuildRequires: automake autoconf libtool readline-devel ncurses-devel @@ -91,6 +92,7 @@ mv src/luaconf.h src/luaconf.h.template.in %patch6015 -p1 %patch6016 -p1 %patch6017 -p1 +%patch6018 -p1 # Put proper version in configure.ac, patch0 hardcodes 5.3.0 sed -i 's|5.3.0|%{version}|g' configure.ac @@ -165,6 +167,9 @@ LD_LIBRARY_PATH=$RPM_BUILD_ROOT/%{_libdir} $RPM_BUILD_ROOT/%{_bindir}/lua -e"_U= %{_mandir}/man1/lua*.1* %changelog +* Wed May 08 2024 fuanan - 5.4.3-14 +- add lua_closethread to adapt interfacechange + * Thu Jan 18 2024 yanglongkang - 5.4.3-13 - fix Segmentation fault -- Gitee