[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: coroutine library can cause panic with low memory
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 2 Mar 2009 15:16:43 -0700
On Mon, Mar 2, 2009 at 2:24 PM, M Joonas Pihlaja
<jpihlaja@cc.helsinki.fi> wrote:
> Right, just as in your example, but I was saying that I think that
> that's a different issue which doesn't warrant changing the existing
> semantics of lua_checkstack(). Every single use of lua_checkstack()
> I've ever written assumes that it will throw a memory error as per the
> manual[1] and depends on those semantics for safety. I expect most
> uses of lua_checkstack() are the same, so changing its behaviour in
> that respect now will likely break lots of programs.
There are other cases where lua_checkstack may fail but it won't throw
an error. If you attempt to allocate more space on the stack above the
maximum C stack limit, then it will immediately return 0. I do not see
why lua_checkstack must fail differently on memory allocation failure.
However...
> 2) An alternate lua_checkstack() or lua_xmove() that takes an extra
> lua_State to throw exceptions on. Namely the resuming lua_State.
I am (also) not in favor of complicating lua_checkstack. I agree something like:
lua_checkcostack(lua_State *L, lua_State *co, int num)
would be favorable. It would require only a simple change to ldo.c
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."