>>>>> "Laurent" == Laurent FAILLIE <email@example.com
Laurent> So, what should I do to correctly call a function in another
Laurent> thread ?
Dump the function to a bytecode string and load the string in the other
You can't safely do it any other way, because each "main" state has its
own independent garbage collection, and can't know whether any of its
objects are referenced by other main states. Even if you worked around
that by holding references to everything, you'd fall foul of memory
synchronization issues, string interning issues, and all sorts of other
breakage (some of which you mentioned in your message).
If you turn on API checks, you'll notice that lua_xmove will abort if
you try and move values between independent states; this operation is
forbidden. The only way to communicate values between independent states
is to serialize them in some form.
(cqueues has an example, you might look at that)