develooper Front page | perl.perl5.porters | Postings from October 2014

[perl #123029] 5.20.x regression in "state" under PERL_NO_COW

Thread Previous | Thread Next
Father Chrysostomos via RT
October 21, 2014 23:19
[perl #123029] 5.20.x regression in "state" under PERL_NO_COW
Message ID:
On Tue Oct 21 10:36:51 2014, arc wrote:
> Niels Larson reports that Perl 5.20 compiled with -DPERL_NO_COW has a
> regression with state variables: they get reset to undef when
> accessed:
> sub no_PERL_NO_COW_regression {
>     state $s;
>     $s = 'foo';
>     my $c = $s;
>     return defined $s;
> }
> ok(no_PERL_NO_COW_regression(),
>    "state variables don't surprisingly disappear when accessed");
> Bisection reveals that the bug was introduced in
> 9ffd39ab75dd662df22fcdafbf7f740838acc898 (between 5.19.6 and 5.19.7),
> and fixed in c0683843e9299db25f354e2c8c90faa7614950d1 (between 5.21.4
> and 5.21.5).
> I'm creating this ticket so that (a) a regression test can mention it,
> and (b) the meta-ticket for 5.20.2 can depend on it.

With a COW build:

$ perl5.20.1 -l -E 'sub { state $s; $s = "foo"x500; my $c = $s; print $s//"undef"}->()'

SvPADTMP and SvPADSTALE used to share a bit, so

                       == SVs_PADTMP

gave the wrong answer.  Putting SVs_PADMY in the list of flags to check will fix the bug for 5.20.  However, there is also a problem with the way CHECK_COWBUF_THRESHOLD is defined.  Here we use it outside #ifdef PERL_NEW_COPY_ON_WRITE, and when COW is not enabled it is not defined properly.  So we need to change the COW constants to be defined regardless of whether COW is enabled, since they are also used for targ swiping.  5.20 without COW is slower than it needs to be, because targ swiping happens far too much, resulting in many malloc calls.

I’ll write a separate maint patch on a branch.


Father Chrysostomos

via perlbug:  queue: perl5 status: open

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About