mirror of
https://github.com/lua/lua
synced 2024-11-22 21:01:26 +03:00
Fixed bug: wrong stack limit when entering a coroutine
When entering a coroutine, the computation of nCcalls added 'from->nci' to correct for preallocated CallInfos, but 'nci' includes also the Callinfos already used.
This commit is contained in:
parent
0f1cd0eba9
commit
e1d8770f12
2
ldo.c
2
ldo.c
@ -674,7 +674,7 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
|
||||
if (from == NULL)
|
||||
L->nCcalls = CSTACKTHREAD;
|
||||
else /* correct 'nCcalls' for this thread */
|
||||
L->nCcalls = getCcalls(from) + from->nci - L->nci - CSTACKCF;
|
||||
L->nCcalls = getCcalls(from) - L->nci - CSTACKCF;
|
||||
if (L->nCcalls <= CSTACKERR)
|
||||
return resume_error(L, "C stack overflow", nargs);
|
||||
luai_userstateresume(L, nargs);
|
||||
|
@ -105,6 +105,22 @@ do print("testing stack-overflow in recursive 'gsub'")
|
||||
print("\tfinal count: ", count)
|
||||
end
|
||||
|
||||
do -- bug in 5.4.0
|
||||
print("testing limits in coroutines inside deep calls")
|
||||
count = 0
|
||||
local lim = 1000
|
||||
local function stack (n)
|
||||
progress()
|
||||
if n > 0 then return stack(n - 1) + 1
|
||||
else coroutine.wrap(function ()
|
||||
stack(lim)
|
||||
end)()
|
||||
end
|
||||
end
|
||||
|
||||
print(xpcall(stack, function () return "ok" end, lim))
|
||||
end
|
||||
|
||||
|
||||
do print("testing changes in C-stack limit")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user