aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-02-11 17:18:21 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-02-11 17:18:21 -0200
commit3b5b14a0852a911a299d97c91e09da52f66ea23d (patch)
tree7af1bd66da20eead1aa6a58936d20d04fd549a9a
parentaec671c126ab32c22adae30c8f8084b0191cd2fb (diff)
downloadlua-3b5b14a0852a911a299d97c91e09da52f66ea23d.tar.gz
lua-3b5b14a0852a911a299d97c91e09da52f66ea23d.tar.bz2
lua-3b5b14a0852a911a299d97c91e09da52f66ea23d.zip
LUAI_MAXCSTACK must be smaller than -LUA_REGISTRYINDEX +
coroutine.resume pushes element without ensuring stack size
-rw-r--r--bugs55
1 files changed, 54 insertions, 1 deletions
diff --git a/bugs b/bugs
index 8943a56b..76453a2c 100644
--- a/bugs
+++ b/bugs
@@ -1645,7 +1645,7 @@ a = coroutine.create(function() yield() end)
1645coroutine.resume(a) 1645coroutine.resume(a)
1646debug.sethook(a) -- may overflow the stack of 'a' 1646debug.sethook(a) -- may overflow the stack of 'a'
1647]], 1647]],
1648patch = [[ ]], 1648patch = [[
1649ldblib.c: 1649ldblib.c:
1650@@ -268,12 +268,11 @@ 1650@@ -268,12 +268,11 @@
1651 count = luaL_optint(L, arg+3, 0); 1651 count = luaL_optint(L, arg+3, 0);
@@ -1680,6 +1680,59 @@ ldblib.c:
1680 } 1680 }
1681 lua_pushstring(L, unmakemask(mask, buff)); 1681 lua_pushstring(L, unmakemask(mask, buff));
1682 lua_pushinteger(L, lua_gethookcount(L1)); 1682 lua_pushinteger(L, lua_gethookcount(L1));
1683]]
1684}
1685
1686
1687
1688-----------------------------------------------------------------
1689-- Lua 5.1.3
1690
1691Bug{
1692what = [[LUAI_MAXCSTACK must be smaller than -LUA_REGISTRYINDEX]],
1693report = [[Patrick Donnell, on 2008/02/11]],
1694since = [[5.1.3]],
1695example = [[
1696j = 1e4
1697co = coroutine.create(function()
1698 t = {}
1699 for i = 1, j do t[i] = i end
1700 return unpack(t)
1701end)
1702print(coroutine.resume(co))
1703]],
1704patch = [[
1705luaconf.h:
1706443c443,444
1707< ** functions to consume unlimited stack space.
1708---
1709> ** functions to consume unlimited stack space. (must be smaller than
1710> ** -LUA_REGISTRYINDEX)
1711445,446c446
1712< #define LUAI_MCS_AUX ((int)(INT_MAX / (4*sizeof(LUA_NUMBER))))
1713< #define LUAI_MAXCSTACK (LUAI_MCS_AUX > SHRT_MAX ? SHRT_MAX : LUAI_MCS_AUX)
1714---
1715> #define LUAI_MAXCSTACK 8000
1716]],
1717}
1718
1719Bug{
1720what = [[coroutine.resume pushes element without ensuring stack size]],
1721report = [[on 2008/02/11]],
1722since = [[5.0]],
1723example = [[(this bug cannot be detected without internal assertions)]],
1724patch = [[
1725lbaselib.c:
1726@@ -526,7 +526,7 @@
1727 status = lua_resume(co, narg);
1728 if (status == 0 || status == LUA_YIELD) {
1729 int nres = lua_gettop(co);
1730- if (!lua_checkstack(L, nres))
1731+ if (!lua_checkstack(L, nres + 1))
1732 luaL_error(L, "too many results to resume");
1733 lua_xmove(co, L, nres); /* move yielded values */
1734 return nres;
1735]],
1683} 1736}
1684 1737
1685Bug{ 1738Bug{