pl/python: fix ref leak on elog

Started by Neil Conwayover 20 years ago3 messagespatches
Jump to latest
#1Neil Conway
neilc@samurai.com

Attached is a simple patch that fixes a minor problem in PL/Python: in
PLy_spi_execute_plan(), we invoke the input function for a Postgres data
type. If that function elog's (which is quite possible), PL/Python leaks
references to two temporary Python objects. The fix seems easy, albeit a
bit ugly: the reference count on one of the temporary objects can be
decremented before calling the function. A pointer that points into the
second object is passed to the input function itself, so we have to
PG_CATCH() the elog and decrement the refcount then.

Since the problem might actually occur in practice and the fix seems to
have little chance of inducing a regression, I'm thinking of applying
this to both HEAD and back branches. Barring any objections I'll do that
later today or early tomorrow.

-Neil

Attachments:

plpython_ref_leak-3.patchtext/x-patch; name=plpython_ref_leak-3.patch; x-mac-creator=0; x-mac-type=0Download+32-34
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#1)
Re: pl/python: fix ref leak on elog

Neil Conway <neilc@samurai.com> writes:

Since the problem might actually occur in practice and the fix seems to
have little chance of inducing a regression, I'm thinking of applying
this to both HEAD and back branches. Barring any objections I'll do that
later today or early tomorrow.

Looks alright to me. I agree with backpatching as far back as we have
PG_TRY. The reason for the FIXME was that there wasn't any simple way
to fix it before that ...

regards, tom lane

#3Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#2)
Re: pl/python: fix ref leak on elog

Tom Lane wrote:

Looks alright to me.

Applied to HEAD, REL8_1_STABLE, and REL8_0_STABLE.

-Neil