lua-users home
lua-l archive

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


joe rossi wrote:
> I'm trying to integrate the Pluto project with LuaJIT.
>  I have a problem that seems to come from the
> lua_resume function of LuaJITs ldo.c on this call:
> luai_userstateresume(L, nargs);
> The pluto test script crashes here when returning a
> value from a resumed coroutine. How can I get around
> this?

My first guess is that the coroutine does not get a C stack
context when resurrected by Pluto. So this is more a problem with
Coco than with LuaJIT. But LuaJIT depends on Coco ...

Replacing lua_newthread(L) with lua_newcthread(L, 0) in
unpersistthread() would recreate the C stack, but without the
contents. Alas, the C stack contains pointers to data areas and
JIT compiled code. There is no guarantee these end up on the same
addresses when restored. This is about the same level of
difficulty as persisting the stack of an arbitrary C program --
i.e. intractable.

If you can arrange your code to only save/restore data structures
(and not coroutines) then the combination of LuaJIT and Pluto
would probably work -- but I haven't tested it.