From ce441f7720b84fe03430ebef43abba85f2bef67a518227a6e7aec9e80b9be7ed Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sun, 30 Apr 2023 22:05:58 +0000 Subject: [PATCH 01/15] - Update to 5.4.5: - this is a bug-fix release. - Lua 5.4.5 also contains several internal improvements and includes a revised reference manual - Remove upstreamed patches: - luabugs1.patch - luabugs10.patch - luabugs11.patch - luabugs2.patch - luabugs6.patch - luabugs7.patch - luabugs8.patch - luabugs9.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=72 --- files_test.patch | 18 ++--- lua-5.4.4-tests.tar.gz | 3 - lua-5.4.4.tar.gz | 3 - lua-5.4.5-tests.tar.gz | 3 + lua-5.4.5.tar.gz | 3 + lua-build-system.patch | 85 +++++++++++------------ lua54.changes | 17 +++++ lua54.spec | 23 +++---- luabugs1.patch | 94 -------------------------- luabugs10.patch | 67 ------------------- luabugs11.patch | 77 --------------------- luabugs2.patch | 43 ------------ luabugs3.patch | 113 ++----------------------------- luabugs4.patch | 42 ++---------- luabugs5.patch | 131 ++---------------------------------- luabugs6.patch | 77 --------------------- luabugs7.patch | 118 -------------------------------- luabugs8.patch | 148 ----------------------------------------- luabugs9.patch | 102 ---------------------------- main_test.patch | 14 ++-- shared_link.patch | 34 ++++++---- 21 files changed, 130 insertions(+), 1085 deletions(-) delete mode 100644 lua-5.4.4-tests.tar.gz delete mode 100644 lua-5.4.4.tar.gz create mode 100644 lua-5.4.5-tests.tar.gz create mode 100644 lua-5.4.5.tar.gz delete mode 100644 luabugs1.patch delete mode 100644 luabugs10.patch delete mode 100644 luabugs11.patch delete mode 100644 luabugs2.patch delete mode 100644 luabugs6.patch delete mode 100644 luabugs7.patch delete mode 100644 luabugs8.patch delete mode 100644 luabugs9.patch diff --git a/files_test.patch b/files_test.patch index 035da1b..0cc9b4f 100644 --- a/files_test.patch +++ b/files_test.patch @@ -1,7 +1,9 @@ -Index: lua/files.lua -=================================================================== ---- lua.orig/testes/files.lua -+++ lua/testes/files.lua +--- + testes/files.lua | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +--- a/testes/files.lua ++++ b/testes/files.lua @@ -81,7 +81,7 @@ assert(io.output() ~= io.stdout) if not _port then -- invalid seek @@ -11,7 +13,7 @@ Index: lua/files.lua end assert(io.output():seek() == 0) -@@ -744,7 +744,7 @@ if not _port then +@@ -746,7 +746,7 @@ if not _port then {"exit 129", "exit", 129}, {"kill -s HUP $$", "signal", 1}, {"kill -s KILL $$", "signal", 9}, @@ -20,7 +22,7 @@ Index: lua/files.lua {progname .. ' -e " "', "ok"}, {progname .. ' -e "os.exit(0, true)"', "ok"}, {progname .. ' -e "os.exit(20, true)"', "exit", 20}, -@@ -757,6 +757,9 @@ if not _port then +@@ -759,6 +759,9 @@ if not _port then if v[2] == "ok" then assert(x and y == 'exit' and z == 0) else @@ -30,7 +32,7 @@ Index: lua/files.lua assert(not x and y == v[2]) -- correct status and 'what' -- correct code if known (but always different from 0) assert((v[3] == nil and z > 0) or v[3] == z) -@@ -791,6 +791,7 @@ assert(os.date(string.rep("%d", 1000), t +@@ -793,6 +796,7 @@ assert(os.date(string.rep("%d", 1000), t assert(os.date(string.rep("%", 200)) == string.rep("%", 100)) local function checkDateTable (t) @@ -38,7 +40,7 @@ Index: lua/files.lua _G.D = os.date("*t", t) assert(os.time(D) == t) load(os.date([[assert(D.year==%Y and D.month==%m and D.day==%d and -@@ -806,7 +806,9 @@ if not _port then +@@ -808,7 +812,9 @@ if not _port then checkDateTable(1) checkDateTable(1000) checkDateTable(0x7fffffff) diff --git a/lua-5.4.4-tests.tar.gz b/lua-5.4.4-tests.tar.gz deleted file mode 100644 index 9a141d7..0000000 --- a/lua-5.4.4-tests.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:04d28355cd67a2299dfe5708b55a0ff221ccb1a3907a3113cc103ccc05ac6aad -size 134094 diff --git a/lua-5.4.4.tar.gz b/lua-5.4.4.tar.gz deleted file mode 100644 index 7b39052..0000000 --- a/lua-5.4.4.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:164c7849653b80ae67bec4b7473b884bf5cc8d2dca05653475ec2ed27b9ebf61 -size 360876 diff --git a/lua-5.4.5-tests.tar.gz b/lua-5.4.5-tests.tar.gz new file mode 100644 index 0000000..226b0f0 --- /dev/null +++ b/lua-5.4.5-tests.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:856103e7298d354d870010b4966ce21281cbf3373abafd50231a98561bca793d +size 136198 diff --git a/lua-5.4.5.tar.gz b/lua-5.4.5.tar.gz new file mode 100644 index 0000000..f8d0b57 --- /dev/null +++ b/lua-5.4.5.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:59df426a3d50ea535a460a452315c4c0d4e1121ba72ff0bdde58c2ef31d6f444 +size 363316 diff --git a/lua-build-system.patch b/lua-build-system.patch index b4d5986..d957a1d 100644 --- a/lua-build-system.patch +++ b/lua-build-system.patch @@ -2,9 +2,15 @@ From: Enrico Tassi , Sergei Golovan + +- Update to 5.4.5: + - this is a bug-fix release. + - Lua 5.4.5 also contains several internal improvements and + includes a revised reference manual +- Remove upstreamed patches: + - luabugs1.patch + - luabugs10.patch + - luabugs11.patch + - luabugs2.patch + - luabugs6.patch + - luabugs7.patch + - luabugs8.patch + - luabugs9.patch + ------------------------------------------------------------------- Tue Apr 4 11:58:56 UTC 2023 - Callum Farmer diff --git a/lua54.spec b/lua54.spec index 2db321e..baa596a 100644 --- a/lua54.spec +++ b/lua54.spec @@ -1,5 +1,5 @@ # -# spec file for package lua54 +# spec file # # Copyright (c) 2023 SUSE LLC # @@ -15,6 +15,7 @@ # Please submit bugfixes or comments via https://bugs.opensuse.org/ # + %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" %define name_ext -test @@ -26,7 +27,7 @@ %define libname liblua5_4-5 Name: lua54%{name_ext} -Version: 5.4.4 +Version: 5.4.5 Release: 0 Summary: Small Embeddable Language with Procedural Syntax License: GPL-3.0-or-later @@ -44,17 +45,9 @@ Patch2: files_test.patch Patch3: main_test.patch Patch6: shared_link.patch # PATCH-FIX-UPSTREAM luabugsX.patch https://www.lua.org/bugs.html#5.4.4-X -Patch7: luabugs1.patch -Patch8: luabugs2.patch Patch9: luabugs3.patch Patch10: luabugs4.patch Patch11: luabugs5.patch -Patch12: luabugs6.patch -Patch13: luabugs7.patch -Patch14: luabugs8.patch -Patch15: luabugs9.patch -Patch16: luabugs10.patch -Patch17: luabugs11.patch # %if "%{flavor}" == "test" BuildRequires: lua54 @@ -65,7 +58,7 @@ BuildRequires: pkgconfig BuildRequires: readline-devel %endif Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives Provides: lua = %{version} Obsoletes: lua < %{version} Provides: Lua(API) = %{major_version} @@ -90,7 +83,7 @@ Requires: %{libname} = %{version} Requires: %{name} = %{version} Requires: lua-macros Requires(post): update-alternatives -Requires(postun): update-alternatives +Requires(postun):update-alternatives Provides: lua-devel = %{version} Provides: Lua(devel) = %{major_version} Provides: pkgconfig(lua) = %{version} @@ -186,9 +179,9 @@ includedir=%{_includedir}/lua%{major_version} INSTALL_LMOD=%{_datadir}/lua/%{major_version} INSTALL_CMOD=%{_libdir}/lua/%{major_version} -Name: Lua %{major_version} +Name: Lua %{major_version} Description: An Extensible Extension Language -Version: %{version} +Version: %{version} Libs: -llua%{major_version} -lm Cflags: -I\${includedir} EOF @@ -213,6 +206,7 @@ ln -sf %{_sysconfdir}/alternatives/liblua.so %{buildroot}%{_libdir}/liblua.so touch %{buildroot}%{_sysconfdir}/alternatives/lua.pc ln -sf %{_sysconfdir}/alternatives/lua.pc %{buildroot}%{_libdir}/pkgconfig/lua.pc %else + %check cd testes LD_LIBRARY_PATH=%{_libdir} %{_bindir}/lua%{major_version} all.lua @@ -286,4 +280,5 @@ fi %doc doc/* %endif + %changelog diff --git a/luabugs1.patch b/luabugs1.patch deleted file mode 100644 index 70a3feb..0000000 --- a/luabugs1.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 25b143dd34fb587d1e35290c4b25bc08954800e2 Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Mon, 7 Feb 2022 10:16:35 -0300 -Subject: [PATCH] Bug: lua.c assumes that argv has at least one element - ---- - lua.c | 35 +++++++++++++++++++++++------------ - 1 file changed, 23 insertions(+), 12 deletions(-) - -diff --git a/lua.c b/lua.c -index 0f1900444..7f7dc2b22 100644 ---- a/src/lua.c -+++ b/src/lua.c -@@ -177,10 +177,11 @@ static void print_version (void) { - ** to the script (everything after 'script') go to positive indices; - ** other arguments (before the script name) go to negative indices. - ** If there is no script name, assume interpreter's name as base. -+** (If there is no interpreter's name either, 'script' is -1, so -+** table sizes are zero.) - */ - static void createargtable (lua_State *L, char **argv, int argc, int script) { - int i, narg; -- if (script == argc) script = 0; /* no script name? */ - narg = argc - (script + 1); /* number of positive indices */ - lua_createtable(L, narg, script + 1); - for (i = 0; i < argc; i++) { -@@ -268,14 +269,23 @@ static int handle_script (lua_State *L, char **argv) { - - /* - ** Traverses all arguments from 'argv', returning a mask with those --** needed before running any Lua code (or an error code if it finds --** any invalid argument). 'first' returns the first not-handled argument --** (either the script name or a bad argument in case of error). -+** needed before running any Lua code or an error code if it finds any -+** invalid argument. In case of error, 'first' is the index of the bad -+** argument. Otherwise, 'first' is -1 if there is no program name, -+** 0 if there is no script name, or the index of the script name. - */ - static int collectargs (char **argv, int *first) { - int args = 0; - int i; -- for (i = 1; argv[i] != NULL; i++) { -+ if (argv[0] != NULL) { /* is there a program name? */ -+ if (argv[0][0]) /* not empty? */ -+ progname = argv[0]; /* save it */ -+ } -+ else { /* no program name */ -+ *first = -1; -+ return 0; -+ } -+ for (i = 1; argv[i] != NULL; i++) { /* handle arguments */ - *first = i; - if (argv[i][0] != '-') /* not an option? */ - return args; /* stop handling options */ -@@ -316,7 +326,7 @@ static int collectargs (char **argv, int *first) { - return has_error; - } - } -- *first = i; /* no script name */ -+ *first = 0; /* no script name */ - return args; - } - -@@ -609,8 +619,8 @@ static int pmain (lua_State *L) { - char **argv = (char **)lua_touserdata(L, 2); - int script; - int args = collectargs(argv, &script); -+ int optlim = (script > 0) ? script : argc; /* first argv not an option */ - luaL_checkversion(L); /* check that interpreter has correct version */ -- if (argv[0] && argv[0][0]) progname = argv[0]; - if (args == has_error) { /* bad arg? */ - print_usage(argv[script]); /* 'script' has index of bad arg. */ - return 0; -@@ -628,14 +638,15 @@ static int pmain (lua_State *L) { - if (handle_luainit(L) != LUA_OK) /* run LUA_INIT */ - return 0; /* error running LUA_INIT */ - } -- if (!runargs(L, argv, script)) /* execute arguments -e and -l */ -+ if (!runargs(L, argv, optlim)) /* execute arguments -e and -l */ - return 0; /* something failed */ -- if (script < argc && /* execute main script (if there is one) */ -- handle_script(L, argv + script) != LUA_OK) -- return 0; -+ if (script > 0) { /* execute main script (if there is one) */ -+ if (handle_script(L, argv + script) != LUA_OK) -+ return 0; /* interrupt in case of error */ -+ } - if (args & has_i) /* -i option? */ - doREPL(L); /* do read-eval-print loop */ -- else if (script == argc && !(args & (has_e | has_v))) { /* no arguments? */ -+ else if (script < 1 && !(args & (has_e | has_v))) { /* no active option? */ - if (lua_stdin_is_tty()) { /* running in interactive mode? */ - print_version(); - doREPL(L); /* do read-eval-print loop */ diff --git a/luabugs10.patch b/luabugs10.patch deleted file mode 100644 index 64324f8..0000000 --- a/luabugs10.patch +++ /dev/null @@ -1,67 +0,0 @@ -From 02bab9fc258fe1cbc6088b1bd61193499d058eff Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Wed, 8 Feb 2023 14:15:41 -0300 -Subject: [PATCH] Bug: Wrong line in error message for arith. errors - -It also causes 'L->top' to be wrong when the error happens, -triggering an 'assert'. ---- - lvm.c | 4 ++++ - testes/errors.lua | 8 ++++++++ - 2 files changed, 12 insertions(+) - -diff --git a/lvm.c b/lvm.c -index 2e84dc63c..8493a770c 100644 ---- a/src/lvm.c -+++ b/src/lvm.c -@@ -1410,6 +1410,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { - vmbreak; - } - vmcase(OP_MODK) { -+ savestate(L, ci); /* in case of division by 0 */ - op_arithK(L, luaV_mod, luaV_modf); - vmbreak; - } -@@ -1422,6 +1423,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { - vmbreak; - } - vmcase(OP_IDIVK) { -+ savestate(L, ci); /* in case of division by 0 */ - op_arithK(L, luaV_idiv, luai_numidiv); - vmbreak; - } -@@ -1470,6 +1472,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { - vmbreak; - } - vmcase(OP_MOD) { -+ savestate(L, ci); /* in case of division by 0 */ - op_arith(L, luaV_mod, luaV_modf); - vmbreak; - } -@@ -1482,6 +1485,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { - vmbreak; - } - vmcase(OP_IDIV) { /* floor division */ -+ savestate(L, ci); /* in case of division by 0 */ - op_arith(L, luaV_idiv, luai_numidiv); - vmbreak; - } -diff --git a/testes/errors.lua b/testes/errors.lua -index cf0ab5265..bf6f389d2 100644 ---- a/testes/errors.lua -+++ b/testes/errors.lua -@@ -444,6 +444,14 @@ if not b then - end - end]], 5) - -+ -+-- bug in 5.4.0 -+lineerror([[ -+ local a = 0 -+ local b = 1 -+ local c = b % a -+]], 3) -+ - do - -- Force a negative estimate for base line. Error in instruction 2 - -- (after VARARGPREP, GETGLOBAL), with first absolute line information diff --git a/luabugs11.patch b/luabugs11.patch deleted file mode 100644 index 63247ce..0000000 --- a/luabugs11.patch +++ /dev/null @@ -1,77 +0,0 @@ -From ab859fe59b464a038a45552921cb2b23892343af Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Fri, 17 Mar 2023 15:52:09 -0300 -Subject: [PATCH] Bug: Loading a corrupted binary file can segfault - -The size of the list of upvalue names are stored separated from the -size of the list of upvalues, but they share the same array. ---- - ldump.c | 8 ++++++-- - lundump.c | 2 ++ - testes/calls.lua | 14 ++++++++++++++ - 3 files changed, 22 insertions(+), 2 deletions(-) - -diff --git a/ldump.c b/ldump.c -index f848b669c..f231691b7 100644 ---- a/src/ldump.c -+++ b/src/ldump.c -@@ -10,6 +10,7 @@ - #include "lprefix.h" - - -+#include - #include - - #include "lua.h" -@@ -55,8 +56,11 @@ static void dumpByte (DumpState *D, int y) { - } - - --/* dumpInt Buff Size */ --#define DIBS ((sizeof(size_t) * 8 / 7) + 1) -+/* -+** 'dumpSize' buffer size: each byte can store up to 7 bits. (The "+6" -+** rounds up the division.) -+*/ -+#define DIBS ((sizeof(size_t) * CHAR_BIT + 6) / 7) - - static void dumpSize (DumpState *D, size_t x) { - lu_byte buff[DIBS]; -diff --git a/lundump.c b/lundump.c -index aba93f828..02aed64fb 100644 ---- a/src/lundump.c -+++ b/src/lundump.c -@@ -248,6 +248,8 @@ static void loadDebug (LoadState *S, Proto *f) { - f->locvars[i].endpc = loadInt(S); - } - n = loadInt(S); -+ if (n != 0) /* does it have debug information? */ -+ n = f->sizeupvalues; /* must be this many */ - for (i = 0; i < n; i++) - f->upvalues[i].name = loadStringN(S, f); - } -diff --git a/testes/calls.lua b/testes/calls.lua -index a19385843..2d562a24a 100644 ---- a/testes/calls.lua -+++ b/testes/calls.lua -@@ -342,6 +342,20 @@ do -- another bug (in 5.4.0) - end - - -+do -- another bug (since 5.2) -+ -- corrupted binary dump: list of upvalue names is larger than number -+ -- of upvalues, overflowing the array of upvalues. -+ local code = -+ "\x1b\x4c\x75\x61\x54\x00\x19\x93\x0d\x0a\x1a\x0a\x04\x08\x08\x78\x56\z -+ \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x28\x77\x40\x00\x86\x40\z -+ \x74\x65\x6d\x70\x81\x81\x01\x00\x02\x82\x48\x00\x02\x00\xc7\x00\x01\z -+ \x00\x80\x80\x80\x82\x00\x00\x80\x81\x82\x78\x80\x82\x81\x86\x40\x74\z -+ \x65\x6d\x70" -+ -+ assert(load(code)) -- segfaults in previous versions -+end -+ -+ - x = string.dump(load("x = 1; return x")) - a = assert(load(read1(x), nil, "b")) - assert(a() == 1 and _G.x == 1) diff --git a/luabugs2.patch b/luabugs2.patch deleted file mode 100644 index 8839c1e..0000000 --- a/luabugs2.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 1f3c6f4534c6411313361697d98d1145a1f030fa Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Tue, 15 Feb 2022 12:28:46 -0300 -Subject: [PATCH] Bug: Lua can generate wrong code when _ENV is - ---- - lparser.c | 1 + - testes/attrib.lua | 10 ++++++++++ - 2 files changed, 11 insertions(+) - -diff --git a/lparser.c b/lparser.c -index 3abe3d751..a5cd55257 100644 ---- a/src/lparser.c -+++ b/src/lparser.c -@@ -468,6 +468,7 @@ static void singlevar (LexState *ls, expdesc *var) { - expdesc key; - singlevaraux(fs, ls->envn, var, 1); /* get environment variable */ - lua_assert(var->k != VVOID); /* this one must exist */ -+ luaK_exp2anyregup(fs, var); /* but could be a constant */ - codestring(&key, varname); /* key is variable name */ - luaK_indexed(fs, var, &key); /* env[varname] */ - } -diff --git a/testes/attrib.lua b/testes/attrib.lua -index b1076c768..83821c069 100644 ---- a/testes/attrib.lua -+++ b/testes/attrib.lua -@@ -434,6 +434,16 @@ a.aVeryLongName012345678901234567890123456789012345678901234567890123456789 == - 10) - - -+do -+ -- _ENV constant -+ local function foo () -+ local _ENV = 11 -+ X = "hi" -+ end -+ local st, msg = pcall(foo) -+ assert(not st and string.find(msg, "number")) -+end -+ - - -- test of large float/integer indices - diff --git a/luabugs3.patch b/luabugs3.patch index 7a72db4..d963b73 100644 --- a/luabugs3.patch +++ b/luabugs3.patch @@ -4,120 +4,17 @@ Date: Mon, 25 Apr 2022 14:42:51 -0300 Subject: [PATCH] Bug: Wrong code generation in bitwise operations --- - lcode.c | 16 ++++++++++------ - ltests.h | 7 +++++++ - testes/constructs.lua | 25 +++++++++++++++++++++++++ - 3 files changed, 42 insertions(+), 6 deletions(-) + src/lcode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/lcode.c b/lcode.c -index 06425a1db..cb724a090 100644 --- a/src/lcode.c +++ b/src/lcode.c -@@ -1391,7 +1391,10 @@ static void finishbinexpval (FuncState *fs, expdesc *e1, expdesc *e2, - */ - static void codebinexpval (FuncState *fs, OpCode op, - expdesc *e1, expdesc *e2, int line) { -- int v2 = luaK_exp2anyreg(fs, e2); /* both operands are in registers */ -+ int v2 = luaK_exp2anyreg(fs, e2); /* make sure 'e2' is in a register */ -+ /* 'e1' must be already in a register or it is a constant */ -+ lua_assert((VNIL <= e1->k && e1->k <= VKSTR) || -+ e1->k == VNONRELOC || e1->k == VRELOC); - lua_assert(OP_ADD <= op && op <= OP_SHR); - finishbinexpval(fs, e1, e2, op, v2, 0, line, OP_MMBIN, - cast(TMS, (op - OP_ADD) + TM_ADD)); -@@ -1478,7 +1481,7 @@ static void codecommutative (FuncState *fs, BinOpr op, - - - /* --** Code bitwise operations; they are all associative, so the function -+** Code bitwise operations; they are all commutative, so the function - ** tries to put an integer constant as the 2nd operand (a K operand). - */ +@@ -1531,7 +1531,7 @@ static void codecommutative (FuncState * static void codebitwise (FuncState *fs, BinOpr opr, -@@ -1486,11 +1489,11 @@ static void codebitwise (FuncState *fs, BinOpr opr, + expdesc *e1, expdesc *e2, int line) { int flip = 0; - int v2; - OpCode op; -- if (e1->k == VKINT && luaK_exp2RK(fs, e1)) { +- if (e1->k == VKINT) { + if (e1->k == VKINT && luaK_exp2K(fs, e1)) { swapexps(e1, e2); /* 'e2' will be the constant operand */ flip = 1; } -- else if (!(e2->k == VKINT && luaK_exp2RK(fs, e2))) { /* no constants? */ -+ else if (!(e2->k == VKINT && luaK_exp2K(fs, e2))) { /* no constants? */ - op = cast(OpCode, opr + OP_ADD); - codebinexpval(fs, op, e1, e2, line); /* all-register opcodes */ - return; -@@ -1551,7 +1554,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { - op = OP_EQI; - r2 = im; /* immediate operand */ - } -- else if (luaK_exp2RK(fs, e2)) { /* 1st expression is constant? */ -+ else if (luaK_exp2RK(fs, e2)) { /* 2nd expression is constant? */ - op = OP_EQK; - r2 = e2->u.info; /* constant index */ - } -@@ -1611,7 +1614,8 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { - case OPR_SHL: case OPR_SHR: { - if (!tonumeral(v, NULL)) - luaK_exp2anyreg(fs, v); -- /* else keep numeral, which may be folded with 2nd operand */ -+ /* else keep numeral, which may be folded or used as an immediate -+ operand */ - break; - } - case OPR_EQ: case OPR_NE: { -diff --git a/ltests.h b/ltests.h -index cb3a0b480..ec520498b 100644 ---- a/testes/ltests/ltests.h -+++ b/testes/ltests/ltests.h -@@ -125,6 +125,13 @@ LUA_API void *debug_realloc (void *ud, void *block, - #define LUAI_USER_ALIGNMENT_T union { char b[sizeof(void*) * 8]; } - - -+/* -+** This one is not compatible with tests for opcode optimizations, -+** as it blocks some optimizations -+#define MAXINDEXRK 0 -+*/ -+ -+ - /* make stack-overflow tests run faster */ - #undef LUAI_MAXSTACK - #define LUAI_MAXSTACK 50000 -diff --git a/testes/constructs.lua b/testes/constructs.lua -index a74a8c041..0d9ec92d7 100644 ---- a/testes/constructs.lua -+++ b/testes/constructs.lua -@@ -103,6 +103,31 @@ do -- test old bug (first name could not be an `upvalue') - local a; function f(x) x={a=1}; x={x=1}; x={G=1} end - end - -+ -+do -- bug since 5.4.0 -+ -- create code with a table using more than 256 constants -+ local code = {"local x = {"} -+ for i = 1, 257 do -+ code[#code + 1] = i .. ".1," -+ end -+ code[#code + 1] = "};" -+ code = table.concat(code) -+ -+ -- add "ret" to the end of that code and checks that -+ -- it produces the expected value "val" -+ local function check (ret, val) -+ local code = code .. ret -+ code = load(code) -+ assert(code() == val) -+ end -+ -+ check("return (1 ~ (2 or 3))", 1 ~ 2) -+ check("return (1 | (2 or 3))", 1 | 2) -+ check("return (1 + (2 or 3))", 1 + 2) -+ check("return (1 << (2 or 3))", 1 << 2) -+end -+ -+ - function f (i) - if type(i) ~= 'number' then return i,'jojo'; end; - if i > 0 then return i, f(i-1); end; diff --git a/luabugs4.patch b/luabugs4.patch index 68f0053..ce3a5f1 100644 --- a/luabugs4.patch +++ b/luabugs4.patch @@ -11,48 +11,16 @@ the message handler), the code should use stack slots with parsimony. This commit fixes the bug "Lua-stack overflow when C stack overflows while handling an error". --- - ldebug.c | 5 ++++- - lvm.c | 6 ++++-- - 2 files changed, 8 insertions(+), 3 deletions(-) + src/lvm.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/ldebug.c b/ldebug.c -index a716d95e2..fa15eaf68 100644 ---- a/src/ldebug.c -+++ b/src/ldebug.c -@@ -824,8 +824,11 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { - va_start(argp, fmt); - msg = luaO_pushvfstring(L, fmt, argp); /* format message */ - va_end(argp); -- if (isLua(ci)) /* if Lua function, add source:line information */ -+ if (isLua(ci)) { /* if Lua function, add source:line information */ - luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); -+ setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */ -+ L->top--; -+ } - luaG_errormsg(L); - } - -diff --git a/lvm.c b/lvm.c -index e8c2e9627..cd992aada 100644 --- a/src/lvm.c +++ b/src/lvm.c -@@ -656,8 +656,10 @@ void luaV_concat (lua_State *L, int total) { - /* collect total length and number of strings */ - for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) { - size_t l = vslen(s2v(top - n - 1)); -- if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) -+ if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) { -+ L->top = top - total; /* pop strings to avoid wasting stack */ - luaG_runerror(L, "string length overflow"); -+ } - tl += l; - } - if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */ -@@ -672,7 +674,7 @@ void luaV_concat (lua_State *L, int total) { +@@ -674,7 +674,7 @@ void luaV_concat (lua_State *L, int tota setsvalue2s(L, top - n, ts); /* create result */ } - total -= n-1; /* got 'n' strings to create 1 new */ -- L->top -= n-1; /* popped 'n' strings and pushed one */ + total -= n - 1; /* got 'n' strings to create one new */ +- L->top.p -= n - 1; /* popped 'n' strings and pushed one */ + L->top = top - (n - 1); /* popped 'n' strings and pushed one */ } while (total > 1); /* repeat until only 1 result left */ } diff --git a/luabugs5.patch b/luabugs5.patch index 3bf9ca0..5aa983a 100644 --- a/luabugs5.patch +++ b/luabugs5.patch @@ -4,137 +4,16 @@ Date: Wed, 25 May 2022 17:41:39 -0300 Subject: [PATCH] Bug: 'lua_settop' may use an invalid pointer to stack --- - lapi.c | 5 ++--- - ldo.c | 12 ++++++------ - lfunc.c | 5 +++-- - lfunc.h | 2 +- - testes/locals.lua | 22 ++++++++++++++++++++++ - 5 files changed, 34 insertions(+), 12 deletions(-) + src/lfunc.c | 1 + + 1 file changed, 1 insertion(+) -diff --git a/lapi.c b/lapi.c -index 352a385a3..5833c7b0a 100644 ---- a/src/lapi.c -+++ b/src/lapi.c -@@ -197,7 +197,7 @@ LUA_API void lua_settop (lua_State *L, int idx) { - newtop = L->top + diff; - if (diff < 0 && L->tbclist >= newtop) { - lua_assert(hastocloseCfunc(ci->nresults)); -- luaF_close(L, newtop, CLOSEKTOP, 0); -+ newtop = luaF_close(L, newtop, CLOSEKTOP, 0); - } - L->top = newtop; /* correct top only after closing any upvalue */ - lua_unlock(L); -@@ -210,8 +210,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) { - level = index2stack(L, idx); - api_check(L, hastocloseCfunc(L->ci->nresults) && L->tbclist == level, - "no variable to close at given level"); -- luaF_close(L, level, CLOSEKTOP, 0); -- level = index2stack(L, idx); /* stack may be moved */ -+ level = luaF_close(L, level, CLOSEKTOP, 0); - setnilvalue(s2v(level)); - lua_unlock(L); - } -diff --git a/ldo.c b/ldo.c -index 5aa6d59d4..13498905f 100644 ---- a/src/ldo.c -+++ b/src/ldo.c -@@ -430,14 +430,15 @@ l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) { - break; - default: /* two/more results and/or to-be-closed variables */ - if (hastocloseCfunc(wanted)) { /* to-be-closed variables? */ -- ptrdiff_t savedres = savestack(L, res); - L->ci->callstatus |= CIST_CLSRET; /* in case of yields */ - L->ci->u2.nres = nres; -- luaF_close(L, res, CLOSEKTOP, 1); -+ res = luaF_close(L, res, CLOSEKTOP, 1); - L->ci->callstatus &= ~CIST_CLSRET; -- if (L->hookmask) /* if needed, call hook after '__close's */ -+ if (L->hookmask) { /* if needed, call hook after '__close's */ -+ ptrdiff_t savedres = savestack(L, res); - rethook(L, L->ci, nres); -- res = restorestack(L, savedres); /* close and hook can move stack */ -+ res = restorestack(L, savedres); /* hook can move stack */ -+ } - wanted = decodeNresults(wanted); - if (wanted == LUA_MULTRET) - wanted = nres; /* we want all results */ -@@ -654,8 +655,7 @@ static int finishpcallk (lua_State *L, CallInfo *ci) { - else { /* error */ - StkId func = restorestack(L, ci->u2.funcidx); - L->allowhook = getoah(ci->callstatus); /* restore 'allowhook' */ -- luaF_close(L, func, status, 1); /* can yield or raise an error */ -- func = restorestack(L, ci->u2.funcidx); /* stack may be moved */ -+ func = luaF_close(L, func, status, 1); /* can yield or raise an error */ - luaD_seterrorobj(L, status, func); - luaD_shrinkstack(L); /* restore stack size in case of overflow */ - setcistrecst(ci, LUA_OK); /* clear original status */ -diff --git a/lfunc.c b/lfunc.c -index f5889a21d..3ed65de2b 100644 --- a/src/lfunc.c +++ b/src/lfunc.c -@@ -223,9 +223,9 @@ static void poptbclist (lua_State *L) { - - /* - ** Close all upvalues and to-be-closed variables up to the given stack --** level. -+** level. Return restored 'level'. - */ --void luaF_close (lua_State *L, StkId level, int status, int yy) { -+StkId luaF_close (lua_State *L, StkId level, int status, int yy) { - ptrdiff_t levelrel = savestack(L, level); - luaF_closeupval(L, level); /* first, close the upvalues */ - while (L->tbclist >= level) { /* traverse tbc's down to that level */ -@@ -234,6 +234,7 @@ void luaF_close (lua_State *L, StkId level, int status, int yy) { - prepcallclosemth(L, tbc, status, yy); /* close variable */ - level = restorestack(L, levelrel); +@@ -204,6 +204,7 @@ void luaF_closeupval (lua_State *L, StkI + luaC_barrier(L, uv, slot); + } } + return level; } -diff --git a/lfunc.h b/lfunc.h -index dc1cebccd..3d296971e 100644 ---- a/src/lfunc.h -+++ b/src/lfunc.h -@@ -54,7 +54,7 @@ LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); - LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); - LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); - LUAI_FUNC void luaF_closeupval (lua_State *L, StkId level); --LUAI_FUNC void luaF_close (lua_State *L, StkId level, int status, int yy); -+LUAI_FUNC StkId luaF_close (lua_State *L, StkId level, int status, int yy); - LUAI_FUNC void luaF_unlinkupval (UpVal *uv); - LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); - LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, -diff --git a/testes/locals.lua b/testes/locals.lua -index 62a88df57..ddb75054f 100644 ---- a/testes/locals.lua -+++ b/testes/locals.lua -@@ -592,6 +592,28 @@ end - - if rawget(_G, "T") then - -+ do -+ -- bug in 5.4.3 -+ -- 'lua_settop' may use a pointer to stack invalidated by 'luaF_close' -+ -+ -- reduce stack size -+ collectgarbage(); collectgarbage(); collectgarbage() -+ -+ -- force a stack reallocation -+ local function loop (n) -+ if n < 400 then loop(n + 1) end -+ end -+ -+ -- close metamethod will reallocate the stack -+ local o = setmetatable({}, {__close = function () loop(0) end}) -+ -+ local script = [[toclose 2; settop 1; return 1]] -+ -+ assert(T.testC(script, o) == script) -+ -+ end -+ -+ - -- memory error inside closing function - local function foo () - local y = func2close(function () T.alloccount() end) diff --git a/luabugs6.patch b/luabugs6.patch deleted file mode 100644 index 2847814..0000000 --- a/luabugs6.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 997f11f54322883c3181225f29d101a597f31730 Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Wed, 24 Aug 2022 17:36:47 -0300 -Subject: [PATCH] Bug: 'break' may not properly close variable in a 'for' loop - -Function 'leaveblock' was generating "break" label before removing -variables from the closing block. If 'createlabel' created a 'close' -instruction (which it did when matching a goto/break that exited -the scope of an upvalue), that instruction would use the wrong level. ---- - lparser.c | 16 ++++++++-------- - testes/locals.lua | 20 ++++++++++++++++++++ - 2 files changed, 28 insertions(+), 8 deletions(-) - -diff --git a/lparser.c b/lparser.c -index a5cd55257..fe693b571 100644 ---- a/src/lparser.c -+++ b/src/lparser.c -@@ -674,19 +674,19 @@ static void leaveblock (FuncState *fs) { - LexState *ls = fs->ls; - int hasclose = 0; - int stklevel = reglevel(fs, bl->nactvar); /* level outside the block */ -- if (bl->isloop) /* fix pending breaks? */ -+ removevars(fs, bl->nactvar); /* remove block locals */ -+ lua_assert(bl->nactvar == fs->nactvar); /* back to level on entry */ -+ if (bl->isloop) /* has to fix pending breaks? */ - hasclose = createlabel(ls, luaS_newliteral(ls->L, "break"), 0, 0); -- if (!hasclose && bl->previous && bl->upval) -+ if (!hasclose && bl->previous && bl->upval) /* still need a 'close'? */ - luaK_codeABC(fs, OP_CLOSE, stklevel, 0, 0); -- fs->bl = bl->previous; -- removevars(fs, bl->nactvar); -- lua_assert(bl->nactvar == fs->nactvar); - fs->freereg = stklevel; /* free registers */ - ls->dyd->label.n = bl->firstlabel; /* remove local labels */ -- if (bl->previous) /* inner block? */ -- movegotosout(fs, bl); /* update pending gotos to outer block */ -+ fs->bl = bl->previous; /* current block now is previous one */ -+ if (bl->previous) /* was it a nested block? */ -+ movegotosout(fs, bl); /* update pending gotos to enclosing block */ - else { -- if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ -+ if (bl->firstgoto < ls->dyd->gt.n) /* still pending gotos? */ - undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ - } - } -diff --git a/testes/locals.lua b/testes/locals.lua -index ddb75054f..d50beaa52 100644 ---- a/testes/locals.lua -+++ b/testes/locals.lua -@@ -360,6 +360,26 @@ do - end - - -+do -+ -- bug in 5.4.4: 'break' may generate wrong 'close' instruction when -+ -- leaving a loop block. -+ -+ local closed = false -+ -+ local o1 = setmetatable({}, {__close=function() closed = true end}) -+ -+ local function test() -+ for k, v in next, {}, nil, o1 do -+ local function f() return k end -- create an upvalue -+ break -+ end -+ assert(closed) -+ end -+ -+ test() -+end -+ -+ - do print("testing errors in __close") - - -- original error is in __close diff --git a/luabugs7.patch b/luabugs7.patch deleted file mode 100644 index 3f3062a..0000000 --- a/luabugs7.patch +++ /dev/null @@ -1,118 +0,0 @@ -From a1f77a234a053da46b06d5d4be00ffb30d3eb45b Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Tue, 23 Aug 2022 16:06:23 -0300 -Subject: [PATCH] Bug: set correct pause when (re)entering gen. collection. - ---- - lgc.c | 63 +++++++++++++++++++++++++++++------------------------------ - 1 file changed, 31 insertions(+), 32 deletions(-) - -diff --git a/lgc.c b/lgc.c -index 42a73d813..317ea4508 100644 ---- a/src/lgc.c -+++ b/src/lgc.c -@@ -1041,7 +1041,25 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) { - ** ======================================================= - */ - --static void setpause (global_State *g); -+ -+/* -+** Set the "time" to wait before starting a new GC cycle; cycle will -+** start when memory use hits the threshold of ('estimate' * pause / -+** PAUSEADJ). (Division by 'estimate' should be OK: it cannot be zero, -+** because Lua cannot even start with less than PAUSEADJ bytes). -+*/ -+static void setpause (global_State *g) { -+ l_mem threshold, debt; -+ int pause = getgcparam(g->gcpause); -+ l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ -+ lua_assert(estimate > 0); -+ threshold = (pause < MAX_LMEM / estimate) /* overflow? */ -+ ? estimate * pause /* no overflow */ -+ : MAX_LMEM; /* overflow; truncate to maximum */ -+ debt = gettotalbytes(g) - threshold; -+ if (debt > 0) debt = 0; -+ luaE_setdebt(g, debt); -+} - - - /* -@@ -1285,6 +1303,15 @@ static void atomic2gen (lua_State *L, global_State *g) { - } - - -+/* -+** Set debt for the next minor collection, which will happen when -+** memory grows 'genminormul'%. -+*/ -+static void setminordebt (global_State *g) { -+ luaE_setdebt(g, -(cast(l_mem, (gettotalbytes(g) / 100)) * g->genminormul)); -+} -+ -+ - /* - ** Enter generational mode. Must go until the end of an atomic cycle - ** to ensure that all objects are correctly marked and weak tables -@@ -1297,6 +1324,7 @@ static lu_mem entergen (lua_State *L, global_State *g) { - luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */ - numobjs = atomic(L); /* propagates all and then do the atomic stuff */ - atomic2gen(L, g); -+ setminordebt(g); /* set debt assuming next cycle will be minor */ - return numobjs; - } - -@@ -1342,15 +1370,6 @@ static lu_mem fullgen (lua_State *L, global_State *g) { - } - - --/* --** Set debt for the next minor collection, which will happen when --** memory grows 'genminormul'%. --*/ --static void setminordebt (global_State *g) { -- luaE_setdebt(g, -(cast(l_mem, (gettotalbytes(g) / 100)) * g->genminormul)); --} -- -- - /* - ** Does a major collection after last collection was a "bad collection". - ** -@@ -1422,8 +1441,8 @@ static void genstep (lua_State *L, global_State *g) { - lu_mem numobjs = fullgen(L, g); /* do a major collection */ - if (gettotalbytes(g) < majorbase + (majorinc / 2)) { - /* collected at least half of memory growth since last major -- collection; keep doing minor collections */ -- setminordebt(g); -+ collection; keep doing minor collections. */ -+ lua_assert(g->lastatomic == 0); - } - else { /* bad collection */ - g->lastatomic = numobjs; /* signal that last collection was bad */ -@@ -1449,26 +1468,6 @@ static void genstep (lua_State *L, global_State *g) { - */ - - --/* --** Set the "time" to wait before starting a new GC cycle; cycle will --** start when memory use hits the threshold of ('estimate' * pause / --** PAUSEADJ). (Division by 'estimate' should be OK: it cannot be zero, --** because Lua cannot even start with less than PAUSEADJ bytes). --*/ --static void setpause (global_State *g) { -- l_mem threshold, debt; -- int pause = getgcparam(g->gcpause); -- l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ -- lua_assert(estimate > 0); -- threshold = (pause < MAX_LMEM / estimate) /* overflow? */ -- ? estimate * pause /* no overflow */ -- : MAX_LMEM; /* overflow; truncate to maximum */ -- debt = gettotalbytes(g) - threshold; -- if (debt > 0) debt = 0; -- luaE_setdebt(g, debt); --} -- -- - /* - ** Enter first sweep phase. - ** The call to 'sweeptolive' makes the pointer point to an object diff --git a/luabugs8.patch b/luabugs8.patch deleted file mode 100644 index f7dfbc9..0000000 --- a/luabugs8.patch +++ /dev/null @@ -1,148 +0,0 @@ -From a1089b415a3f5c753aa1b40758ffdaf28d5701b0 Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Fri, 23 Sep 2022 10:41:16 -0300 -Subject: [PATCH] Bug: 'utf8.codes' accepts spurious continuation bytes - ---- - lutf8lib.c | 27 ++++++++++++++++----------- - testes/utf8.lua | 12 +++++++++++- - 2 files changed, 27 insertions(+), 12 deletions(-) - -diff --git a/lutf8lib.c b/lutf8lib.c -index e7bf098f6..3a5b9bc38 100644 ---- a/src/lutf8lib.c -+++ b/src/lutf8lib.c -@@ -25,6 +25,9 @@ - - #define MAXUTF 0x7FFFFFFFu - -+ -+#define MSGInvalid "invalid UTF-8 code" -+ - /* - ** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits. - */ -@@ -35,7 +38,8 @@ typedef unsigned long utfint; - #endif - - --#define iscont(p) ((*(p) & 0xC0) == 0x80) -+#define iscont(c) (((c) & 0xC0) == 0x80) -+#define iscontp(p) iscont(*(p)) - - - /* from strlib */ -@@ -65,7 +69,7 @@ static const char *utf8_decode (const char *s, utfint *val, int strict) { - int count = 0; /* to count number of continuation bytes */ - for (; c & 0x40; c <<= 1) { /* while it needs continuation bytes... */ - unsigned int cc = (unsigned char)s[++count]; /* read next byte */ -- if ((cc & 0xC0) != 0x80) /* not a continuation byte? */ -+ if (!iscont(cc)) /* not a continuation byte? */ - return NULL; /* invalid byte sequence */ - res = (res << 6) | (cc & 0x3F); /* add lower 6 bits from cont. byte */ - } -@@ -140,7 +144,7 @@ static int codepoint (lua_State *L) { - utfint code; - s = utf8_decode(s, &code, !lax); - if (s == NULL) -- return luaL_error(L, "invalid UTF-8 code"); -+ return luaL_error(L, MSGInvalid); - lua_pushinteger(L, code); - n++; - } -@@ -190,16 +194,16 @@ static int byteoffset (lua_State *L) { - "position out of bounds"); - if (n == 0) { - /* find beginning of current byte sequence */ -- while (posi > 0 && iscont(s + posi)) posi--; -+ while (posi > 0 && iscontp(s + posi)) posi--; - } - else { -- if (iscont(s + posi)) -+ if (iscontp(s + posi)) - return luaL_error(L, "initial position is a continuation byte"); - if (n < 0) { - while (n < 0 && posi > 0) { /* move back */ - do { /* find beginning of previous character */ - posi--; -- } while (posi > 0 && iscont(s + posi)); -+ } while (posi > 0 && iscontp(s + posi)); - n++; - } - } -@@ -208,7 +212,7 @@ static int byteoffset (lua_State *L) { - while (n > 0 && posi < (lua_Integer)len) { - do { /* find beginning of next character */ - posi++; -- } while (iscont(s + posi)); /* (cannot pass final '\0') */ -+ } while (iscontp(s + posi)); /* (cannot pass final '\0') */ - n--; - } - } -@@ -226,15 +230,15 @@ static int iter_aux (lua_State *L, int strict) { - const char *s = luaL_checklstring(L, 1, &len); - lua_Unsigned n = (lua_Unsigned)lua_tointeger(L, 2); - if (n < len) { -- while (iscont(s + n)) n++; /* skip continuation bytes */ -+ while (iscontp(s + n)) n++; /* go to next character */ - } - if (n >= len) /* (also handles original 'n' being negative) */ - return 0; /* no more codepoints */ - else { - utfint code; - const char *next = utf8_decode(s + n, &code, strict); -- if (next == NULL) -- return luaL_error(L, "invalid UTF-8 code"); -+ if (next == NULL || iscontp(next)) -+ return luaL_error(L, MSGInvalid); - lua_pushinteger(L, n + 1); - lua_pushinteger(L, code); - return 2; -@@ -253,7 +257,8 @@ static int iter_auxlax (lua_State *L) { - - static int iter_codes (lua_State *L) { - int lax = lua_toboolean(L, 2); -- luaL_checkstring(L, 1); -+ const char *s = luaL_checkstring(L, 1); -+ luaL_argcheck(L, !iscontp(s), 1, MSGInvalid); - lua_pushcfunction(L, lax ? iter_auxlax : iter_auxstrict); - lua_pushvalue(L, 1); - lua_pushinteger(L, 0); -diff --git a/testes/utf8.lua b/testes/utf8.lua -index 461e223c7..7472cfd05 100644 ---- a/testes/utf8.lua -+++ b/testes/utf8.lua -@@ -97,9 +97,15 @@ do -- error indication in utf8.len - assert(not a and b == p) - end - check("abc\xE3def", 4) -- check("汉字\x80", #("汉字") + 1) - check("\xF4\x9F\xBF", 1) - check("\xF4\x9F\xBF\xBF", 1) -+ -- spurious continuation bytes -+ check("汉字\x80", #("汉字") + 1) -+ check("\x80hello", 1) -+ check("hel\x80lo", 4) -+ check("汉字\xBF", #("汉字") + 1) -+ check("\xBFhello", 1) -+ check("hel\xBFlo", 4) - end - - -- errors in utf8.codes -@@ -112,12 +118,16 @@ do - end - errorcodes("ab\xff") - errorcodes("\u{110000}") -+ errorcodes("in\x80valid") -+ errorcodes("\xbfinvalid") -+ errorcodes("αλφ\xBFα") - - -- calling interation function with invalid arguments - local f = utf8.codes("") - assert(f("", 2) == nil) - assert(f("", -1) == nil) - assert(f("", math.mininteger) == nil) -+ - end - - -- error in initial position for offset diff --git a/luabugs9.patch b/luabugs9.patch deleted file mode 100644 index c92cf1f..0000000 --- a/luabugs9.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 1e64c1391f9a14115b5cc82066dbf545ae73ee27 Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Tue, 25 Oct 2022 16:44:06 -0300 -Subject: [PATCH] Bug: stack overflow with nesting of coroutine.close - ---- - lcorolib.c | 4 ++-- - lstate.c | 3 ++- - ltests.c | 2 +- - lua.h | 2 +- - manual/manual.of | 7 ++++++- - testes/cstack.lua | 26 ++++++++++++++++++++++++++ - 6 files changed, 38 insertions(+), 6 deletions(-) - -diff --git a/lcorolib.c b/lcorolib.c -index 785a1e81a..40b880b14 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); /* close its tbc variables */ -+ stat = lua_resetthread(co, L); /* close its tbc variables */ - lua_assert(stat != LUA_OK); - lua_xmove(co, L, 1); /* move error message to the caller */ - } -@@ -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); -+ status = lua_resetthread(co, L); - if (status == LUA_OK) { - lua_pushboolean(L, 1); - return 1; -diff --git a/lstate.c b/lstate.c -index 1ffe1a0f7..4b5c10008 100644 ---- a/src/lstate.c -+++ b/src/lstate.c -@@ -343,9 +343,10 @@ int luaE_resetthread (lua_State *L, int status) { - } - - --LUA_API int lua_resetthread (lua_State *L) { -+LUA_API int lua_resetthread (lua_State *L, lua_State *from) { - int status; - lua_lock(L); -+ L->nCcalls = (from) ? getCcalls(from) : 0; - status = luaE_resetthread(L, L->status); - lua_unlock(L); - return status; -diff --git a/lua.h b/lua.h -index 219784cc0..bfba4d1e1 100644 ---- a/src/lua.h -+++ b/src/lua.h -@@ -153,7 +153,7 @@ 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_API int (lua_resetthread) (lua_State *L, lua_State *from); - - LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); - -diff --git a/testes/cstack.lua b/testes/cstack.lua -index ca76c8729..97afe9fd0 100644 ---- a/testes/cstack.lua -+++ b/testes/cstack.lua -@@ -84,6 +84,32 @@ do -- bug in 5.4.0 - end - - -+do -- bug since 5.4.0 -+ local count = 0 -+ print("chain of 'coroutine.close'") -+ -- create N coroutines forming a list so that each one, when closed, -+ -- closes the previous one. (With a large enough N, previous Lua -+ -- versions crash in this test.) -+ local coro = false -+ for i = 1, 1000 do -+ local previous = coro -+ coro = coroutine.create(function() -+ local cc = setmetatable({}, {__close=function() -+ count = count + 1 -+ if previous then -+ assert(coroutine.close(previous)) -+ end -+ end}) -+ coroutine.yield() -- leaves 'cc' pending to be closed -+ end) -+ assert(coroutine.resume(coro)) -- start it and run until it yields -+ end -+ local st, msg = coroutine.close(coro) -+ assert(not st and string.find(msg, "C stack overflow")) -+ print("final count: ", count) -+end -+ -+ - do - print("nesting of resuming yielded coroutines") - local count = 0 diff --git a/main_test.patch b/main_test.patch index 6ca0618..6978f1b 100644 --- a/main_test.patch +++ b/main_test.patch @@ -1,6 +1,10 @@ +--- + testes/main.lua | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + --- a/testes/main.lua +++ b/testes/main.lua -@@ -47,7 +47,7 @@ +@@ -47,7 +47,7 @@ local function checkprogout (s) assert(string.sub(s, -1) == "\n") local t = getoutput() for line in string.gmatch(s, ".-\n") do @@ -8,8 +12,8 @@ + -- assert(string.find(t, line, 1, true)) end end - -@@ -307,11 +307,11 @@ + +@@ -367,11 +367,11 @@ a = 2 ]] RUN([[lua -e "%s" -i < %s > %s]], prompt, prog, out) local t = getoutput() @@ -23,6 +27,6 @@ +-- 2a = 2 +-- 3 +-- ]], 1, true)) - - + + -- test for error objects diff --git a/shared_link.patch b/shared_link.patch index e835219..4ce2df2 100644 --- a/shared_link.patch +++ b/shared_link.patch @@ -1,28 +1,23 @@ +--- + src/ldebug.h | 2 +- + src/lmem.h | 2 +- + src/lundump.h | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + --- a/src/ldebug.h +++ b/src/ldebug.h @@ -36,7 +36,7 @@ #endif - - + + -LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); +LUA_API int luaG_getfuncline (const Proto *f, int pc); LUAI_FUNC const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, StkId *pos); LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, ---- a/src/lundump.h -+++ b/src/lundump.h -@@ -30,7 +30,7 @@ - LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); - - /* dump one chunk; from ldump.c */ --LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, -+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, - void* data, int strip); - - #endif --- a/src/lmem.h +++ b/src/lmem.h -@@ -81,7 +81,7 @@ +@@ -81,7 +81,7 @@ LUAI_FUNC void *luaM_realloc_ (lua_State size_t size); LUAI_FUNC void *luaM_saferealloc_ (lua_State *L, void *block, size_t oldsize, size_t size); @@ -31,3 +26,14 @@ LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int nelems, int *size, int size_elem, int limit, const char *what); +--- a/src/lundump.h ++++ b/src/lundump.h +@@ -30,7 +30,7 @@ + LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); + + /* dump one chunk; from ldump.c */ +-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, ++LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, + void* data, int strip); + + #endif From e780e2d22c22348423e1a4ed15ae2e8809f8ea3b21d9433cd595774eb607d8fa Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 1 May 2023 17:41:55 +0000 Subject: [PATCH 02/15] Remove two more upstreamed patches OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=73 --- lua54.changes | 2 ++ lua54.spec | 4 +--- luabugs4.patch | 27 --------------------------- luabugs5.patch | 19 ------------------- 4 files changed, 3 insertions(+), 49 deletions(-) delete mode 100644 luabugs4.patch delete mode 100644 luabugs5.patch diff --git a/lua54.changes b/lua54.changes index ce765a9..a56d85d 100644 --- a/lua54.changes +++ b/lua54.changes @@ -10,6 +10,8 @@ Sun Apr 30 12:22:03 UTC 2023 - Matej Cepl - luabugs10.patch - luabugs11.patch - luabugs2.patch + - luabugs4.patch + - luabugs5.patch - luabugs6.patch - luabugs7.patch - luabugs8.patch diff --git a/lua54.spec b/lua54.spec index baa596a..5d7e3db 100644 --- a/lua54.spec +++ b/lua54.spec @@ -45,9 +45,7 @@ Patch2: files_test.patch Patch3: main_test.patch Patch6: shared_link.patch # PATCH-FIX-UPSTREAM luabugsX.patch https://www.lua.org/bugs.html#5.4.4-X -Patch9: luabugs3.patch -Patch10: luabugs4.patch -Patch11: luabugs5.patch +# Patch9: luabugs3.patch # %if "%{flavor}" == "test" BuildRequires: lua54 diff --git a/luabugs4.patch b/luabugs4.patch deleted file mode 100644 index ce3a5f1..0000000 --- a/luabugs4.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 42d40581dd919fb134c07027ca1ce0844c670daf Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Fri, 20 May 2022 13:14:33 -0300 -Subject: [PATCH] Save stack space while handling errors - -Because error handling (luaG_errormsg) uses slots from EXTRA_STACK, -and some errors can recur (e.g., string overflow while creating an -error message in 'luaG_runerror', or a C-stack overflow before calling -the message handler), the code should use stack slots with parsimony. - -This commit fixes the bug "Lua-stack overflow when C stack overflows -while handling an error". ---- - src/lvm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/src/lvm.c -+++ b/src/lvm.c -@@ -674,7 +674,7 @@ void luaV_concat (lua_State *L, int tota - setsvalue2s(L, top - n, ts); /* create result */ - } - total -= n - 1; /* got 'n' strings to create one new */ -- L->top.p -= n - 1; /* popped 'n' strings and pushed one */ -+ L->top = top - (n - 1); /* popped 'n' strings and pushed one */ - } while (total > 1); /* repeat until only 1 result left */ - } - diff --git a/luabugs5.patch b/luabugs5.patch deleted file mode 100644 index 5aa983a..0000000 --- a/luabugs5.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 196bb94d66e727e0aec053a0276c3ad701500762 Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Wed, 25 May 2022 17:41:39 -0300 -Subject: [PATCH] Bug: 'lua_settop' may use an invalid pointer to stack - ---- - src/lfunc.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/src/lfunc.c -+++ b/src/lfunc.c -@@ -204,6 +204,7 @@ void luaF_closeupval (lua_State *L, StkI - luaC_barrier(L, uv, slot); - } - } -+ return level; - } - - From ea7fea61b8fcc7abf1fb840d88ae7fb9a82d92b61517e858a446033248029489 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 4 May 2023 21:21:08 +0000 Subject: [PATCH 03/15] - luabugs3.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=74 --- attrib_test.patch | 4 ++++ lua-build-system.patch | 20 ++++++++++++-------- lua54.changes | 1 + lua54.spec | 16 +++++++++++----- luabugs3.patch | 20 -------------------- 5 files changed, 28 insertions(+), 33 deletions(-) delete mode 100644 luabugs3.patch diff --git a/attrib_test.patch b/attrib_test.patch index d5fd3be..46c9817 100644 --- a/attrib_test.patch +++ b/attrib_test.patch @@ -1,3 +1,7 @@ +--- + testes/attrib.lua | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + --- a/testes/attrib.lua +++ b/testes/attrib.lua @@ -269,7 +269,7 @@ local p = "" -- On Mac OS X, redefine diff --git a/lua-build-system.patch b/lua-build-system.patch index d957a1d..288b7d9 100644 --- a/lua-build-system.patch +++ b/lua-build-system.patch @@ -4,9 +4,9 @@ Subject: build system --- Makefile | 22 +++++++++++----------- - src/Makefile | 42 ++++++++++++++++++++++++------------------ + src/Makefile | 43 +++++++++++++++++++++++++------------------ src/luaconf.h | 2 +- - 3 files changed, 36 insertions(+), 30 deletions(-) + 3 files changed, 37 insertions(+), 30 deletions(-) --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ Subject: build system TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 -+TO_LIB= liblua$(V).la ++TO_LIB= liblua$(V).a +TO_MAN= lua$(V).1 luac$(V).1 # Lua version and release. @@ -76,7 +76,11 @@ Subject: build system LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) LIBS= -lm $(SYSLIBS) $(MYLIBS) -@@ -22,25 +22,40 @@ SYSLIBS= +@@ -19,28 +19,44 @@ UNAME= uname + SYSCFLAGS= + SYSLDFLAGS= + SYSLIBS= ++LIBDIR=/usr/lib MYCFLAGS= MYLDFLAGS= @@ -121,13 +125,13 @@ Subject: build system LUAC_O= luac.o ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) -@@ -57,17 +72,16 @@ o: $(ALL_O) +@@ -57,17 +73,16 @@ o: $(ALL_O) a: $(ALL_A) $(LUA_A): $(BASE_O) - $(AR) $@ $(BASE_O) - $(RANLIB) $@ -+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -shared -rpath /usr/lib -version-info 9:0:4 -o $(LUA_A) ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -shared -rpath $(LIBDIR) -version-info 9:0:4 -o $(LUA_A) $(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) @@ -135,7 +139,7 @@ Subject: build system $(LUAC_T): $(LUAC_O) $(LUA_A) - $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) -+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LUA_A) luac.lo -o $@ ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LUA_A) luac.lo -lm -o $@ test: - ./$(LUA_T) -v @@ -143,7 +147,7 @@ Subject: build system clean: $(RM) $(ALL_T) $(ALL_O) -@@ -147,14 +161,6 @@ SunOS solaris: +@@ -147,14 +162,6 @@ SunOS solaris: .PHONY: all $(PLATS) help test clean default o a depend echo # Compiler modules may use special flags. diff --git a/lua54.changes b/lua54.changes index a56d85d..50ac443 100644 --- a/lua54.changes +++ b/lua54.changes @@ -10,6 +10,7 @@ Sun Apr 30 12:22:03 UTC 2023 - Matej Cepl - luabugs10.patch - luabugs11.patch - luabugs2.patch + - luabugs3.patch - luabugs4.patch - luabugs5.patch - luabugs6.patch diff --git a/lua54.spec b/lua54.spec index 5d7e3db..65e91d3 100644 --- a/lua54.spec +++ b/lua54.spec @@ -44,9 +44,6 @@ Patch1: attrib_test.patch Patch2: files_test.patch Patch3: main_test.patch Patch6: shared_link.patch -# PATCH-FIX-UPSTREAM luabugsX.patch https://www.lua.org/bugs.html#5.4.4-X -# Patch9: luabugs3.patch -# %if "%{flavor}" == "test" BuildRequires: lua54 %else @@ -155,7 +152,7 @@ cat doc/luac.1 | sed 's/TH LUAC 1/TH LUAC%{major_version} 1/' > doc/luac%{major_ %build sed -i -e "s@lib/lua/@%{_lib}/lua/@g" src/luaconf.h make linux-readline %{_smp_mflags} VERBOSE=1 -C src \ - CC="cc" \ + CC="cc" LIBDIR="%{_libdir}" \ MYCFLAGS="%{optflags} -std=gnu99 -D_GNU_SOURCE -fPIC -DLUA_COMPAT_MODULE" \ V=%{major_version} \ LIBTOOL="libtool --quiet" @@ -164,7 +161,8 @@ make linux-readline %{_smp_mflags} VERBOSE=1 -C src \ %make_install \ LIBTOOL="libtool --quiet" \ INSTALL_TOP="%{buildroot}%{_prefix}" \ - INSTALL_LIB="%{buildroot}%{_libdir}" + INSTALL_LIB="%{buildroot}%{_libdir}" \ + INSTALL_MAN="%{buildroot}%{_mandir}/man1" find %{buildroot} -type f -name "*.la" -delete -print @@ -194,6 +192,14 @@ for file in lua luac ; do ln -sf "%{_sysconfdir}/alternatives/${file}.1%{ext_man}" "%{buildroot}%{_mandir}/man1/${file}.1%{ext_man}" done +# lrwxrwxrwx. 1 abuild abuild 27 May 3 21:50 liblua.so -> /etc/alternatives/liblua.so +# lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua.so.5.4 -> liblua5.4.so.5.4.0 +# -rw-r--r--. 1 abuild abuild 30352 May 3 21:50 liblua5.4.a +# lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua5.4.so.0 -> liblua5.4.so.5.4.0 +# lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua5.4.so.5.4 -> liblua5.4.so.5.4.0 +# drwxr-xr-x. 1 abuild abuild 6 May 3 21:50 lua +# drwxr-xr-x. 1 abuild abuild 30 May 3 21:50 pkgconfig + # Compat link with older unprefixed library and with soname 0 from deb/etc ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version} ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0 diff --git a/luabugs3.patch b/luabugs3.patch deleted file mode 100644 index d963b73..0000000 --- a/luabugs3.patch +++ /dev/null @@ -1,20 +0,0 @@ -From c764ca71a639f5585b5f466bea25dc42b855a4b0 Mon Sep 17 00:00:00 2001 -From: Roberto Ierusalimschy -Date: Mon, 25 Apr 2022 14:42:51 -0300 -Subject: [PATCH] Bug: Wrong code generation in bitwise operations - ---- - src/lcode.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/src/lcode.c -+++ b/src/lcode.c -@@ -1531,7 +1531,7 @@ static void codecommutative (FuncState * - static void codebitwise (FuncState *fs, BinOpr opr, - expdesc *e1, expdesc *e2, int line) { - int flip = 0; -- if (e1->k == VKINT) { -+ if (e1->k == VKINT && luaK_exp2K(fs, e1)) { - swapexps(e1, e2); /* 'e2' will be the constant operand */ - flip = 1; - } From aaddd414569f6887f969f14a8adbd3e806c8144c850b8b850f1507634a1b9f3b Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 9 May 2023 12:30:50 +0000 Subject: [PATCH 04/15] WIP OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=75 --- baselibs.conf | 2 +- lua-5.4.5.tar.gz | 3 --- lua-5.4.6-rc1.tar.gz | 3 +++ lua54.spec | 17 +++++++++++------ 4 files changed, 15 insertions(+), 10 deletions(-) delete mode 100644 lua-5.4.5.tar.gz create mode 100644 lua-5.4.6-rc1.tar.gz diff --git a/baselibs.conf b/baselibs.conf index 2fa28f4..54c7f60 100644 --- a/baselibs.conf +++ b/baselibs.conf @@ -1 +1 @@ -liblua5_4-5 +liblua5_4-6 diff --git a/lua-5.4.5.tar.gz b/lua-5.4.5.tar.gz deleted file mode 100644 index f8d0b57..0000000 --- a/lua-5.4.5.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:59df426a3d50ea535a460a452315c4c0d4e1121ba72ff0bdde58c2ef31d6f444 -size 363316 diff --git a/lua-5.4.6-rc1.tar.gz b/lua-5.4.6-rc1.tar.gz new file mode 100644 index 0000000..ac89c8d --- /dev/null +++ b/lua-5.4.6-rc1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7d5ea1b9cb6aa0b59ca3dde1c6adcb57ef83a1ba8e5432c0ecd06bf439b3ad88 +size 363329 diff --git a/lua54.spec b/lua54.spec index 65e91d3..b7a1578 100644 --- a/lua54.spec +++ b/lua54.spec @@ -24,17 +24,17 @@ %define name_ext %{nil} %endif %define major_version 5.4 -%define libname liblua5_4-5 +%define libname liblua5_4-6 Name: lua54%{name_ext} -Version: 5.4.5 +Version: 5.4.6~rc1 Release: 0 Summary: Small Embeddable Language with Procedural Syntax License: GPL-3.0-or-later Group: Development/Languages/Other URL: https://www.lua.org -Source: http://www.lua.org/ftp/lua-%{version}.tar.gz -Source1: http://www.lua.org/tests/lua-%{version}-tests.tar.gz +Source: https://www.lua.org/work/lua-5.4.6-rc1.tar.gz +Source1: https://www.lua.org/tests/lua-5.4.5-tests.tar.gz Source99: baselibs.conf # PATCH-FIX-SUSE tweak the buildsystem to produce what is needed for SUSE Patch0: lua-build-system.patch @@ -140,8 +140,8 @@ scripting, and rapid prototyping. Lua is implemented as a small library of C functions, written in ANSI C. %prep -%setup -q -n lua-%{version} -a1 -mv lua-%{version}-tests testes +%setup -q -n lua-5.4.6 -a1 +mv lua-5.4.5-tests testes %autopatch -p1 # manpage @@ -164,6 +164,8 @@ make linux-readline %{_smp_mflags} VERBOSE=1 -C src \ INSTALL_LIB="%{buildroot}%{_libdir}" \ INSTALL_MAN="%{buildroot}%{_mandir}/man1" +find %{buildroot} -name \*.so\* -ls + find %{buildroot} -type f -name "*.la" -delete -print # create pkg-config file @@ -181,6 +183,7 @@ Version: %{version} Libs: -llua%{major_version} -lm Cflags: -I\${includedir} EOF + install -D -m 644 lua%{major_version}.pc %{buildroot}%{_libdir}/pkgconfig/lua%{major_version}.pc # update-alternatives @@ -192,6 +195,8 @@ for file in lua luac ; do ln -sf "%{_sysconfdir}/alternatives/${file}.1%{ext_man}" "%{buildroot}%{_mandir}/man1/${file}.1%{ext_man}" done +# /home/abuild/rpmbuild/BUILDROOT/lua54-5.4.6~rc1-0.x86_64/usr/lib64/liblua5.4.so + # lrwxrwxrwx. 1 abuild abuild 27 May 3 21:50 liblua.so -> /etc/alternatives/liblua.so # lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua.so.5.4 -> liblua5.4.so.5.4.0 # -rw-r--r--. 1 abuild abuild 30352 May 3 21:50 liblua5.4.a From 5868047cb497ab1ec03fc262dd37f7bf03a6d07ccb4de472193f5daaa4682138 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Tue, 9 May 2023 12:57:44 +0000 Subject: [PATCH 05/15] - Experimenting with lua 5.4.6-rc1 (release 5.4.5 has been effectively withdrawn). OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=76 --- lua-build-system.patch | 8 ++++---- lua54.changes | 6 ++++++ lua54.spec | 14 +------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lua-build-system.patch b/lua-build-system.patch index 288b7d9..6e345c8 100644 --- a/lua-build-system.patch +++ b/lua-build-system.patch @@ -44,12 +44,12 @@ Subject: build system TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp -TO_LIB= liblua.a -TO_MAN= lua.1 luac.1 -+TO_LIB= liblua$(V).a ++TO_LIB= liblua$(V).la +TO_MAN= lua$(V).1 luac$(V).1 # Lua version and release. V= 5.4 -@@ -52,13 +52,13 @@ R= $V.5 +@@ -52,13 +52,13 @@ R= $V.6 all: $(PLAT) $(PLATS) help test clean: @@ -111,7 +111,7 @@ Subject: build system PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris -LUA_A= liblua.a -+LUA_A= liblua$(V).a ++LUA_A= liblua$(V).la CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) @@ -139,7 +139,7 @@ Subject: build system $(LUAC_T): $(LUAC_O) $(LUA_A) - $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) -+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LUA_A) luac.lo -lm -o $@ ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LUA_A) luac.lo -o $@ test: - ./$(LUA_T) -v diff --git a/lua54.changes b/lua54.changes index 50ac443..113214f 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue May 9 12:43:31 UTC 2023 - Matej Cepl + +- Experimenting with lua 5.4.6-rc1 (release 5.4.5 has been + effectively withdrawn). + ------------------------------------------------------------------- Sun Apr 30 12:22:03 UTC 2023 - Matej Cepl diff --git a/lua54.spec b/lua54.spec index b7a1578..666fce5 100644 --- a/lua54.spec +++ b/lua54.spec @@ -164,8 +164,6 @@ make linux-readline %{_smp_mflags} VERBOSE=1 -C src \ INSTALL_LIB="%{buildroot}%{_libdir}" \ INSTALL_MAN="%{buildroot}%{_mandir}/man1" -find %{buildroot} -name \*.so\* -ls - find %{buildroot} -type f -name "*.la" -delete -print # create pkg-config file @@ -195,19 +193,9 @@ for file in lua luac ; do ln -sf "%{_sysconfdir}/alternatives/${file}.1%{ext_man}" "%{buildroot}%{_mandir}/man1/${file}.1%{ext_man}" done -# /home/abuild/rpmbuild/BUILDROOT/lua54-5.4.6~rc1-0.x86_64/usr/lib64/liblua5.4.so - -# lrwxrwxrwx. 1 abuild abuild 27 May 3 21:50 liblua.so -> /etc/alternatives/liblua.so -# lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua.so.5.4 -> liblua5.4.so.5.4.0 -# -rw-r--r--. 1 abuild abuild 30352 May 3 21:50 liblua5.4.a -# lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua5.4.so.0 -> liblua5.4.so.5.4.0 -# lrwxrwxrwx. 1 abuild abuild 18 May 3 21:50 liblua5.4.so.5.4 -> liblua5.4.so.5.4.0 -# drwxr-xr-x. 1 abuild abuild 6 May 3 21:50 lua -# drwxr-xr-x. 1 abuild abuild 30 May 3 21:50 pkgconfig - # Compat link with older unprefixed library and with soname 0 from deb/etc ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version} -ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0 +# ln -s %%{_libdir}/liblua%%{major_version}.so.%%{major_version}.0 %%{buildroot}%%{_libdir}/liblua%%{major_version}.so.0 ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version} # Library devel alternatives touch %{buildroot}%{_sysconfdir}/alternatives/liblua.so From d4fcca537efff0111f3698209eb3fc0639d565c6ab9ef87468a96fc466758006 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 9 May 2023 13:02:50 +0000 Subject: [PATCH 06/15] Always 5.4.0 in SOVER so doesn't change OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=77 --- lua54.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua54.spec b/lua54.spec index 666fce5..f927f29 100644 --- a/lua54.spec +++ b/lua54.spec @@ -24,7 +24,7 @@ %define name_ext %{nil} %endif %define major_version 5.4 -%define libname liblua5_4-6 +%define libname liblua5_4-5 Name: lua54%{name_ext} Version: 5.4.6~rc1 From 203eb7c0ff544754665dfc7a60e92147fcffeb3aab238dc3917e8ce96612276f Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 9 May 2023 13:03:38 +0000 Subject: [PATCH 07/15] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=78 --- lua54.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua54.spec b/lua54.spec index f927f29..63cce80 100644 --- a/lua54.spec +++ b/lua54.spec @@ -195,7 +195,7 @@ done # Compat link with older unprefixed library and with soname 0 from deb/etc ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version} -# ln -s %%{_libdir}/liblua%%{major_version}.so.%%{major_version}.0 %%{buildroot}%%{_libdir}/liblua%%{major_version}.so.0 +ln -s %%{_libdir}/liblua%%{major_version}.so.%%{major_version}.0 %%{buildroot}%%{_libdir}/liblua%%{major_version}.so.0 ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version} # Library devel alternatives touch %{buildroot}%{_sysconfdir}/alternatives/liblua.so From ed5fc9b60dfca5bc1fdabe2dd7d99d700181415825abf26960fbf3bcb9cf2c9f Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 9 May 2023 13:06:09 +0000 Subject: [PATCH 08/15] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=79 --- lua54.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua54.spec b/lua54.spec index 63cce80..91dc756 100644 --- a/lua54.spec +++ b/lua54.spec @@ -195,7 +195,7 @@ done # Compat link with older unprefixed library and with soname 0 from deb/etc ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version} -ln -s %%{_libdir}/liblua%%{major_version}.so.%%{major_version}.0 %%{buildroot}%%{_libdir}/liblua%%{major_version}.so.0 +ln -s %{_libdir}/liblua%%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0 ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version} # Library devel alternatives touch %{buildroot}%{_sysconfdir}/alternatives/liblua.so From ffe731f969158bf33abfc69e0557bad7f18dff64d0bd573c9dacd1b88b295486 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 9 May 2023 13:06:27 +0000 Subject: [PATCH 09/15] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=80 --- lua54.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua54.spec b/lua54.spec index 91dc756..00eb9da 100644 --- a/lua54.spec +++ b/lua54.spec @@ -195,7 +195,7 @@ done # Compat link with older unprefixed library and with soname 0 from deb/etc ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.%{major_version} -ln -s %{_libdir}/liblua%%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0 +ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua%{major_version}.so.0 ln -s %{_libdir}/liblua%{major_version}.so.%{major_version}.0 %{buildroot}%{_libdir}/liblua.so.%{major_version} # Library devel alternatives touch %{buildroot}%{_sysconfdir}/alternatives/liblua.so From a480ec0033c08ac6acb8d2c6a78b5a4566e9a770ccd759d1bb86c8b62be3353a Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 9 May 2023 13:08:12 +0000 Subject: [PATCH 10/15] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=81 --- baselibs.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baselibs.conf b/baselibs.conf index 54c7f60..2fa28f4 100644 --- a/baselibs.conf +++ b/baselibs.conf @@ -1 +1 @@ -liblua5_4-6 +liblua5_4-5 From 0fa24a50beeffea849a56ebe3bd0b6718840fafe8a79eac38e64aaae7e09a430 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 22 May 2023 10:09:46 +0000 Subject: [PATCH 11/15] - Final release of 5.4.6. No change in the changelog. OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=82 --- baselibs.conf | 2 +- lua-5.4.5-tests.tar.gz | 3 --- lua-5.4.6-tests.tar.gz | 3 +++ lua-5.4.6-rc1.tar.gz => lua-5.4.6.tar.gz | 0 lua54.changes | 5 +++++ lua54.spec | 14 ++++++++------ 6 files changed, 17 insertions(+), 10 deletions(-) delete mode 100644 lua-5.4.5-tests.tar.gz create mode 100644 lua-5.4.6-tests.tar.gz rename lua-5.4.6-rc1.tar.gz => lua-5.4.6.tar.gz (100%) diff --git a/baselibs.conf b/baselibs.conf index 2fa28f4..54c7f60 100644 --- a/baselibs.conf +++ b/baselibs.conf @@ -1 +1 @@ -liblua5_4-5 +liblua5_4-6 diff --git a/lua-5.4.5-tests.tar.gz b/lua-5.4.5-tests.tar.gz deleted file mode 100644 index 226b0f0..0000000 --- a/lua-5.4.5-tests.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:856103e7298d354d870010b4966ce21281cbf3373abafd50231a98561bca793d -size 136198 diff --git a/lua-5.4.6-tests.tar.gz b/lua-5.4.6-tests.tar.gz new file mode 100644 index 0000000..0122ec1 --- /dev/null +++ b/lua-5.4.6-tests.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:63ed5f5bcfd15dfd2f72e04c2f8c10585bb8de9e558df62b335cb9e5c1a4ef34 +size 136212 diff --git a/lua-5.4.6-rc1.tar.gz b/lua-5.4.6.tar.gz similarity index 100% rename from lua-5.4.6-rc1.tar.gz rename to lua-5.4.6.tar.gz diff --git a/lua54.changes b/lua54.changes index 113214f..bd05188 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon May 22 09:39:52 UTC 2023 - Matej Cepl + +- Final release of 5.4.6. No change in the changelog. + ------------------------------------------------------------------- Tue May 9 12:43:31 UTC 2023 - Matej Cepl diff --git a/lua54.spec b/lua54.spec index 00eb9da..e60fa46 100644 --- a/lua54.spec +++ b/lua54.spec @@ -24,17 +24,17 @@ %define name_ext %{nil} %endif %define major_version 5.4 -%define libname liblua5_4-5 +%define libname liblua5_4-6 Name: lua54%{name_ext} -Version: 5.4.6~rc1 +Version: 5.4.6 Release: 0 Summary: Small Embeddable Language with Procedural Syntax License: GPL-3.0-or-later Group: Development/Languages/Other URL: https://www.lua.org -Source: https://www.lua.org/work/lua-5.4.6-rc1.tar.gz -Source1: https://www.lua.org/tests/lua-5.4.5-tests.tar.gz +Source: https://www.lua.org/ftp/lua-%{version}.tar.gz +Source1: https://www.lua.org/tests/lua-%{version}-tests.tar.gz Source99: baselibs.conf # PATCH-FIX-SUSE tweak the buildsystem to produce what is needed for SUSE Patch0: lua-build-system.patch @@ -140,8 +140,8 @@ scripting, and rapid prototyping. Lua is implemented as a small library of C functions, written in ANSI C. %prep -%setup -q -n lua-5.4.6 -a1 -mv lua-5.4.5-tests testes +%setup -q -n lua-%{version} -a1 +mv lua-%{version}-tests testes %autopatch -p1 # manpage @@ -209,6 +209,8 @@ cd testes LD_LIBRARY_PATH=%{_libdir} %{_bindir}/lua%{major_version} all.lua %endif +%clean + %if "%{flavor}" != "test" %post -n %{libname} -p /sbin/ldconfig %postun -n %{libname} -p /sbin/ldconfig From f47f672f23f80d15101600a71a62b147926ba8b56204d3bd204be54728a608f5 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 22 May 2023 11:20:56 +0000 Subject: [PATCH 12/15] Clean up SPEC file. OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=83 --- lua54.spec | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lua54.spec b/lua54.spec index e60fa46..68837b1 100644 --- a/lua54.spec +++ b/lua54.spec @@ -25,7 +25,6 @@ %endif %define major_version 5.4 %define libname liblua5_4-6 - Name: lua54%{name_ext} Version: 5.4.6 Release: 0 @@ -44,6 +43,11 @@ Patch1: attrib_test.patch Patch2: files_test.patch Patch3: main_test.patch Patch6: shared_link.patch +Requires(post): update-alternatives +Requires(postun):update-alternatives +Provides: lua = %{version} +Obsoletes: lua < %{version} +Provides: Lua(API) = %{major_version} %if "%{flavor}" == "test" BuildRequires: lua54 %else @@ -52,11 +56,6 @@ BuildRequires: lua-macros BuildRequires: pkgconfig BuildRequires: readline-devel %endif -Requires(post): update-alternatives -Requires(postun):update-alternatives -Provides: lua = %{version} -Obsoletes: lua < %{version} -Provides: Lua(API) = %{major_version} %description Lua is a programming language originally designed for extending @@ -95,16 +94,16 @@ application. Summary: The Lua integration library License: MIT Group: System/Libraries +Provides: liblua5_4 = %{version}-%{release} +Obsoletes: liblua5_4 < %{version}-%{release} +Provides: %{name}-libs = %{version} +Obsoletes: %{name}-libs < %{version} # Compat as libtool changes the soname %ifarch aarch64 x86_64 ppc64 ppc64le s390x riscv64 Provides: liblua.so.5.4()(64bit) %else Provides: liblua.so.5.4 %endif -Provides: liblua5_4 = %{version}-%{release} -Obsoletes: liblua5_4 < %{version}-%{release} -Provides: %{name}-libs = %{version} -Obsoletes: %{name}-libs < %{version} %description -n %{libname} Lua is a programming language originally designed for extending @@ -151,7 +150,7 @@ cat doc/luac.1 | sed 's/TH LUAC 1/TH LUAC%{major_version} 1/' > doc/luac%{major_ %build sed -i -e "s@lib/lua/@%{_lib}/lua/@g" src/luaconf.h -make linux-readline %{_smp_mflags} VERBOSE=1 -C src \ +%make_build linux-readline -C src \ CC="cc" LIBDIR="%{_libdir}" \ MYCFLAGS="%{optflags} -std=gnu99 -D_GNU_SOURCE -fPIC -DLUA_COMPAT_MODULE" \ V=%{major_version} \ @@ -209,8 +208,6 @@ cd testes LD_LIBRARY_PATH=%{_libdir} %{_bindir}/lua%{major_version} all.lua %endif -%clean - %if "%{flavor}" != "test" %post -n %{libname} -p /sbin/ldconfig %postun -n %{libname} -p /sbin/ldconfig From 59741167c5f47f54acfc2a0037ed61214c8ba70de30517e2cdb16f68eaead2e3 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 29 May 2023 16:22:24 +0000 Subject: [PATCH 13/15] It's back again? OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=84 --- baselibs.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baselibs.conf b/baselibs.conf index 54c7f60..2fa28f4 100644 --- a/baselibs.conf +++ b/baselibs.conf @@ -1 +1 @@ -liblua5_4-6 +liblua5_4-5 From b136ed9eb2afe714ed43ecbcf9cf54ae6d9ef2f69f503dc525ecdcd1a40c55df Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 29 May 2023 16:22:40 +0000 Subject: [PATCH 14/15] It's back again? pt2 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=85 --- lua54.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua54.spec b/lua54.spec index 68837b1..840bd0d 100644 --- a/lua54.spec +++ b/lua54.spec @@ -24,7 +24,7 @@ %define name_ext %{nil} %endif %define major_version 5.4 -%define libname liblua5_4-6 +%define libname liblua5_4-5 Name: lua54%{name_ext} Version: 5.4.6 Release: 0 From f7f5a38e27b3d332c01d4a5c5a4f10620362cfb6df07b1c0199e9a7610533555 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 29 May 2023 16:24:24 +0000 Subject: [PATCH 15/15] It's back again? pt3 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=86 --- lua54.changes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua54.changes b/lua54.changes index bd05188..29f8b34 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon May 29 16:23:16 UTC 2023 - Callum Farmer + +- Library is always liblua5_4-5: due to SOVERSION leading digit + being 5 + ------------------------------------------------------------------- Mon May 22 09:39:52 UTC 2023 - Matej Cepl