[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: stack overflow?
- From: Rici Lake <lua@...>
- Date: Tue, 30 Aug 2005 17:37:59 -0500
On 30-Aug-05, at 5:24 PM, Brent Arias wrote:
If I'm recursing deeply (pushing a couple parameters on the stack each
time), and I'm checking lua_gettop(..) each time through, I presume it
be larger each time? That is, lua_gettop reveals the total stack
just the size of the current recursive frame?
lua_gettop() at entry to a function tells you (precisely) the number of
arguments supplied. Stack indices are within the current stackframe;
all other frames are invisible.
There is no API to tell you how big the total stack is. You shouldn't
Recursing through a lua_CFunction uses up C stack frames as well as Lua
stack frames. The MAXCCALLS setting is deliberately kept low in order
to minimize the danger of overflowing the C stack, as I understand it,
since there is no reliable way to test for this condition (whereas Lua
can and does test for an out-of-memory condition when attempting to
expand the Lua stack.)
Read the reference manual's short but precise section on the Lua API
for more details :)