lua-users home
lua-l archive

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


Ok... thanks for the info, doing forensics now...

Rici Lake wrote:


On 12-Oct-05, at 10:44 PM, David Morris-Oliveros wrote:

It asserts on line 4 of the code below. Now my question is, is it supposed to be L->ci->top or just L->top? Because lua_gettop() is (L->top - L->base), and like 9 below is very similar to this.


L->ci->top is the end of the allocated stack (allocated in the sense that you've done lua_checkstack() to make sure that you have that stack space available; if you don't do that, you have 20 slots.) L->top is the top of the actual stack.

If L->ci->top < L->top, something evil has happened (this could happen if you didn't do a lua_checkstack(), but in that case the index would be >20).

It's not an api error to refer to a stack slot that has been allocated, even if it is beyond the end of the current stack. (Although it's highly questionable.) On the other hand, a negative index greater than the current end is clearly a non-existent stack slot. That's why those two lines are different.

I wonder if your problem has to do with the fact that there are two stacks in play when you're doing coroutines. It's pretty easy to use the wrong one by mistake.

Rici




--
// David Morris-Oliveros
// Camera & Lua Coder
// Team Bondi


------------------------------------------------------------------------
Contact:
Team Bondi Pty Ltd
Level 2, 608 Harris Street
Ultimo, NSW 2007
Australia
Tel: +61 (0)2 8218 1500
Fax: +61 (0)2 8218 1507
Web: http://www.teambondi.com
------------------------------------------------------------------------
This email may contain confidential information.  If you are not
the intended recipient, you may not copy or deliver this message to
anyone. In such case, you should destroy this message and kindly
notify the sender by reply email. Opinions, conclusions and other
information in this message that do not relate to the official business
of our firm shall be understood as neither given nor endorsed by it.
------------------------------------------------------------------------