[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "*toclose" vs. sandboxes / embedded environments
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 18 Dec 2018 16:16:05 -0200
> Right now, if spi.execute gets an error generated by PG, what happens is
> that it stores the relevant details in a userdata, throws that as a Lua
> error, lets it propagate out to the lua_pcall that was used to call the
> function, and then raises it as a PG error again. There could be several
> levels of this - for example, the SQL query might contain a call to
> another Lua function. (It doesn't matter if the error gets replaced with
> a different error along the way, for example if we get an out-of-memory
> when trying to copy error data, as long as it continues to propagate as
> an error and as long as we're not executing arbitrary Lua code.)
>
> I can be sure this is safe because the Lua code can't interfere with the
> error process except by calling pcall()/xpcall(), which I already
> replaced with my own versions.
In your current implementation, what happens if there is a PG error
inside a coroutine? The error handler in that case is not pcall/xpcall,
but resume.
I must say that this whole process of changing pcall/xcall seems
somewhat smelly.
-- Roberto