aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-01-21 12:41:19 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2008-01-21 12:41:19 -0200
commit3a515df086d952e320991e7d7c64fadf9c5364e2 (patch)
treeb25967c41c5d7a65d6d3867d55590bd0b0b4c162
parent74897bc52f07d416c717edeb1e26e75d62e937dd (diff)
downloadlua-3a515df086d952e320991e7d7c64fadf9c5364e2.tar.gz
lua-3a515df086d952e320991e7d7c64fadf9c5364e2.tar.bz2
lua-3a515df086d952e320991e7d7c64fadf9c5364e2.zip
debug.sethook/gethook may overflow the thread's stack
-rw-r--r--bugs46
1 files changed, 46 insertions, 0 deletions
diff --git a/bugs b/bugs
index 8254da03..8943a56b 100644
--- a/bugs
+++ b/bugs
@@ -1637,6 +1637,52 @@ lua.c:
1637} 1637}
1638 1638
1639Bug{ 1639Bug{
1640what = [[debug.sethook/gethook may overflow the thread's stack]],
1641report = [[Ivko Stanilov, on 2008/01/04]],
1642since = [[5.1]],
1643example = [[
1644a = coroutine.create(function() yield() end)
1645coroutine.resume(a)
1646debug.sethook(a) -- may overflow the stack of 'a'
1647]],
1648patch = [[ ]],
1649ldblib.c:
1650@@ -268,12 +268,11 @@
1651 count = luaL_optint(L, arg+3, 0);
1652 func = hookf; mask = makemask(smask, count);
1653 }
1654- gethooktable(L1);
1655- lua_pushlightuserdata(L1, L1);
1656+ gethooktable(L);
1657+ lua_pushlightuserdata(L, L1);
1658 lua_pushvalue(L, arg+1);
1659- lua_xmove(L, L1, 1);
1660- lua_rawset(L1, -3); /* set new hook */
1661- lua_pop(L1, 1); /* remove hook table */
1662+ lua_rawset(L, -3); /* set new hook */
1663+ lua_pop(L, 1); /* remove hook table */
1664 lua_sethook(L1, func, mask, count); /* set hooks */
1665 return 0;
1666 }
1667@@ -288,11 +287,10 @@
1668 if (hook != NULL && hook != hookf) /* external hook? */
1669 lua_pushliteral(L, "external hook");
1670 else {
1671- gethooktable(L1);
1672- lua_pushlightuserdata(L1, L1);
1673- lua_rawget(L1, -2); /* get hook */
1674- lua_remove(L1, -2); /* remove hook table */
1675- lua_xmove(L1, L, 1);
1676+ gethooktable(L);
1677+ lua_pushlightuserdata(L, L1);
1678+ lua_rawget(L, -2); /* get hook */
1679+ lua_remove(L, -2); /* remove hook table */
1680 }
1681 lua_pushstring(L, unmakemask(mask, buff));
1682 lua_pushinteger(L, lua_gethookcount(L1));
1683}
1684
1685Bug{
1640what = [[ ]], 1686what = [[ ]],
1641report = [[ , on ]], 1687report = [[ , on ]],
1642since = [[i ]], 1688since = [[i ]],