Re: [PATCH] fix segfault with DO and plperl/plperlu

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alex Hunsaker <badalex@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2010-04-18T19:17:39Z
Lists: pgsql-hackers
Alex Hunsaker <badalex@gmail.com> writes:
> 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.

Hmm.  I don't see a segfault on my machine, but I agree that this looks
bogus.  I changed it to this order instead:

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

so as to keep the "state restore" operations together.

			regards, tom lane