lua-users home
lua-l archive

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


I wrote:
> Very likely you are catching the error with lua_pcall() or
> lua_resume() and then doing some processing on it.

Ok, we've resolved this: it was caused by relying on undefined
behavior (and LuaJIT is not very forgiving here):

Once a coroutine is dead, you can only inspect its stack to get a
backtrace, e.g. with debug.traceback(). But you're not supposed to
use a dead coroutine for *anything* else. E.g. running lua_call()
on the dead stack is asking for trouble. I've added assertions to
catch this misuse of the Lua/C API earlier.

Solution: run debug.traceback() in a parent coroutine or the main
thread and pass the coroutine as the first argument, i.e:
  debug.traceback(coro, msg)

[While the issue with dead coroutines has been discussed on the
mailing list before, it's sadly absent from the Lua manual.]

--Mike