Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0) - Mailing list pgsql-bugs

From Alex Hunsaker
Subject Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)
Date
Msg-id 34d269d41002242101h5eb8ebf0o54ba1646cdbe35d@mail.gmail.com
Whole thread Raw
In response to Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)  (Tim Bunce <Tim.Bunce@pobox.com>)
Responses Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)
List pgsql-bugs
On Tue, Feb 23, 2010 at 15:54, Tim Bunce <Tim.Bunce@pobox.com> wrote:
> Doesn't seem too icky. Basically plperl would need to save the values of
> PL_defstash, PL_incgv and PL_op_mask when a plperl interpreter is
> initialized. =C2=A0And then local()'ly restore them in the plperl entry p=
oints.
> Should only be a few lines of code - in theory :)

Ok I can get behind this.  I did some testing and we could probably
even store less than than that if we could do the equivalent of:
Safe->share('::mksafefunc');
pl_perl_createsub()
Safe->unshare('::mksafefunc');

See my quick test case:
my $s =3D Safe->new();
$s->permit(qw(print));

our $obj =3D sub { return eval 'sub { print "b\n";}' };
$obj->()->();
$s->share(qw($obj));
$s->reval('$obj->()->();');
print $@ . "\n";
---
b
b

(BTW the above fails with the helpful "Undefined subroutine &main::
called at (eval 6) line 1." without the ->permt(qw(print))")

So we might not even have to store anything if we can make it behave
as above.  However I think it will be cleaner to me to locally restore
them as your originally suggested.

BTW sorry for my scatter braininess.  I keep flip flopping between
revet Safe or patch postgres.  ATM it seems if the patch is simple we
can get it back patched and into 9.0.  So my vote is lets try that, if
its to hard then lets see about reverting Safe.  Sound Ok?

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: PostgreSQL-9.0alpha: jade required?
Next
From: "David E. Wheeler"
Date:
Subject: Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)