summaryrefslogtreecommitdiff
path: root/testes/cstack.lua
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-26 13:26:36 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-26 13:26:36 -0300
commit8b7cfee26b71e66de2cef9f8db9d9e18f5439afd (patch)
tree8590bc5eba700f6c03da032bff8a925de257c726 /testes/cstack.lua
parentc1a63c45f8ec5932993c8cec40d3c5ec0743349c (diff)
downloadlua-github-8b7cfee26b71e66de2cef9f8db9d9e18f5439afd.tar.gz
Small changes around C-stack limit
- Better documentation in 'testes/cstack.lua' about using 'debug.setCstacklimit' to find a good limit. - Constant LUAI_MAXCSTACK gets added CSTACKERR (extra stack for error handling), so that it is compatible with the argument to 'debug.setCstacklimit'.
Diffstat (limited to 'testes/cstack.lua')
-rw-r--r--testes/cstack.lua28
1 files changed, 21 insertions, 7 deletions
diff --git a/testes/cstack.lua b/testes/cstack.lua
index c7aa740f..2a55ce21 100644
--- a/testes/cstack.lua
+++ b/testes/cstack.lua
@@ -4,15 +4,29 @@
local debug = require "debug"
print"testing C-stack overflow detection"
+print"If this test craches, see its file ('cstack.lua')"
+
+-- Segmentation faults in these tests probably result from a C-stack
+-- overflow. To avoid these errors, you can use the function
+-- 'debug.setCstacklimit' to set a smaller limit for the use of
+-- C stack by Lua. After finding a reliable limit, you might want
+-- to recompile Lua with this limit as the value for
+-- the constant 'LUAI_MAXCCALLS', which defines the default limit.
+-- (The default limit is printed by this test.)
+-- Alternatively, you can ensure a larger stack for the program.
+
+-- For Linux, a limit up to 30_000 seems Ok. Windows cannot go much
+-- higher than 2_000.
+
local origlimit = debug.setCstacklimit(400)
-print("current stack limit: " .. origlimit)
-debug.setCstacklimit(origlimit)
+print("default stack limit: " .. origlimit)
+
+-- change this value for different limits for this test suite
+local currentlimit = origlimit
+debug.setCstacklimit(currentlimit)
+print("current stack limit: " .. currentlimit)
--- Segmentation faults in these tests probably result from a C-stack
--- overflow. To avoid these errors, recompile Lua with a smaller
--- value for the constant 'LUAI_MAXCCALLS' or else ensure a larger
--- stack for the program.
local function checkerror (msg, f, ...)
local s, err = pcall(f, ...)
@@ -104,7 +118,7 @@ do print("testing changes in C-stack limit")
return n
end
- assert(debug.setCstacklimit(400) == origlimit)
+ assert(debug.setCstacklimit(400) == currentlimit)
local lim400 = check()
-- a very low limit (given that the several calls to arive here)
local lowlimit = 38