[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: The C API and yielded threads: What is allowed?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 17 Nov 2017 17:09:41 -0200
> my problem is basically: Which functions am I allowed to call on a
> lua_State with lua_status(L) == LUA_YIELD? Also, where in the manual is
> this documented (and/or: could someone write up the needed docs for this)?
> So, what is the state of this? Is the assertion from  correct that
> only lua_resume, lua_xmove, lua_pushthread and lua_checkstack are okay?
> (I would add lua_version to the list, and I bet there are other
> functions which ought to be okay:)
Indeed this is not well documented. Basically, you should be able to
call anything with no chances of running Lua code. (That corresponds
roughly to the functions that cannot raise errors in the API minus
lua_pcall.) We will try to document that.
> However, I don't think that even just lua_checkstack is okay since if
> HARDMEMTESTS is defined this can cause a complete GC run (and this runs
> finalizers, right?). If so, then I can not even push the arguments for
> continuation to the yielded thread if there are too many?!?
HARDMEMTESTS is only for internal debuging purposes. Moreover, the
"complete GC run" in that case (and also in the case of an emergency
collection, which can actually happens in regular code) does not run