Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.98k stars 560 forks source link

perl 5.31.7 has incompatible change "tr/AB/1/ds" #17391

Closed ina-cpan closed 4 years ago

ina-cpan commented 4 years ago

perl 5.31.7 has incompatible change "tr/AB/1/ds"

$ perl -e '$_="ABAB"; tr/AB/1/ds; print'

Since perl 5.00503 to perl 5.31.6 make ==> 1

But perl 5.31.7 does ==> 11

I noticed this in the FAIL report for UTF8::R2. http://www.cpantesters.org/cpan/report/32566ff0-26e1-11ea-96f2-7978ab727c9c http://www.cpantesters.org/cpan/report/a768cd28-15bc-11ea-972b-ef706694f557

Thanks, ina

eserte commented 4 years ago

To be more precise: the problem started with perl 5.31.6.

atoomic commented 4 years ago

The regression was introduced somewhere between 472799915f..00bd451dcd during the v5.31.6 dev cycle

| * 6507ac8375  Change names of some OPpTRANS flags
| * 00bd451dcd  doop.c: Refactor do_trans_complex()     # test failed
| * 79f0ed310a  t/op/tr.t: Add tests, incl. a TODO      # fail to compile
| * 5e874c42f3  doop.c: Change name of variable         # fail to compile
| * 472799915f  doop.c: Change out-of-bounds value      # test passes - no errors
| * b8e8e0fc7c  doop.c: Add, revise comments
| * 1132699c20  op.c: Simplify expression.

https://github.com/Perl/perl5/compare/472799915f..00bd451dcd

atoomic commented 4 years ago

This is one of these changes https://github.com/Perl/perl5/compare/472799915f..00bd451dcd

jkeenan commented 4 years ago

perl 5.31.7 has incompatible change "tr/AB/1/ds"

$ perl -e '$_="ABAB"; tr/AB/1/ds; print'

Since perl 5.00503 to perl 5.31.6 make ==> 1

But perl 5.31.7 does ==> 11

I noticed this in the FAIL report for UTF8::R2. http://www.cpantesters.org/cpan/report/32566ff0-26e1-11ea-96f2-7978ab727c9c http://www.cpantesters.org/cpan/report/a768cd28-15bc-11ea-972b-ef706694f557

Thanks, ina

This regression appears to hold regardless of the order of the two function modifiers.

$ perl -e '$_="ABAB"; tr/AB/1/ds; print "$_\n";'
1
$ ./perl -e '$_="ABAB"; tr/AB/1/ds; print "$_\n";'
11
$ perl -e '$_="ABAB"; tr/AB/1/sd; print "$_\n";'
1
$ ./perl -e '$_="ABAB"; tr/AB/1/sd; print "$_\n";'
11

... where perl is 5.30.0 and ./perl is v5.31.7-22-g77b20e6796.

Thank you very much. Jim Keenan

khwilliamson commented 4 years ago

I'll look into it. Note that I tried to fix a bug regarding this. perl5316delta.pod reads (where I have separated out the relevant text):

    The code that handles "tr///" has been extensively revised, fixing
     various bugs, especially when the source and/or replacement strings
     contain characters whose code points are above 255. Some of the bugs
     were undocumented, 

   one being that under some circumstances (but not
     all) with "/s", the squeezing was done based on the source, rather
     than the replacement.

    A documented bug that got fixed was [perl RT
     #125493].
jkeenan commented 4 years ago

Bisecting with this command:

$> perl Porting/bisect.pl --start=v5.31.5 --end=v5.31.7 \
-- ./perl -Ilib /tmp/ghi-17391.pl

... where the test program contained:

$> cat ghi-17391.pl 

$_="ABAB";
tr/AB/1/ds;
if ($_ eq '1') {
    print "Success\n";
    exit 0;
}
else {
    print "Failure\n";
    exit 1;
}

... yielded this result:

cc -c -DPERL_CORE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -std=c89 -g -Wall -Werror=declaration-after-statement -Werror=pointer-arith -Wextra -Wc++-compat -Wwrite-strings doio.c
doop.c: In function ‘S_do_trans_complex’:
doop.c:187:12: error: ‘ch’ undeclared (first use in this function); did you mean ‘cv’?
   else if (ch == (short) TR_DELETE)
            ^~
            cv
doop.c:187:12: note: each undeclared identifier is reported only once for each function it appears in
Makefile:250: recipe for target 'doop.o' failed
make: *** [doop.o] Error 1
make: *** Waiting for unfinished jobs....
HEAD is now at 5e874c42f3 doop.c: Change name of variable
skipping - could not build test_prep at /tmp/xh8c0V4igl line 1249.
There are only 'skip'ped commits left to test.
The first bad commit could be any of:
5e874c42f3fcb001bc30d9d1a2618581b52a412e
79f0ed310ab9459639c1dfac0c0c276669ad500d
00bd451dcd3aeb82c9155d46e0f39afac4e75a7a
We cannot bisect more!
bisect run cannot continue any more
Died at Porting/bisect.pl line 269.

The fact that at least one of the commits to blead (79f0ed310ab9459639c1dfac0c0c276669ad500d) would not build prevents more accurate analysis.

Thank you very much. Jim Keenan

khwilliamson commented 4 years ago

I'll look into it. Note that I tried to fix a bug regarding this. perl5316delta.pod reads (where I have separated out the relevant text):

    The code that handles "tr///" has been extensively revised, fixing
     various bugs, especially when the source and/or replacement strings
     contain characters whose code points are above 255. Some of the bugs
     were undocumented, 

   one being that under some circumstances (but not
     all) with "/s", the squeezing was done based on the source, rather
     than the replacement.

    A documented bug that got fixed was [perl RT
     #125493].