aboutsummaryrefslogtreecommitdiff
path: root/manual
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-18 16:52:22 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-18 16:52:22 -0300
commitbe73f72fcc944a8ebae2c60d2ce84139acb011b9 (patch)
tree6ba1154c224a4b7af9e5202b4b52e43706faddb1 /manual
parent3cd9b56ae6002b4ef28d2467abd119606ae625d3 (diff)
downloadlua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.tar.gz
lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.tar.bz2
lua-be73f72fcc944a8ebae2c60d2ce84139acb011b9.zip
New function 'setCstacklimit'
Added new functions to dynamically set the C-stack limit ('lua_setCstacklimit' in the C-API, 'debug.setCstacklimit' in Lua).
Diffstat (limited to 'manual')
-rw-r--r--manual/manual.of42
1 files changed, 42 insertions, 0 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 725b12ad..e9416956 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -4803,6 +4803,20 @@ calling @Lid{lua_yield} with @id{nresults} equal to zero
4803 4803
4804} 4804}
4805 4805
4806@APIEntry{int (lua_setCstacklimit) (lua_State *L, unsigned int limit);|
4807@apii{0,0,-}
4808
4809Sets a new limit for the C stack.
4810This limit controls how deeply nested calls can go in Lua,
4811with the intent of avoiding a stack overflow.
4812Returns the old limit in case of success,
4813or zero in case of error.
4814For more details about this function,
4815see @Lid{debug.setCstacklimit},
4816its equivalent in the standard library.
4817
4818}
4819
4806@APIEntry{void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);| 4820@APIEntry{void lua_sethook (lua_State *L, lua_Hook f, int mask, int count);|
4807@apii{0,0,-} 4821@apii{0,0,-}
4808 4822
@@ -8516,6 +8530,34 @@ to the userdata @id{u} plus a boolean,
8516 8530
8517} 8531}
8518 8532
8533@LibEntry{debug.setCstacklimit (limit)|
8534
8535Sets a new limit for the C stack.
8536This limit controls how deeply nested calls can go in Lua,
8537with the intent of avoiding a stack overflow.
8538A limit too small restricts recursive calls pointlessly;
8539a limit too large exposes the interpreter to stack-overflow crashes.
8540Unfortunately, there is no way to know a priori
8541the maximum safe limit for a platform.
8542
8543Each call made from Lua code counts one unit.
8544Other operations (e.g., calls made from C to Lua or resuming a coroutine)
8545may have a higher cost.
8546
8547This function has the following restrictions:
8548@description{
8549@item{It can only be called from the main coroutine (thread);}
8550@item{It cannot be called while handling a stack-overflow error;}
8551@item{@id{limit} must be less than 40000;}
8552@item{@id{limit} cannot be less than the amount of C stack in use.}
8553}
8554In case of success,
8555this function returns the old limit.
8556In case of error,
8557it returns @false.
8558
8559}
8560
8519@LibEntry{debug.sethook ([thread,] hook, mask [, count])| 8561@LibEntry{debug.sethook ([thread,] hook, mask [, count])|
8520 8562
8521Sets the given function as the debug hook. 8563Sets the given function as the debug hook.