Skip Menu |
Report information
Id: 130981
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: paul [at] pjcj.net
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: library
Perl Version: 5.25.10
Fixed In: (no value)



CC: paul [...] pjcj.net
Date: Sat, 11 Mar 2017 14:23:17 +0000 (GMT)
To: perlbug [...] perl.org
Subject: Confusing B::Deparse output with unless/elsif
From: paul [...] pjcj.net
Download (untitled) / with headers
text/plain 4.4k
This is a bug report for perl from paul@pjcj.net, generated with the help of perlbug 1.40 running under perl 5.25.10. ----------------------------------------------------------------- B::Deparse outputs some fairly confusing code for unless/elsif constructs: $ perl5.25.10 -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' $a ? do { $c } && do { $d } : do { $b }; -e syntax OK $ perl5.22.3 -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' if (not $a) { $b; } elsif ($c) { $d; } -e syntax OK $ 5.24.1 has the same output as 5.25.10 so it is not strictly a regression, I suppose. I've not confirmed, but I presume it came in somewhere during 5.23.x development. It is (rightly) quite an uncommon construct so I imagine it was just overlooked, but it does rather confuse Devel::Cover. See http://cpancover.com/latest//Net-DNS-1.08_02/blib-lib-Net-DNS-RR-pm--condition.html#113-1 for an example in the wild. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=library severity=low module=B::Deparse --- Site configuration information for perl 5.25.10: Configured by pjcj at Sat Mar 11 13:42:34 GMT 2017. Summary of my perl5 (revision 5 version 25 subversion 10) configuration: Platform: osname=linux osvers=3.13.0-110-generic archname=x86_64-linux uname='linux cpancover1.default.cpancover.uk0.bigv.io 3.13.0-110-generic #157-ubuntu smp mon feb 20 11:54:05 utc 2017 x86_64 x86_64 x86_64 gnulinux ' config_args='-de -Dprefix=/cover/perls/perlbrew/perls/perl-5.25.10 -Dusedevel -Aeval:scriptdir=/cover/perls/perlbrew/perls/perl-5.25.10/bin' hint=recommended useposix=true d_sigaction=define useithreads=undef usemultiplicity=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n bincompat5005=undef Compiler: cc='cc' ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' optimize='-O2' cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='' gccversion='4.8.4' gccosandvers='' intsize=4 longsize=8 ptrsize=8 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=16 longdblkind=3 ivtype='long' ivsize=8 nvtype='double' nvsize=8 Off_t='off_t' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='cc' ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib libs=-lpthread -lnsl -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=libc-2.19.so so=so useshrplib=false libperl=libperl.a gnulibc_version='2.19' Dynamic Linking: dlsrc=dl_dlopen.xs dlext=so d_dlsymun=undef ccdlflags='-Wl,-E' cccdlflags='-fPIC' lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Locally applied patches: Devel::PatchPerl 1.38 --- @INC for perl 5.25.10: /cover/perls/perlbrew/perls/perl-5.25.10/lib/site_perl/5.25.10/x86_64-linux /cover/perls/perlbrew/perls/perl-5.25.10/lib/site_perl/5.25.10 /cover/perls/perlbrew/perls/perl-5.25.10/lib/5.25.10/x86_64-linux /cover/perls/perlbrew/perls/perl-5.25.10/lib/5.25.10 --- Environment for perl 5.25.10: HOME=/home/pjcj LANG=en_GB.UTF-8 LANGUAGE=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8 LC_CTYPE=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/cover/perls/perlbrew/bin:/cover/perls/perlbrew/perls/perl-5.25.10/bin:/home/pjcj/g/base/utils:/home/pjcj/.local/bin:/home/pjcj/g/go/bin:/home/pjcj/g/sw/bin:/home/pjcj/.zplug/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games PERLBREW=command perlbrew PERLBREW_BASHRC_VERSION=0.75 PERLBREW_HOME=/home/pjcj/.perlbrew PERLBREW_MANPATH=/cover/perls/perlbrew/perls/perl-5.25.10/man PERLBREW_PATH=/cover/perls/perlbrew/bin:/cover/perls/perlbrew/perls/perl-5.25.10/bin PERLBREW_PERL=perl-5.25.10 PERLBREW_ROOT=/cover/perls/perlbrew PERLBREW_VERSION=0.75 PERL_BADLANG (unset) SHELL=/usr/bin/zsh
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.6k
On Sat, 11 Mar 2017 14:56:49 GMT, paul@pjcj.net wrote: Show quoted text
> > This is a bug report for perl from paul@pjcj.net, > generated with the help of perlbug 1.40 running under perl 5.25.10. > > > ----------------------------------------------------------------- > B::Deparse outputs some fairly confusing code for unless/elsif > constructs: > > $ perl5.25.10 -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' > $a ? do { > $c > } && do { > $d > } : do { > $b > }; > -e syntax OK > $ perl5.22.3 -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' > if (not $a) { > $b; > } > elsif ($c) { > $d; > } > -e syntax OK > $ > > 5.24.1 has the same output as 5.25.10 so it is not strictly a > regression, I > suppose. I've not confirmed, but I presume it came in somewhere > during > 5.23.x development. > > It is (rightly) quite an uncommon construct so I imagine it was just > overlooked, but it does rather confuse Devel::Cover. See > http://cpancover.com/latest//Net-DNS-1.08_02/blib-lib-Net-DNS-RR-pm-- > condition.html#113-1 > for an example in the wild. >
The change occurred between perl-5.23.7 and perl-5.23.8. Checking out each of those tags and configuring and building perl thereat, I got: ##### Version: v5.23.7 Previous HEAD position was 8d0cd0d... add new release to perlhist HEAD is now at 0057cac... add in the Known Issue, thanks again to BinGOs++ my($w, $x, $y, $z) = ('') x 4; if (not $w) { $x; } elsif ($y) { $z; } /home/jkeenan/learn/perl/unless.pl syntax OK ##### Version: v5.23.8 Previous HEAD position was 0057cac... add in the Known Issue, thanks again to BinGOs++ HEAD is now at 0d316f7... add new release to perlhist my($w, $x, $y, $z) = ('') x 4; $w ? do { $y } && do { $z } : do { $x }; /home/jkeenan/learn/perl/unless.pl syntax OK ##### My hunch was that any change in lib/B/Deparse.pm during the month when 5.23.8 was in development (Dec 2015-Jan 2016) would explain the problem. The only time B::Deparse was modified during this period was: ##### commit dc6dfd62197489a4c671a17a43d8555551b5446c Author: Lukas Mai <l.mai@web.de> AuthorDate: Wed Jan 6 15:16:16 2016 +0100 Commit: Lukas Mai <l.mai@web.de> CommitDate: Wed Jan 6 15:27:43 2016 +0100 Deparse the /n flag on regexes [perl #127189] ##### But, when I build perl at dc6dfd62197489a4c671a17a43d8555551b5446c^ and dc6dfd62197489a4c671a17a43d8555551b5446c and ran the test program, I got the same -- "good" -- results both times: ##### my($w, $x, $y, $z) = ('') x 4; if (not $w) { $x; } elsif ($y) { $z; } /home/jkeenan/learn/perl/unless.pl syntax OK ##### So I haven't yet been able to identify the commit where the problem first appeared. Thank you very much. -- James E Keenan (jkeenan@cpan.org)
RT-Send-CC: perl5-porters [...] perl.org
On Sat, 11 Mar 2017 10:03:55 -0800, jkeenan wrote: Show quoted text
> On Sat, 11 Mar 2017 14:56:49 GMT, paul@pjcj.net wrote:
> > > > This is a bug report for perl from paul@pjcj.net, > > generated with the help of perlbug 1.40 running under perl 5.25.10. > > > > > > ----------------------------------------------------------------- > > B::Deparse outputs some fairly confusing code for unless/elsif > > constructs: > > > > $ perl5.25.10 -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' > > $a ? do { > > $c > > } && do { > > $d > > } : do { > > $b > > }; > > -e syntax OK > > $ perl5.22.3 -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' > > if (not $a) { > > $b; > > } > > elsif ($c) { > > $d; > > } > > -e syntax OK > > $ > > > > 5.24.1 has the same output as 5.25.10 so it is not strictly a > > regression, I > > suppose. I've not confirmed, but I presume it came in somewhere > > during > > 5.23.x development. > > > > It is (rightly) quite an uncommon construct so I imagine it was just > > overlooked, but it does rather confuse Devel::Cover. See > > http://cpancover.com/latest//Net-DNS-1.08_02/blib-lib-Net-DNS-RR-pm-- > > condition.html#113-1 > > for an example in the wild. > >
> > The change occurred between perl-5.23.7 and perl-5.23.8. Checking out > each of those tags and configuring and building perl thereat, I got: > > ##### > Version: v5.23.7 > Previous HEAD position was 8d0cd0d... add new release to perlhist > HEAD is now at 0057cac... add in the Known Issue, thanks again to > BinGOs++ > my($w, $x, $y, $z) = ('') x 4; > if (not $w) { > $x; > } > elsif ($y) { > $z; > } > /home/jkeenan/learn/perl/unless.pl syntax OK > ##### > Version: v5.23.8 > Previous HEAD position was 0057cac... add in the Known Issue, thanks > again to BinGOs++ > HEAD is now at 0d316f7... add new release to perlhist > my($w, $x, $y, $z) = ('') x 4; > $w ? do { > $y > } && do { > $z > } : do { > $x > }; > /home/jkeenan/learn/perl/unless.pl syntax OK > ##### > > My hunch was that any change in lib/B/Deparse.pm during the month when > 5.23.8 was in development (Dec 2015-Jan 2016) would explain the > problem. > > The only time B::Deparse was modified during this period was: > > ##### > commit dc6dfd62197489a4c671a17a43d8555551b5446c > Author: Lukas Mai <l.mai@web.de> > AuthorDate: Wed Jan 6 15:16:16 2016 +0100 > Commit: Lukas Mai <l.mai@web.de> > CommitDate: Wed Jan 6 15:27:43 2016 +0100 > > Deparse the /n flag on regexes [perl #127189] > ##### > > But, when I build perl at dc6dfd62197489a4c671a17a43d8555551b5446c^ > and dc6dfd62197489a4c671a17a43d8555551b5446c and ran the test program, > I got the same -- "good" -- results both times: > > ##### > my($w, $x, $y, $z) = ('') x 4; > if (not $w) { > $x; > } > elsif ($y) { > $z; > } > /home/jkeenan/learn/perl/unless.pl syntax OK > ##### > > So I haven't yet been able to identify the commit where the problem > first appeared. > > Thank you very much.
It doesn't necessarily have to be a B::Deparse change that did it... it could be changes in the code tree generation (or whatever it's called) and/or the optimizer.
Date: Mon, 13 Mar 2017 09:47:28 +0000
CC: perl5-porters [...] perl.org
To: Curtis Jewell via RT <perlbug-comment [...] perl.org>
Subject: Re: [perl #130981] Confusing B::Deparse output with unless/elsif
From: Dave Mitchell <davem [...] iabyn.com>
Download (untitled) / with headers
text/plain 741b
On Sat, Mar 11, 2017 at 01:30:35PM -0800, Curtis Jewell via RT wrote: Show quoted text
> It doesn't necessarily have to be a B::Deparse change that did it... it > could be changes in the code tree generation (or whatever it's called) > and/or the optimizer.
It bisects to this: commit 08b3e84fbb1c493d7157c2ad8d1dec4242c965cc Author: Tony Cook <tony@develop-help.com> Date: Mon Jan 4 10:17:22 2016 +1100 [perl #127122] warn on unless (assignment) when syntax warnings are on Previously the assignment was hidden by the not op wrapped around the condition, but newCONDOP() is sufficiently flexible that it isn't needed. -- Red sky at night - gerroff my land! Red sky at morning - gerroff my land! -- old farmers' sayings #14
CC: perl5-porters [...] perl.org
Date: Mon, 13 Mar 2017 11:58:33 +0000
To: Curtis Jewell via RT <perlbug-comment [...] perl.org>
From: Dave Mitchell <davem [...] iabyn.com>
Subject: Re: [perl #130981] Confusing B::Deparse output with unless/elsif
Download (untitled) / with headers
text/plain 1.1k
On Mon, Mar 13, 2017 at 09:47:28AM +0000, Dave Mitchell wrote: Show quoted text
> On Sat, Mar 11, 2017 at 01:30:35PM -0800, Curtis Jewell via RT wrote:
> > It doesn't necessarily have to be a B::Deparse change that did it... it > > could be changes in the code tree generation (or whatever it's called) > > and/or the optimizer.
> > It bisects to this: > > commit 08b3e84fbb1c493d7157c2ad8d1dec4242c965cc > Author: Tony Cook <tony@develop-help.com> > Date: Mon Jan 4 10:17:22 2016 +1100 > > [perl #127122] warn on unless (assignment) when syntax warnings are on > > Previously the assignment was hidden by the not op wrapped around the > condition, but newCONDOP() is sufficiently flexible that it isn't > needed.
... which triggers an optimisation that causes the 'if' and 'else' children of the condexpr op to be swapped and a 'not' op eliminated. This is confuses the "is it an if/else or a ?:" heuristics in Deparse.pm and it guesses wrong. Going forward, I think it would be better to set private flags in and/or/condexpr ops to indicate that this was compiled via an 'if/else' rather than getting Deparse to guess. -- No matter how many dust sheets you use, you will get paint on the carpet.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 831b
On Mon, 13 Mar 2017 09:48:03 GMT, davem wrote: Show quoted text
> On Sat, Mar 11, 2017 at 01:30:35PM -0800, Curtis Jewell via RT wrote:
> > It doesn't necessarily have to be a B::Deparse change that did it... it > > could be changes in the code tree generation (or whatever it's called) > > and/or the optimizer.
> > It bisects to this: > > commit 08b3e84fbb1c493d7157c2ad8d1dec4242c965cc > Author: Tony Cook <tony@develop-help.com> > Date: Mon Jan 4 10:17:22 2016 +1100 > > [perl #127122] warn on unless (assignment) when syntax warnings are on > > Previously the assignment was hidden by the not op wrapped around the > condition, but newCONDOP() is sufficiently flexible that it isn't > needed. > >
Could you share the bisection approach you took to this? Thank you very much. -- James E Keenan (jkeenan@cpan.org)
CC: perl5-porters [...] perl.org
Date: Mon, 20 Mar 2017 08:36:35 +0000
Subject: Re: [perl #130981] Confusing B::Deparse output with unless/elsif
From: Dave Mitchell <davem [...] iabyn.com>
To: James E Keenan via RT <perlbug-followup [...] perl.org>
Download (untitled) / with headers
text/plain 1.2k
On Tue, Mar 14, 2017 at 05:38:28AM -0700, James E Keenan via RT wrote: Show quoted text
> On Mon, 13 Mar 2017 09:48:03 GMT, davem wrote:
> > On Sat, Mar 11, 2017 at 01:30:35PM -0800, Curtis Jewell via RT wrote:
> > > It doesn't necessarily have to be a B::Deparse change that did it... it > > > could be changes in the code tree generation (or whatever it's called) > > > and/or the optimizer.
> > > > It bisects to this: > > > > commit 08b3e84fbb1c493d7157c2ad8d1dec4242c965cc > > Author: Tony Cook <tony@develop-help.com> > > Date: Mon Jan 4 10:17:22 2016 +1100 > > > > [perl #127122] warn on unless (assignment) when syntax warnings are on > > > > Previously the assignment was hidden by the not op wrapped around the > > condition, but newCONDOP() is sufficiently flexible that it isn't > > needed. > > > >
> > Could you share the bisection approach you took to this?
Sorry, I didn't spot your email till a week later, so I can't remember exactly. But I probably created a shell script, /tmp/s say, containing: #!/bin/sh $@ -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' 2>&1 | grep -q not which does: $ /tmp/s perl5220; echo $? 0 $ /tmp/s perl5240; echo $? 1 Then ran $ Porting/bisect.pl .... -- /tmp/s ./perl -Ilib -- A problem shared is a problem doubled.
To: perl5-porters [...] perl.org
From: James E Keenan <jkeen [...] verizon.net>
Subject: Re: [perl #130981] Confusing B::Deparse output with unless/elsif
Date: Mon, 20 Mar 2017 11:29:57 -0400
Download (untitled) / with headers
text/plain 1.4k
On 03/20/2017 04:36 AM, Dave Mitchell wrote: Show quoted text
> On Tue, Mar 14, 2017 at 05:38:28AM -0700, James E Keenan via RT wrote:
>> On Mon, 13 Mar 2017 09:48:03 GMT, davem wrote:
>>> On Sat, Mar 11, 2017 at 01:30:35PM -0800, Curtis Jewell via RT wrote:
>>>> It doesn't necessarily have to be a B::Deparse change that did it... it >>>> could be changes in the code tree generation (or whatever it's called) >>>> and/or the optimizer.
>>> >>> It bisects to this: >>> >>> commit 08b3e84fbb1c493d7157c2ad8d1dec4242c965cc >>> Author: Tony Cook <tony@develop-help.com> >>> Date: Mon Jan 4 10:17:22 2016 +1100 >>> >>> [perl #127122] warn on unless (assignment) when syntax warnings are on >>> >>> Previously the assignment was hidden by the not op wrapped around the >>> condition, but newCONDOP() is sufficiently flexible that it isn't >>> needed. >>> >>>
>> >> Could you share the bisection approach you took to this?
> > Sorry, I didn't spot your email till a week later, so I can't remember > exactly. But I probably created a shell script, /tmp/s say, containing: > > #!/bin/sh > $@ -MO=Deparse -e 'unless ($a) { $b } elsif($c) { $d }' 2>&1 | grep -q not > > which does: > > $ /tmp/s perl5220; echo $? > 0 > $ /tmp/s perl5240; echo $? > 1 > > Then ran > > $ Porting/bisect.pl .... -- /tmp/s ./perl -Ilib > > >
Thanks. I ran: perl Porting/bisect.pl --start=v5.23.7 --end=v5.23.8 -- /tmp/s ./perl -Ilib ... and got the same results as you did.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org