[PATCH] fix segfault with DO and plperl/plperlu

From: Alex Hunsaker <badalex(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: [PATCH] fix segfault with DO and plperl/plperlu
Date: 2010-04-18 06:48:41
Message-ID: x2q34d269d41004172348hbc78d168y5e913a951be91ca2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

If you do:

# DO $do$ 1; $do$ LANGUAGE plperlu;
# DO $do$ 1; $do$ LANGUAGE plperl;

You get a segfault as we try to SvREFCNT_dec(...); for the wrong
interpreter. To fix push down the restore_context() so that we do the
above on the correct perl interpreter.
--
*** a/src/pl/plperl/plperl.c
--- b/src/pl/plperl/plperl.c
***************
*** 1154,1170 **** plperl_inline_handler(PG_FUNCTION_ARGS)
PG_CATCH();
{
current_call_data = save_call_data;
- restore_context(oldcontext);
if (desc.reference)
SvREFCNT_dec(desc.reference);
PG_RE_THROW();
}
PG_END_TRY();

current_call_data = save_call_data;
- restore_context(oldcontext);
if (desc.reference)
SvREFCNT_dec(desc.reference);

error_context_stack = pl_error_context.previous;

--- 1154,1170 ----
PG_CATCH();
{
current_call_data = save_call_data;
if (desc.reference)
SvREFCNT_dec(desc.reference);
+ restore_context(oldcontext);
PG_RE_THROW();
}
PG_END_TRY();

current_call_data = save_call_data;
if (desc.reference)
SvREFCNT_dec(desc.reference);
+ restore_context(oldcontext);

error_context_stack = pl_error_context.previous;

Attachment Content-Type Size
fix_do_plperl_plperlu.patch text/x-patch 915 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-04-18 07:24:36 Re: testing HS/SR - 1 vs 2 performance
Previous Message Josh Kupershmidt 2010-04-18 03:53:01 patch: Distinguish between unique indexes and unique constraints