From e0ca79217ea51c5b6aec524cfbf9b67cbe0d4cfc1513ccff15771a8edaae5cc2 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 29 Mar 2021 17:06:31 +0000 Subject: [PATCH 1/5] Accepting request 882019 from home:gmbr3:Lua - Update to version 5.4.3 - Removed upstream-bugs.patch: new release (no bugs found yet) - Removed upstream-bugs-test.patch: new release (no bugs found yet) OBS-URL: https://build.opensuse.org/request/show/882019 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=26 --- lua-5.4.2-tests.tar.gz | 3 --- lua-5.4.2.tar.gz | 3 --- lua-5.4.3-tests.tar.gz | 3 +++ lua-5.4.3.tar.gz | 3 +++ lua-build-system.patch | 14 ++++++------ lua54.changes | 7 ++++++ lua54.spec | 12 +++++------ upstream-bugs-test.patch | 38 --------------------------------- upstream-bugs.patch | 46 ---------------------------------------- 9 files changed, 26 insertions(+), 103 deletions(-) delete mode 100644 lua-5.4.2-tests.tar.gz delete mode 100644 lua-5.4.2.tar.gz create mode 100644 lua-5.4.3-tests.tar.gz create mode 100644 lua-5.4.3.tar.gz delete mode 100644 upstream-bugs-test.patch delete mode 100644 upstream-bugs.patch diff --git a/lua-5.4.2-tests.tar.gz b/lua-5.4.2-tests.tar.gz deleted file mode 100644 index cdf0e7f..0000000 --- a/lua-5.4.2-tests.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:91bd3163fd237b2bd0bc99127fc25b4502f4526e17ac71a3df7c218e6b0798c0 -size 128901 diff --git a/lua-5.4.2.tar.gz b/lua-5.4.2.tar.gz deleted file mode 100644 index 1e0947f..0000000 --- a/lua-5.4.2.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:11570d97e9d7303c0a59567ed1ac7c648340cd0db10d5fd594c09223ef2f524f -size 353472 diff --git a/lua-5.4.3-tests.tar.gz b/lua-5.4.3-tests.tar.gz new file mode 100644 index 0000000..29b3038 --- /dev/null +++ b/lua-5.4.3-tests.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d29c3022897a8290f280ebe1c6853248dfa35a668e1fc02ba9c8cde4e7bf110 +size 131911 diff --git a/lua-5.4.3.tar.gz b/lua-5.4.3.tar.gz new file mode 100644 index 0000000..3f44452 --- /dev/null +++ b/lua-5.4.3.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8612276169e3bfcbcfb8f226195bfc6e466fe13042f1076cbde92b7ec96bbfb +size 358216 diff --git a/lua-build-system.patch b/lua-build-system.patch index 47236e9..deb19a6 100644 --- a/lua-build-system.patch +++ b/lua-build-system.patch @@ -132,23 +132,23 @@ Subject: build system $(LUA_A): $(BASE_O) - $(AR) $@ $(BASE_O) - $(RANLIB) $@ -+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -rpath /usr/lib -version-info 9:0:4 -o liblua$(V).la ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -lm -ldl $(BASE_O:.o=.lo) -rpath /usr/lib -version-info 9:0:4 -o $(LUA_A) $(LUA_T): $(LUA_O) $(LUA_A) - $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) -+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LIBS) -static liblua$(V).la -Wl,-E lua.lo -o $@ ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) $(LIBS) -static $(LUA_A) -Wl,-E lua.lo -o $@ $(LUAC_T): $(LUAC_O) $(LUA_A) - $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) -+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -static liblua$(V).la luac.lo -o $@ ++ $(LIBTOOL) --mode=link --tag=CC $(CC) $(LDFLAGS) -static $(LUA_A) luac.lo -o $@ test: -- ./lua -v -+ $(LIBTOOL) --mode=execute -dlopen ./liblua$(V).la ./lua$(V) -v +- ./$(LUA_T) -v ++ $(LIBTOOL) --mode=execute -dlopen ./$(LUA_A) ./$(LUA_T) -v clean: $(RM) $(ALL_T) $(ALL_O) -@@ -142,14 +157,6 @@ +@@ -144,14 +159,6 @@ .PHONY: all $(PLATS) help test clean default o a depend echo # Compiler modules may use special flags. @@ -166,7 +166,7 @@ Subject: build system --- a/src/luaconf.h +++ b/src/luaconf.h -@@ -227,7 +227,7 @@ +@@ -217,7 +217,7 @@ #else /* }{ */ diff --git a/lua54.changes b/lua54.changes index fa5f034..cb46bf5 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Mar 29 17:04:47 UTC 2021 - Callum Farmer + +- Update to version 5.4.3 +- Removed upstream-bugs.patch: new release (no bugs found yet) +- Removed upstream-bugs-test.patch: new release (no bugs found yet) + ------------------------------------------------------------------- Thu Mar 11 17:10:14 UTC 2021 - Callum Farmer diff --git a/lua54.spec b/lua54.spec index 52cf710..30f0556 100644 --- a/lua54.spec +++ b/lua54.spec @@ -25,7 +25,7 @@ %define major_version 5.4 %define libname liblua5_4-5 Name: lua54%{name_ext} -Version: 5.4.2 +Version: 5.4.3 Release: 0 Summary: Small Embeddable Language with Procedural Syntax License: MIT @@ -41,9 +41,9 @@ Patch0: lua-build-system.patch 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 -Patch5: upstream-bugs-test.patch +# PATCH-FIX-UPSTREAM https://www.lua.org/bugs.html#5.4.3 +#Patch4: upstream-bugs.patch +#Patch5: upstream-bugs-test.patch %if "%{flavor}" == "test" BuildRequires: lua54 %else @@ -139,11 +139,11 @@ of C functions, written in ANSI C. %patch1 -p1 %patch2 -p1 %patch3 -p1 -%patch5 -p1 +#%patch5 -p1 %else %setup -q -n lua-%{version} %patch0 -p1 -%patch4 -p1 +#%patch4 -p1 %endif # manpage diff --git a/upstream-bugs-test.patch b/upstream-bugs-test.patch deleted file mode 100644 index d656c9f..0000000 --- a/upstream-bugs-test.patch +++ /dev/null @@ -1,38 +0,0 @@ ---- 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 deleted file mode 100644 index aa1cb29..0000000 --- a/upstream-bugs.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- 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 */ - } From 391f08d99ee8775e4624b39c81158fd670b31ba4546176a51e8600e6e5df7b2b Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 29 Mar 2021 17:11:07 +0000 Subject: [PATCH 2/5] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=27 --- lua54.changes | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua54.changes b/lua54.changes index cb46bf5..8e37404 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,7 +1,8 @@ ------------------------------------------------------------------- Mon Mar 29 17:04:47 UTC 2021 - Callum Farmer -- Update to version 5.4.3 +- Update to version 5.4.3: + * Fixes bugs found in Lua 5.4.2 - Removed upstream-bugs.patch: new release (no bugs found yet) - Removed upstream-bugs-test.patch: new release (no bugs found yet) From d164f587b34dfb0303111af237759ae43f1ac6d56e30e0d6774037cc98782e6d Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 30 Mar 2021 18:30:10 +0000 Subject: [PATCH 3/5] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=28 --- files_test.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/files_test.patch b/files_test.patch index 16bbd08..142eb09 100644 --- a/files_test.patch +++ b/files_test.patch @@ -11,7 +11,7 @@ Index: lua/files.lua end assert(io.output():seek() == 0) -@@ -729,7 +729,7 @@ if not _port then +@@ -744,7 +744,7 @@ if not _port then {"exit 129", "exit", 129}, {"kill -s HUP $$", "signal", 1}, {"kill -s KILL $$", "signal", 9}, @@ -20,7 +20,7 @@ Index: lua/files.lua {progname .. ' -e " "', "ok"}, {progname .. ' -e "os.exit(0, true)"', "ok"}, {progname .. ' -e "os.exit(20, true)"', "exit", 20}, -@@ -742,6 +742,9 @@ if not _port then +@@ -757,6 +757,9 @@ if not _port then if v[2] == "ok" then assert(x and y == 'exit' and z == 0) else @@ -30,7 +30,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) -@@ -776,6 +779,7 @@ assert(os.date(string.rep("%d", 1000), t +@@ -794,6 +794,7 @@ assert(os.date(string.rep("%d", 1000), t assert(os.date(string.rep("%", 200)) == string.rep("%", 100)) local function checkDateTable (t) @@ -38,7 +38,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 -@@ -791,7 +795,9 @@ if not _port then +@@ -810,7 +810,9 @@ if not _port then checkDateTable(1) checkDateTable(1000) checkDateTable(0x7fffffff) From 45a4d23ac6463303e495a42885e1b0986dd9c1ea3500e26ec3d32517f55c8b11 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Tue, 30 Mar 2021 18:35:23 +0000 Subject: [PATCH 4/5] OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=29 --- files_test.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files_test.patch b/files_test.patch index 142eb09..64ab3f3 100644 --- a/files_test.patch +++ b/files_test.patch @@ -30,7 +30,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) -@@ -794,6 +794,7 @@ assert(os.date(string.rep("%d", 1000), t +@@ -791,6 +791,7 @@ assert(os.date(string.rep("%d", 1000), t assert(os.date(string.rep("%", 200)) == string.rep("%", 100)) local function checkDateTable (t) @@ -38,7 +38,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 -@@ -810,7 +810,9 @@ if not _port then +@@ -806,7 +806,9 @@ if not _port then checkDateTable(1) checkDateTable(1000) checkDateTable(0x7fffffff) From 8ce8cc4141dcf634fc55a33bedec950c0b4ee5296e08cb420f372a2f4b2d4075 Mon Sep 17 00:00:00 2001 From: Callum Farmer Date: Mon, 19 Apr 2021 09:17:04 +0000 Subject: [PATCH 5/5] Accepting request 886618 from home:gmbr3:lua - Add upstream-bugs.patch and upstream-bugs-test.patch to fix bugs 1,2,3 for build and tests respectively. OBS-URL: https://build.opensuse.org/request/show/886618 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=30 --- lua54.changes | 8 ++- lua54.spec | 8 +-- upstream-bugs-test.patch | 104 +++++++++++++++++++++++++++ upstream-bugs.patch | 149 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 264 insertions(+), 5 deletions(-) create mode 100644 upstream-bugs-test.patch create mode 100644 upstream-bugs.patch diff --git a/lua54.changes b/lua54.changes index 8e37404..5595274 100644 --- a/lua54.changes +++ b/lua54.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Apr 19 09:15:40 UTC 2021 - Callum Farmer + +- Add upstream-bugs.patch and upstream-bugs-test.patch to fix + bugs 1,2,3 for build and tests respectively. + ------------------------------------------------------------------- Mon Mar 29 17:04:47 UTC 2021 - Callum Farmer @@ -10,7 +16,7 @@ Mon Mar 29 17:04:47 UTC 2021 - Callum Farmer 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. + 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 30f0556..043cdfd 100644 --- a/lua54.spec +++ b/lua54.spec @@ -42,8 +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.3 -#Patch4: upstream-bugs.patch -#Patch5: upstream-bugs-test.patch +Patch4: upstream-bugs.patch +Patch5: upstream-bugs-test.patch %if "%{flavor}" == "test" BuildRequires: lua54 %else @@ -139,11 +139,11 @@ of C functions, written in ANSI C. %patch1 -p1 %patch2 -p1 %patch3 -p1 -#%patch5 -p1 +%patch5 -p1 %else %setup -q -n lua-%{version} %patch0 -p1 -#%patch4 -p1 +%patch4 -p1 %endif # manpage diff --git a/upstream-bugs-test.patch b/upstream-bugs-test.patch new file mode 100644 index 0000000..591f4ad --- /dev/null +++ b/upstream-bugs-test.patch @@ -0,0 +1,104 @@ +diff --git a/testes/locals.lua b/testes/locals.lua +index 2c67edbdb..6aad5d253 100644 +--- a/locals.lua ++++ b/locals.lua +@@ -335,6 +335,29 @@ do + end + + ++do ++ -- bug in 5.4.3: previous condition (calls cannot be tail in the ++ -- scope of to-be-closed variables) must be valid for tbc variables ++ -- created by 'for' loops. ++ ++ local closed = false ++ ++ local function foo () ++ return function () return true end, 0, 0, ++ func2close(function () closed = true end) ++ end ++ ++ local function tail() return closed end ++ ++ local function foo1 () ++ for k in foo() do return tail() end ++ end ++ ++ assert(foo1() == false) ++ assert(closed == true) ++end ++ ++ + do print("testing errors in __close") + + -- original error is in __close +diff --git a/testes/locals.lua b/testes/locals.lua +index 6aad5d253..6151f64d0 100644 +--- a/locals.lua ++++ b/locals.lua +@@ -813,6 +813,65 @@ do + end + + ++do ++ -- yielding inside closing metamethods while returning ++ -- (bug in 5.4.3) ++ ++ local extrares -- result from extra yield (if any) ++ ++ local function check (body, extra, ...) ++ local t = table.pack(...) -- expected returns ++ local co = coroutine.wrap(body) ++ if extra then ++ extrares = co() -- runs until first (extra) yield ++ end ++ local res = table.pack(co()) -- runs until yield inside '__close' ++ assert(res.n == 2 and res[2] == nil) ++ local res2 = table.pack(co()) -- runs until end of function ++ assert(res2.n == t.n) ++ for i = 1, #t do ++ if t[i] == "x" then ++ assert(res2[i] == res[1]) -- value that was closed ++ else ++ assert(res2[i] == t[i]) ++ end ++ end ++ end ++ ++ local function foo () ++ local x = func2close(coroutine.yield) ++ local extra = func2close(function (self) ++ assert(self == extrares) ++ coroutine.yield(100) ++ end) ++ extrares = extra ++ return table.unpack{10, x, 30} ++ end ++ check(foo, true, 10, "x", 30) ++ assert(extrares == 100) ++ ++ local function foo () ++ local x = func2close(coroutine.yield) ++ return ++ end ++ check(foo, false) ++ ++ local function foo () ++ local x = func2close(coroutine.yield) ++ local y, z = 20, 30 ++ return x ++ end ++ check(foo, false, "x") ++ ++ local function foo () ++ local x = func2close(coroutine.yield) ++ local extra = func2close(coroutine.yield) ++ return table.unpack({}, 1, 100) -- 100 nils ++ end ++ check(foo, true, table.unpack({}, 1, 100)) ++ ++end ++ + do + -- yielding inside closing metamethods after an error + diff --git a/upstream-bugs.patch b/upstream-bugs.patch new file mode 100644 index 0000000..1a7a7a6 --- /dev/null +++ b/upstream-bugs.patch @@ -0,0 +1,149 @@ +From 47cffdc723c2e0c6dfaf62b7775ca1c1d338c0a4 Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy +Date: Wed, 7 Apr 2021 14:59:26 -0300 +Subject: [PATCH] Bug: tbc variables in "for" loops don't avoid tail calls + +--- + lparser.c | 21 +++++++++++++++------ + testes/locals.lua | 23 +++++++++++++++++++++++ + 2 files changed, 38 insertions(+), 6 deletions(-) + +diff --git a/lparser.c b/lparser.c +index 284ef1f0c..df9473c27 100644 +--- a/src/lparser.c ++++ b/src/lparser.c +@@ -416,6 +416,17 @@ static void markupval (FuncState *fs, int level) { + } + + ++/* ++** Mark that current block has a to-be-closed variable. ++*/ ++static void marktobeclosed (FuncState *fs) { ++ BlockCnt *bl = fs->bl; ++ bl->upval = 1; ++ bl->insidetbc = 1; ++ fs->needclose = 1; ++} ++ ++ + /* + ** Find a variable with the given name 'n'. If it is an upvalue, add + ** this upvalue into all intermediate functions. If it is a global, set +@@ -1599,7 +1610,7 @@ static void forlist (LexState *ls, TString *indexname) { + line = ls->linenumber; + adjust_assign(ls, 4, explist(ls, &e), &e); + adjustlocalvars(ls, 4); /* control variables */ +- markupval(fs, fs->nactvar); /* last control var. must be closed */ ++ marktobeclosed(fs); /* last control var. must be closed */ + luaK_checkstack(fs, 3); /* extra space to call generator */ + forbody(ls, base, line, nvars - 4, 1); + } +@@ -1703,11 +1714,9 @@ static int getlocalattribute (LexState *ls) { + } + + +-static void checktoclose (LexState *ls, int level) { ++static void checktoclose (FuncState *fs, int level) { + if (level != -1) { /* is there a to-be-closed variable? */ +- FuncState *fs = ls->fs; +- markupval(fs, level + 1); +- fs->bl->insidetbc = 1; /* in the scope of a to-be-closed variable */ ++ marktobeclosed(fs); + luaK_codeABC(fs, OP_TBC, reglevel(fs, level), 0, 0); + } + } +@@ -1751,7 +1760,7 @@ static void localstat (LexState *ls) { + adjust_assign(ls, nvars, nexps, &e); + adjustlocalvars(ls, nvars); + } +- checktoclose(ls, toclose); ++ checktoclose(fs, toclose); + } + + +From d205f3a4847bc8b835fda91f51ba1cf45b796baf Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy +Date: Sat, 10 Apr 2021 10:19:21 -0300 +Subject: [PATCH] Bug: Lua source should not use C99 comments ("//") + +--- + lvm.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/lvm.c b/lvm.c +index c9729bcca..16e01d683 100644 +--- a/src/lvm.c ++++ b/src/lvm.c +@@ -1156,8 +1156,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { + Instruction i; /* instruction being executed */ + StkId ra; /* instruction's A register */ + vmfetch(); +-// low-level line tracing for debugging Lua +-// printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); ++ #if 0 ++ /* low-level line tracing for debugging Lua */ ++ printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p))); ++ #endif + lua_assert(base == ci->func + 1); + lua_assert(base <= L->top && L->top < L->stack_last); + /* invalidate top for instructions not expecting it */ +From 681297187ec45268e872b26753c441586c12bdd8 Mon Sep 17 00:00:00 2001 +From: Roberto Ierusalimschy +Date: Fri, 16 Apr 2021 15:41:44 -0300 +Subject: [PATCH] Bug: yielding in '__close' mess up number of returns + +Yielding in a __close metamethod called when returning vararg results +changes the top and so messes up the number of returned values. +--- + lstate.h | 2 +- + lvm.c | 12 +++++++++- + testes/locals.lua | 59 +++++++++++++++++++++++++++++++++++++++++++++++ + 3 files changed, 71 insertions(+), 2 deletions(-) + +diff --git a/lstate.h b/lstate.h +index c1283bb6b..44cf939cb 100644 +--- a/src/lstate.h ++++ b/src/lstate.h +@@ -165,7 +165,7 @@ typedef struct stringtable { + ** - field 'nyield' is used only while a function is "doing" an + ** yield (from the yield until the next resume); + ** - field 'nres' is used only while closing tbc variables when +-** returning from a C function; ++** returning from a function; + ** - field 'transferinfo' is used only during call/returnhooks, + ** before the function starts or after it ends. + */ +diff --git a/lvm.c b/lvm.c +index 16e01d683..e4b1903e7 100644 +--- a/src/lvm.c ++++ b/src/lvm.c +@@ -847,10 +847,19 @@ void luaV_finishOp (lua_State *L) { + luaV_concat(L, total); /* concat them (may yield again) */ + break; + } +- case OP_CLOSE: case OP_RETURN: { /* yielded closing variables */ ++ case OP_CLOSE: { /* yielded closing variables */ + ci->u.l.savedpc--; /* repeat instruction to close other vars. */ + break; + } ++ case OP_RETURN: { /* yielded closing variables */ ++ StkId ra = base + GETARG_A(inst); ++ /* adjust top to signal correct number of returns, in case the ++ return is "up to top" ('isIT') */ ++ L->top = ra + ci->u2.nres; ++ /* repeat instruction to close other vars. and complete the return */ ++ ci->u.l.savedpc--; ++ break; ++ } + default: { + /* only these other opcodes can yield */ + lua_assert(op == OP_TFORCALL || op == OP_CALL || +@@ -1672,6 +1681,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { + n = cast_int(L->top - ra); /* get what is available */ + savepc(ci); + if (TESTARG_k(i)) { /* may there be open upvalues? */ ++ ci->u2.nres = n; /* save number of returns */ + if (L->top < ci->top) + L->top = ci->top; + luaF_close(L, base, CLOSEKTOP, 1);