diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-02-26 11:31:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-02-26 11:31:10 -0300 |
commit | f9e35627ed26dff4114a1d01ff113d8b4cc91ab5 (patch) | |
tree | ad817f574adcd2d57720c8a498626919b85e6e78 /testes | |
parent | ceac82f78be8baeddfa8536472d8b08df2eb7d49 (diff) | |
download | lua-f9e35627ed26dff4114a1d01ff113d8b4cc91ab5.tar.gz lua-f9e35627ed26dff4114a1d01ff113d8b4cc91ab5.tar.bz2 lua-f9e35627ed26dff4114a1d01ff113d8b4cc91ab5.zip |
'lua_State.nci' must be an integer
Lua can easily overflow an unsigned short counting nested calls.
(The limit to this value is the maximum stack size, LUAI_MAXSTACK,
which is currently 1e6.)
Diffstat (limited to 'testes')
-rw-r--r-- | testes/coroutine.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/testes/coroutine.lua b/testes/coroutine.lua index 78b9bdca..abc08039 100644 --- a/testes/coroutine.lua +++ b/testes/coroutine.lua | |||
@@ -127,6 +127,18 @@ assert(#a == 22 and a[#a] == 79) | |||
127 | x, a = nil | 127 | x, a = nil |
128 | 128 | ||
129 | 129 | ||
130 | do -- "bug" in 5.4.2 | ||
131 | local function foo () foo () end -- just create a stack overflow | ||
132 | local co = coroutine.create(foo) | ||
133 | -- running this coroutine would overflow the unsigned short 'nci', the | ||
134 | -- counter of CallInfo structures available to the thread. | ||
135 | -- (The issue only manifests in an 'assert'.) | ||
136 | local st, msg = coroutine.resume(co) | ||
137 | assert(string.find(msg, "stack overflow")) | ||
138 | assert(coroutine.status(co) == "dead") | ||
139 | end | ||
140 | |||
141 | |||
130 | print("to-be-closed variables in coroutines") | 142 | print("to-be-closed variables in coroutines") |
131 | 143 | ||
132 | local function func2close (f) | 144 | local function func2close (f) |