From: | Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com> |
---|---|
To: | Alex Hunsaker <badalex(at)gmail(dot)com> |
Cc: | Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #5334: Version 2.22 of Perl Safe module breaks UTF8 PostgreSQL 8.4 |
Date: | 2010-02-19 09:30:41 |
Message-ID: | 20100219093041.GE373@timac.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Feb 18, 2010 at 11:32:38AM -0700, Alex Hunsaker wrote:
> On Thu, Feb 18, 2010 at 11:09, Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com> wrote:
> > The key line is:
> >
> > *PLPerl::utf8::SWASHNEW = \&utf8::SWASHNEW;
>
> Hrm... It seems to work for me in HEAD and AFAICS we dont have that
> line. Did I just miss it? Or did you happen to fix it in another way
> with your refactoring?
To be honest I'm not sure. I plan to look into that today.
> Another Idea that comes to mind would be instead of (in ::mksafefunc):
> my $subref = ->reval(sub {} );
> $subref->();
>
> do:
> my $subref = ->reval(sub {});
> return sub { ->reval("$subreb->();"); }
>
> or something...
>
> I did a few quick tests but it failed miserably for me... Im also not
> fond of adding yet another closure. :)
No amount of closure wrapping will fix the problem.
> > This allows the perl regex logic to call the SWASHNEW method that's
> > called when information from the Unicode character database is needed.
> > (The lack of that method was causing the regex logic to think that the
> > utf8 module wasn't loaded, so it would try to 'require' it but fail due
> > to the restrictions of the Safe compartment.)
>
> Makes me think we might just be able to share some of utf8 package in the safe?
I tried. The perl utf8.c code does a method lookup of SWASHNEW to decide
if the utf8 module has been loaded. So if SWASHNEW is shared _before_
utf8 is loaded *and used* then the method lookup works (it finds the
shared stub) and the utf8 module never gets loaded.
(The *and used* complication is due to utf8.pm being a thin wrapper with
an AUTOLOAD trampoline that loads utf8_heavy.pl on first use. More fun.)
I do have a patch for Safe that, if utf8 is loaded, will ensure it's
'used' and then auto-share SWASHNEW. That won't fix PostgreSQL 8.x
though because utf8 isn't loaded at the time Safe->new is called.
> > The rest of the patch is updates the surrounding code to the same
> > simplified 'utf8fix' logic used in PostgreSQL 9.0, and the same Safe
> > version checks.
>
> From a quick look it looks ok.
Thanks.
Tim.
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Bunce | 2010-02-19 13:06:17 | Re: BUG #5334: Version 2.22 of Perl Safe module breaks UTF8 PostgreSQL 8.4 |
Previous Message | Tim Bunce | 2010-02-19 09:13:28 | Re: [Tigerlead] BUG #5334: Version 2.22 of Perl Safe module breaks UTF8 PostgreSQL 8.4 |