lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Thu, May 5, 2011 at 10:36 AM, Jeremy Jurksztowicz
<> wrote:
> Hello,
> I'd like to have some info under what circumstances does the "too many
> results to resume." error occur? I'm running a coroutine and upon it's
> return this error pops up. I put a breakpoint at the error and noticed
> that the nres (number of results) is 0, and lua_checkstack(L, nres+1)
> fails. So I assumed that my stack was getting trashed somewhere (Is
> that assumption wrong?). To find the source of the error I stackdumped
> at the end of the function that is being run in the coroutine and got
> only one stack element: The thread (coroutine) that is running the
> function. I also stackdumped at the actual error (right before it
> prints the message) and got a stack filled with A) My error function
> that I pass to lua_pall B) Booleans (true and false) C) The number 1.
> So somewhere between the return call and the end of coroutine.resume
> something goes awfully wrong. My first instinct was to look for
> infinite loop/recursion, but couldn't find one. So my questions are:
> 1) Under what conditions would a "too many results to resume." error
> most likely occur.

A (C) Lua stack cannot exceed LUAI_MAXCSTACK (8000). You passed too
many results to coroutine.resume:

> t = {}; for i = 1, 8000 do t[i] = 1 end
> coroutine.resume(coroutine.create(function() end), unpack(t))
stdin:1: too many results to unpack
stack traceback:
	[C]: in function 'unpack'
	stdin:1: in main chunk
	[C]: ?
> t = {}; for i = 1, 7999 do t[i] = 1 end
> coroutine.resume(coroutine.create(function() end), unpack(t))

- Patrick Donnelly