From 236d9fb18d2112593e435aa012c971c024138ab20ac02f51a8605aedfa98b4f8 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Thu, 11 Mar 2021 17:25:01 +0000 Subject: [PATCH] Accepting request 878378 from home:gmbr3:Lua - Add upstream-bugs.patch and upstream-bugs-test.patch to fix bugs 2,3,4 for build and tests respectively. OBS-URL: https://build.opensuse.org/request/show/878378 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=24 --- lua54.changes | 6 ++++++ lua54.spec | 5 ++++- upstream-bugs-test.patch | 38 +++++++++++++++++++++++++++++++++ upstream-bugs.patch | 46 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 upstream-bugs-test.patch create mode 100644 upstream-bugs.patch diff --git a/lua54.changes b/lua54.changes index bd7aa0d..fa5f034 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Mar 11 17:10:14 UTC 2021 - Callum Farmer + +- Add upstream-bugs.patch and upstream-bugs-test.patch to fix + bugs 2,3,4 for build and tests respectively. + ------------------------------------------------------------------- Fri Jan 22 12:38:04 UTC 2021 - Callum Farmer diff --git a/lua54.spec b/lua54.spec index d8b72c9..52cf710 100644 --- a/lua54.spec +++ b/lua54.spec @@ -42,7 +42,8 @@ Patch1: attrib_test.patch Patch2: files_test.patch Patch3: main_test.patch # PATCH-FIX-UPSTREAM https://www.lua.org/bugs.html#5.4.2 -#Patch4: upstream-bugs.patch +Patch4: upstream-bugs.patch +Patch5: upstream-bugs-test.patch %if "%{flavor}" == "test" BuildRequires: lua54 %else @@ -138,9 +139,11 @@ of C functions, written in ANSI C. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch5 -p1 %else %setup -q -n lua-%{version} %patch0 -p1 +%patch4 -p1 %endif # manpage diff --git a/upstream-bugs-test.patch b/upstream-bugs-test.patch new file mode 100644 index 0000000..d656c9f --- /dev/null +++ b/upstream-bugs-test.patch @@ -0,0 +1,38 @@ +--- a/db.lua ++++ b/db.lua +@@ -31,6 +31,7 @@ end + + do + assert(not pcall(debug.getinfo, print, "X")) -- invalid option ++ assert(not pcall(debug.getinfo, 0, ">")) -- invalid option + assert(not debug.getinfo(1000)) -- out of range level + assert(not debug.getinfo(-1)) -- out of range level + local a = debug.getinfo(print) +--- a/strings.lua ++++ b/strings.lua +@@ -361,6 +361,9 @@ assert(load("return 1\n--comment without ending EOL")() == 1) + + + checkerror("table expected", table.concat, 3) ++checkerror("at index " .. maxi, table.concat, {}, " ", maxi, maxi) ++-- '%' escapes following minus signal ++checkerror("at index %" .. mini, table.concat, {}, " ", mini, mini) + assert(table.concat{} == "") + assert(table.concat({}, 'x') == "") + assert(table.concat({'\0', '\0\1', '\0\1\2'}, '.\0.') == "\0.\0.\0\1.\0.\0\1\2") +--- a/errors.lua ++++ b/errors.lua +@@ -191,6 +191,13 @@ checkmessage("a = 24 // 0", "divide by zero") + checkmessage("a = 1 % 0", "'n%0'") + + ++-- type error for an object which is neither in an upvalue nor a register. ++-- The following code will try to index the value 10 that is stored in ++-- the metatable, without moving it to a register. ++checkmessage("local a = setmetatable({}, {__index = 10}).x", ++ "attempt to index a number value") ++ ++ + -- numeric for loops + checkmessage("for i = {}, 10 do end", "table") + checkmessage("for i = io.stdin, 10 do end", "FILE") diff --git a/upstream-bugs.patch b/upstream-bugs.patch new file mode 100644 index 0000000..aa1cb29 --- /dev/null +++ b/upstream-bugs.patch @@ -0,0 +1,46 @@ +--- a/src/ldblib.c ++++ b/src/ldblib.c +@@ -152,6 +152,7 @@ static int db_getinfo (lua_State *L) { + lua_State *L1 = getthread(L, &arg); + const char *options = luaL_optstring(L, arg+2, "flnSrtu"); + checkstack(L, L1, 3); ++ luaL_argcheck(L, options[0] != '>', arg + 2, "invalid option '>'"); + if (lua_isfunction(L, arg + 1)) { /* info about a function? */ + options = lua_pushfstring(L, ">%s", options); /* add '>' to 'options' */ + lua_pushvalue(L, arg + 1); /* move function to 'L1' stack */ +--- a/src/ltablib.c ++++ b/src/ltablib.c +@@ -146,7 +146,7 @@ static int tmove (lua_State *L) { + static void addfield (lua_State *L, luaL_Buffer *b, lua_Integer i) { + lua_geti(L, 1, i); + if (!lua_isstring(L, -1)) +- luaL_error(L, "invalid value (%s) at index %d in table for 'concat'", ++ luaL_error(L, "invalid value (%s) at index %I in table for 'concat'", + luaL_typename(L, -1), i); + luaL_addvalue(b); + } +--- a/src/ldebug.c ++++ b/src/ldebug.c +@@ -638,14 +638,18 @@ static const char *funcnamefromcode (lua_State *L, CallInfo *ci, + + + /* +-** The subtraction of two potentially unrelated pointers is +-** not ISO C, but it should not crash a program; the subsequent +-** checks are ISO C and ensure a correct result. ++** Check whether pointer 'o' points to some value in the stack ++** frame of the current function. Because 'o' may not point to a ++** value in this stack, we cannot compare it with the region ++** boundaries (undefined behaviour in ISO C). + */ + static int isinstack (CallInfo *ci, const TValue *o) { +- StkId base = ci->func + 1; +- ptrdiff_t i = cast(StkId, o) - base; +- return (0 <= i && i < (ci->top - base) && s2v(base + i) == o); ++ StkId pos; ++ for (pos = ci->func + 1; pos < ci->top; pos++) { ++ if (o == s2v(pos)) ++ return 1; ++ } ++ return 0; /* not found */ + }