develooper Front page | perl.perl5.porters | Postings from June 2009

Re: [PATCH] [RT #60508] Avoid stomping on regex ->offs when reentrant(e.g., utf8 swashes).

Thread Previous | Thread Next
From:
George Greer
Date:
June 21, 2009 12:57
Subject:
Re: [PATCH] [RT #60508] Avoid stomping on regex ->offs when reentrant(e.g., utf8 swashes).
Message ID:
alpine.LFD.2.00.0906211547590.28252@ein.m-l.org
On Sun, 21 Jun 2009, Rafael Garcia-Suarez wrote:

> I had a look at this, and this looks correct, (although the
> Devel::PPPort part is not necessary)
>
> However, I have a concern : while this patch removes usage of the swap
> entry of the regexps, it doesn't remove the swap entry from the regexp
> structs, which look like they don't serve any purpose anymore --
> although regcomp.c still references it (mostly to free its memory).

My original cut of the patch did that but I created the second patch from 
a fresh repository and forgot to do that part again (I noted that 
omission on the RT ticket).  I've been traveling lately so I haven't had 
time for a 3rd cut of the patch to include that.  If you refer to the 
first patch on the RT ticket, you'll see there isn't much else that relies 
on the ->swap, at least in the base Perl.

> But couldn't we use a broader approach and still make use of the swap
> pointer, but save it and restore it more properly ? (I'm waving
> hands.)

I had planned to make an alternate patch using the Perl stack macros 
rather than leaving it on the C stack, but I have to research their usage 
more, as I'm new to the code, before I can write that.  My reasoning for 
doing the alternate patch as well was perhaps that would resolve the 
pre-existing comment wondering about how it works with "eval { die }".

> I propose this also because this patch, if completed to remove swap,
> would break binary compatibility, and couldn't go in 5.10.x, because
> of the pluggable regex engines on CPAN. A completely backportable fix
> would be nicer, if possible. If that's not realistic I guess we'll
> keep swap in the struct for the benefit of other engines.

For backportability, probably save_re_context() is a better place to do 
the saving than on the Perl stack inside the function since the struct 
member would still be there.  That would presumably be sufficient to 
prevent utf8::SWASHNEW from clobbering the original regexp offsets and 
still maintain the relative backreference offsets.  I'll be at YAPC 
Pittsburgh so the chances of doing the above soon are murky.

-George Greer

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About