diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-02-11 17:18:21 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2008-02-11 17:18:21 -0200 |
commit | 3b5b14a0852a911a299d97c91e09da52f66ea23d (patch) | |
tree | 7af1bd66da20eead1aa6a58936d20d04fd549a9a | |
parent | aec671c126ab32c22adae30c8f8084b0191cd2fb (diff) | |
download | lua-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-- | bugs | 55 |
1 files changed, 54 insertions, 1 deletions
@@ -1645,7 +1645,7 @@ a = coroutine.create(function() yield() end) | |||
1645 | coroutine.resume(a) | 1645 | coroutine.resume(a) |
1646 | debug.sethook(a) -- may overflow the stack of 'a' | 1646 | debug.sethook(a) -- may overflow the stack of 'a' |
1647 | ]], | 1647 | ]], |
1648 | patch = [[ ]], | 1648 | patch = [[ |
1649 | ldblib.c: | 1649 | ldblib.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 | |||
1691 | Bug{ | ||
1692 | what = [[LUAI_MAXCSTACK must be smaller than -LUA_REGISTRYINDEX]], | ||
1693 | report = [[Patrick Donnell, on 2008/02/11]], | ||
1694 | since = [[5.1.3]], | ||
1695 | example = [[ | ||
1696 | j = 1e4 | ||
1697 | co = coroutine.create(function() | ||
1698 | t = {} | ||
1699 | for i = 1, j do t[i] = i end | ||
1700 | return unpack(t) | ||
1701 | end) | ||
1702 | print(coroutine.resume(co)) | ||
1703 | ]], | ||
1704 | patch = [[ | ||
1705 | luaconf.h: | ||
1706 | 443c443,444 | ||
1707 | < ** functions to consume unlimited stack space. | ||
1708 | --- | ||
1709 | > ** functions to consume unlimited stack space. (must be smaller than | ||
1710 | > ** -LUA_REGISTRYINDEX) | ||
1711 | 445,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 | |||
1719 | Bug{ | ||
1720 | what = [[coroutine.resume pushes element without ensuring stack size]], | ||
1721 | report = [[on 2008/02/11]], | ||
1722 | since = [[5.0]], | ||
1723 | example = [[(this bug cannot be detected without internal assertions)]], | ||
1724 | patch = [[ | ||
1725 | lbaselib.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 | ||
1685 | Bug{ | 1738 | Bug{ |