aboutsummaryrefslogtreecommitdiff
path: root/testes/cstack.lua
diff options
context:
space:
mode:
Diffstat (limited to 'testes/cstack.lua')
-rw-r--r--testes/cstack.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/testes/cstack.lua b/testes/cstack.lua
index 7bd55063..213d15d4 100644
--- a/testes/cstack.lua
+++ b/testes/cstack.lua
@@ -2,6 +2,8 @@
2-- See Copyright Notice in file all.lua 2-- See Copyright Notice in file all.lua
3 3
4 4
5local tracegc = require"tracegc"
6
5print"testing stack overflow detection" 7print"testing stack overflow detection"
6 8
7-- Segmentation faults in these tests probably result from a C-stack 9-- Segmentation faults in these tests probably result from a C-stack
@@ -21,7 +23,9 @@ do print("testing stack overflow in message handling")
21 count = count + 1 23 count = count + 1
22 return 1 + loop(x, y, z) 24 return 1 + loop(x, y, z)
23 end 25 end
26 tracegc.stop() -- __gc should not be called with a full stack
24 local res, msg = xpcall(loop, loop) 27 local res, msg = xpcall(loop, loop)
28 tracegc.start()
25 assert(msg == "error in error handling") 29 assert(msg == "error in error handling")
26 print("final count: ", count) 30 print("final count: ", count)
27end 31end
@@ -135,18 +139,18 @@ if T then
135 local topB, sizeB -- top and size Before overflow 139 local topB, sizeB -- top and size Before overflow
136 local topA, sizeA -- top and size After overflow 140 local topA, sizeA -- top and size After overflow
137 topB, sizeB = T.stacklevel() 141 topB, sizeB = T.stacklevel()
138 collectgarbage("stop") -- __gc should not be called with a full stack 142 tracegc.stop() -- __gc should not be called with a full stack
139 xpcall(f, err) 143 xpcall(f, err)
140 collectgarbage("restart") 144 tracegc.start()
141 topA, sizeA = T.stacklevel() 145 topA, sizeA = T.stacklevel()
142 -- sizes should be comparable 146 -- sizes should be comparable
143 assert(topA == topB and sizeA < sizeB * 2) 147 assert(topA == topB and sizeA < sizeB * 2)
144 print(string.format("maximum stack size: %d", stack1)) 148 print(string.format("maximum stack size: %d", stack1))
145 LIM = N -- will stop recursion at maximum level 149 LIM = N -- will stop recursion at maximum level
146 N = 0 -- to count again 150 N = 0 -- to count again
147 collectgarbage("stop") -- __gc should not be called with a full stack 151 tracegc.stop() -- __gc should not be called with a full stack
148 f() 152 f()
149 collectgarbage("restart") 153 tracegc.start()
150 print"+" 154 print"+"
151end 155end
152 156