Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chained comparison operators sometimes fail at 5.32 debugger prompt #17917

Closed
lindleyw opened this issue Jun 30, 2020 · 2 comments
Closed

Chained comparison operators sometimes fail at 5.32 debugger prompt #17917

lindleyw opened this issue Jun 30, 2020 · 2 comments

Comments

@lindleyw
Copy link

lindleyw commented Jun 30, 2020

Description
At the debugger prompt, syntax with chained comparison operators is incorrectly parsed in some cases when constants are used.

Steps to Reproduce

  DB<1> x ( 1 < 2 < 3 )                                                         
0  2
1  1
  DB<2> @ex = ( 7 < 8 < 9 )                                                     

  DB<3> x @ex                                                                   
0  8
1  1
  DB<4> $rr = 8
  DB<5> x ( 7 < $rr > 9 )                                                      
0  8
1  ''
  DB<6> x ( $rr < 8.5 < $rr+1 )                                                
0  1
  DB<7> x ( $rr < 8.5 < 9 )                                                    
0  8.5
1  1
  DB<8> x ( 9 > $rr > 7 )                                                       
0  8
1  ''
  DB<9> x ( 9 >= $rr >= $rr-2 )                                                 
0  1
  DB<10>

Expected behavior
Perl source files with this new syntax are processed as expected, and should work the same at the debugger prompt.

Perl configuration

$ perl -V
Summary of my perl5 (revision 5 version 32 subversion 0) configuration:
   
  Platform:
    osname=linux
    osvers=5.4.0-37-generic
    archname=x86_64-linux
    uname='linux shinybox 5.4.0-37-generic #41~18.04.1-ubuntu smp mon jun 8 13:37:29 utc 2020 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/wlindley/perl5/perlbrew/perls/perl-5.32.0 -Aeval:scriptdir=/home/wlindley/perl5/perlbrew/perls/perl-5.32.0/bin'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='7.5.0'
    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-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/7/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 -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.27.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.27'
  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-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Locally applied patches:
    Devel::PatchPerl 1.38
  Built under linux
  Compiled at Jun 21 2020 07:27:05
  %ENV:
    PERLBREW_HOME="/home/wlindley/.perlbrew"
    PERLBREW_MANPATH="/home/wlindley/perl5/perlbrew/perls/perl-5.32.0/man"
    PERLBREW_PATH="/home/wlindley/perl5/perlbrew/bin:/home/wlindley/perl5/perlbrew/perls/perl-5.32.0/bin"
    PERLBREW_PERL="perl-5.32.0"
    PERLBREW_ROOT="/home/wlindley/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.84"
    PERLBREW_VERSION="0.84"
  @INC:
    /home/wlindley/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0/x86_64-linux
    /home/wlindley/perl5/perlbrew/perls/perl-5.32.0/lib/site_perl/5.32.0
    /home/wlindley/perl5/perlbrew/perls/perl-5.32.0/lib/5.32.0/x86_64-linux
    /home/wlindley/perl5/perlbrew/perls/perl-5.32.0/lib/5.32.0
@choroba
Copy link
Contributor

choroba commented Jul 4, 2020

It seems it happens in eval, too:

#! /usr/bin/perl
use warnings;
use strict;

my %tests = ('5.032' => '1 < 2 < 3');

for my $version (keys %tests) {
    my $expression = $tests{$version};
    my $value = eval $expression;
    $value or die "Expected 1, got $value.";
}

Output:

Expected 1, got . at /home/choroba/1.pl line 10.

Interestingly, when using

my @v = keys %tests;
for my $version (@v) {

it passes. Something wrong with the stack?

@tonycoz
Copy link
Contributor

tonycoz commented Dec 23, 2020

fixed by 08be3ef

@tonycoz tonycoz closed this as completed Dec 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants