forked from pool/lua54
Accepting request 1000322 from home:gmbr3:Lua
- Add more upstream patches: * luabugs6.patch * luabugs7.patch OBS-URL: https://build.opensuse.org/request/show/1000322 OBS-URL: https://build.opensuse.org/package/show/devel:languages:lua/lua54?expand=0&rev=61
This commit is contained in:
parent
aa809f6769
commit
c6debe4633
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 30 16:40:09 UTC 2022 - Callum Farmer <gmbr3@opensuse.org>
|
||||
|
||||
- Add more upstream patches:
|
||||
* luabugs6.patch
|
||||
* luabugs7.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Jun 4 13:49:42 UTC 2022 - Callum Farmer <gmbr3@opensuse.org>
|
||||
|
||||
|
@ -49,6 +49,8 @@ Patch8: luabugs2.patch
|
||||
Patch9: luabugs3.patch
|
||||
Patch10: luabugs4.patch
|
||||
Patch11: luabugs5.patch
|
||||
Patch12: luabugs6.patch
|
||||
Patch13: luabugs7.patch
|
||||
#
|
||||
%if "%{flavor}" == "test"
|
||||
BuildRequires: lua54
|
||||
|
77
luabugs6.patch
Normal file
77
luabugs6.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From 997f11f54322883c3181225f29d101a597f31730 Mon Sep 17 00:00:00 2001
|
||||
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
|
||||
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
|
118
luabugs7.patch
Normal file
118
luabugs7.patch
Normal file
@ -0,0 +1,118 @@
|
||||
From a1f77a234a053da46b06d5d4be00ffb30d3eb45b Mon Sep 17 00:00:00 2001
|
||||
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
|
||||
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
|
Loading…
Reference in New Issue
Block a user