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

From: Alex Hunsaker <badalex(at)gmail(dot)com>
To: Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, "David E(dot) Wheeler" <david(dot)wheeler(at)pgexperts(dot)com>, Rafael Garcia-Suarez <rgs(at)consttype(dot)org>
Subject: Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)
Date: 2010-02-25 05:01:34
Message-ID: 34d269d41002242101h5eb8ebf0o54ba1646cdbe35d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, Feb 23, 2010 at 15:54, Tim Bunce <Tim(dot)Bunce(at)pobox(dot)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.  And then local()'ly restore them in the plperl entry points.
> 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 = Safe->new();
$s->permit(qw(print));

our $obj = 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?

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alex Hunsaker 2010-02-25 06:34:18 Re: New PL/Perl failure with Safe 2.2x due to recursion (8.x & 9.0)
Previous Message Tom Lane 2010-02-25 04:22:57 Re: PostgreSQL-9.0alpha: jade required?