Re: Problems while switching C stacks (fibers)

  • From: Konstantin Osipov <kostja@xxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 6 May 2013 16:19:30 +0400

* Konstantin Olkhovskiy <lupus@xxxxxxxxxx> [13/05/06 16:15]:
> I'm trying to integrate my fiber library (based on libcoro) with luajit.
> Fiber creation is done via pure Lua/C api via trampoline C fiber that does
> roughly the following:
> - calls lua_newthread to create a new ``thread'' for the fiber
> - determines parent lua thread (if any, or root lua state)
> - performs lua_xmove for 2 values from parent state to thread state
> (function and a single argument)
> - does a lua_pcall on the thread's state
> 
> All of the above is performed inside a C fiber on a separate stack.

Most likely your reference counting for the newly created Lua
state is not done right.

You might want to take a look at how exactly the same task is done
in Tarantool,

https://github.com/mailru/tarantool/blob/master/src/lua/init.m#L469


The stuff you're trying to do is already done in Tarantool, too :)

http://www.tarantool.org/tarantool_user_guide.html#sp-box-socket

-- 
http://tarantool.org - an efficient, extensible in-memory data store

Other related posts: