[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Should Lua reject (via assertions) calls which may error on a yielded thread?
- From: Patrick Donnelly <batrick@...>
- Date: Tue, 9 Aug 2016 22:12:19 -0400
On Tue, Aug 9, 2016 at 4:47 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> We yield a thread that issues a blocking a socket operation and later
>> resume it via a callback. The resume takes place in a Lua function
>> which is called on the yielded thread. This was "okay" to do from a
>> past lua-l posting by (I think) Roberto. However, since Lua 5.2,
>> apparently there is a new assertion that fails if you call a function
>> on a yielded thread.
>
> Do you know which assertion?
api_check(L, L->status == LUA_OK, "cannot do calls on non-normal thread");
>> Also, a question I lack time to check: errors on a yielded thread
>> could cause catastrophic effects as there is no active lua_resume?
>> Does Lua panic? Does it make sense to have Lua just assert fail *all
>> API functions which may error* on a yielded thread? It seems to me
>> this should be explicitly disallowed in the manual but I found no
>> mention.
>
> Errors in a thread with no handler are "transfered" to the main thread.
> If it also has no handler, then Lua panics. (Nevertheless, the whole
> process is not very "stable". Other threads which might be active
> between the error and the recovery point of the main thread may get
> corrupted, because parts of their C stack were destroyed.)
Yah, I really think this should be explicitly forbidden in the manual
and checked in the code using assertions. There is no safe way to
handle exceptions that occur on a yielded thread.
> I have to rethink that again, but it does seem a good idea to use
> non-main threads only inside resumes.
I'm not sure I follow what you mean here.
--
Patrick Donnelly