lua-users home
lua-l archive

Re: LuaJIT + Coco : coroutine issue

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


Hi,
Dmitriy Iassenev wrote:
> I have the following problem : when coroutine.yield is called from the
> script side in the thread, which is created from the C side using
> lua_newthread, an error
> 
> "attempt to yield across metamethod/C-call boundary"
> 
> occured. If I change to lua_newcthread, all is ok.
This is ok and expected. JIT compiled functions behave like
C functions, i.e. Coco is required for yielding.
> But all is ok only in case when newly created thread is in the lua
> stack, though I use luaL_ref for referencing thread to prevent it to
> be garbage collected and to remove it form the lua stack. This scheme
> works fine for Lua 5.1 alpha, but it doesn work with LuaJIT + Coco.
Well, but what happens? An error or a crash?
* You get the above error: This must be a logic error somewhere.
You are resuming the wrong coroutine or a coroutine not created
with lua_newcthread. You may never notice this with plain Lua.
* A crash when running under Windows XP: Please apply this change:
 http://lua-users.org/lists/lua-l/2005-12/msg00098.html
* Still a crash in a random place: Are you 100% sure you've made a
reference to the coroutine? The incremental garbage collection is
very sensitive to tiny changes and LuaJIT obviously allocates a
few more objects. I suggest you turn on assertions as described in
 jitdoc/luajit_debug.html
and then check if you get strange errors. This almost always
means a coroutine reference has been lost.
> What am I doing wrong? Does LuaJIT depends on luaopen_... sequence?
Not really (at least not yet). The sequence you are using is fine
and matches the order in linit.c. I suggest you keep it.
Bye,
 Mike

AltStyle によって変換されたページ (->オリジナル) /