lua-users home
lua-l archive

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

Thankyou! I now call luaL_ref immediately after the call to lua_newthread (and no additional push/pops). This serves the dual purpose of preventing the thread from being GC'd, as well as removing the thread from the master's stack. I then unref the returned refid when my C++ script object destructs.

All appears to be working...


Thomas Blom wrote:
Below is the simplest test I could concoct to repro. There are a few interesting cases:

   lua_State * pThread = lua_newthread( master );
 From Reference Manual:


Creates a new thread, pushes it on the stack, and returns a pointer to a lua_State that
   represents this new thread.

   3.2 - Stack Size

When you interact with Lua API, you are responsible for ensuring consistency. In particular, you are responsible for controlling stack overflow. You can use the function lua_checkstack
   to grow the stack size.

So you just overflow master's stack.

Using Opera's revolutionary e-mail client: