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

bizarre behavior with sort and CORE::fake #14323

Closed
p5pRT opened this issue Dec 11, 2014 · 10 comments
Closed

bizarre behavior with sort and CORE::fake #14323

p5pRT opened this issue Dec 11, 2014 · 10 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 11, 2014

Migrated from rt.perl.org#123410 (status was 'resolved')

Searchable as RT123410$

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2014

From @rjbs

Created by @rjbs

  ~$ perl -MO=Deparse -E'sort CORE​::abc_def("*")'
  use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
  sort CORE​::a '*';
  -e syntax OK

  ~$ perl -MO=Deparse -E'sort CORE​::abc_def_ghi("*")'
  use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
  sort CORE​::abc_d '*';
  -e syntax OK

Woah.

  11​:51 <ilmari> it's chopping length("CORE​::") off the wrong end?
  11​:51 <rjbs> ilmari​: !!

This isn't just Deparse.

  ~$ perl -E'use Data​::Dumper; warn Dumper [sort CORE​::abc_def("*")]'
  Undefined sort subroutine "CORE​::a" called at -e line 1.
  ~$ perl -E'use Data​::Dumper; warn Dumper [sort CORE​::abc_def_ghi("*")]'
  Undefined sort subroutine "CORE​::abc_d" called at -e line 1.

Bug appears in v5.20, not in v5.18.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl 5.21.5:

Configured by rjbs at Mon Oct 20 13:54:04 EDT 2014.

Summary of my perl5 (revision 5 version 21 subversion 5) configuration:
   
  Platform:
    osname=darwin, osvers=14.0.0, archname=darwin-2level
    uname='darwin walrus.local 14.0.0 darwin kernel version 14.0.0: fri sep 19 00:26:44 pdt 2014; root:xnu-2782.1.97~2release_x86_64 x86_64 '
    config_args='-Dprefix=/Users/rjbs/.plenv/versions/21.5 -de -Dusedevel -A'eval:scriptdir=/Users/rjbs/.plenv/versions/21.5/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 ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include',
    optimize='-O3',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -I/opt/local/include'
    ccversion='', gccversion='4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /usr/lib /opt/local/lib
    libs=-lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector'



@INC for perl 5.21.5:
    /Users/rjbs/.plenv/versions/21.5/lib/perl5/site_perl/5.21.5/darwin-2level
    /Users/rjbs/.plenv/versions/21.5/lib/perl5/site_perl/5.21.5
    /Users/rjbs/.plenv/versions/21.5/lib/perl5/5.21.5/darwin-2level
    /Users/rjbs/.plenv/versions/21.5/lib/perl5/5.21.5
    .


Environment for perl 5.21.5:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/rjbs
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/rjbs/.plenv/versions/21.5/bin:/Users/rjbs/.plenv/libexec:/Users/rjbs/.plenv/plugins/perl-build/bin:/Users/rjbs/bin:/Users/rjbs/.rbenv/shims:/Users/rjbs/.rbenv/bin:/Users/rjbs/.plenv/shims:/Users/rjbs/.plenv/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/rjbs/code/hla
    PERL_AUTOINSTALL=--skipdeps
    PERL_BADLANG (unset)
    PERL_MAILERS=sendmail:/Users/rjbs/bin/sendmail
    SHELL=/opt/local/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2014

From @wolfsage

On Thu, Dec 11, 2014 at 11​:55 AM, Ricardo SIGNES
<perlbug-followup@​perl.org> wrote​:

~$ perl -MO=Deparse -E'sort CORE​::abc_def("*")'
use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
sort CORE​::a '*';
-e syntax OK

~$ perl -MO=Deparse -E'sort CORE​::abc_def_ghi("*")'
use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch', 'unicode_strings', 'unicode_eval';
sort CORE​::abc_d '*';
-e syntax OK

Looks like this broke between 5.19.0 and 5.19.1​:

  /home/mhorsfall/dpppperls/default/perl-5.19.0/bin/perl5.19.0
-MO=Deparse '-E[sort CORE​::abc_def("*")]' 2>&1
  -e syntax OK
  [(sort CORE​::abc_def '*')];
  /home/mhorsfall/dpppperls/default/perl-5.19.1/bin/perl5.19.1
-MO=Deparse '-E[sort CORE​::abc_def("*")]' 2>&1
  -e syntax OK
  [(sort CORE​::a '*')];

  /home/mhorsfall/dpppperls/default/perl-5.19.0/bin/perl5.19.0 '-Euse
File​::Glob bsd_glob; use Data​::Dumper; warn Dumper [sort
CORE​::bsd_glob("*")]' 2>&1
  Undefined sort subroutine "CORE​::bsd_glob" called at -e line 1.
  child exited with value 255
  /home/mhorsfall/dpppperls/default/perl-5.19.1/bin/perl5.19.1 '-Euse
File​::Glob bsd_glob; use Data​::Dumper; warn Dumper [sort
CORE​::bsd_glob("*")]' 2>&1
  Undefined sort subroutine "CORE​::bs" called at -e line 1.
  child exited with value 255

-- Matthew Horsfall (alh)

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Dec 11, 2014

From @rjbs

* "Matthew Horsfall (alh)" <wolfsage@​gmail.com> [2014-12-11T12​:00​:01]

Looks like this broke between 5.19.0 and 5.19.1​:

Unsurprisingly, it bisects to 01b5ef5

  commit 01b5ef5
  Author​: Father Chrysostomos <sprout@​cpan.org>
  Date​: Fri Jun 7 20​:16​:23 2013 -0700

  [perl #24482] Fix sort and require to treat CORE​:: as keyword

Looks like the code assumes that CORE​::... is never bogus?

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2014

From @cpansprout

On Thu Dec 11 10​:45​:12 2014, perl.p5p@​rjbs.manxome.org wrote​:

* "Matthew Horsfall (alh)" <wolfsage@​gmail.com> [2014-12-11T12​:00​:01]

Looks like this broke between 5.19.0 and 5.19.1​:

Unsurprisingly, it bisects to 01b5ef5

commit 01b5ef5
Author​: Father Chrysostomos <sprout@​cpan.org>
Date​: Fri Jun 7 20​:16​:23 2013 -0700

  \[perl \#24482\] Fix sort and require to treat CORE&#8203;:: as keyword

Looks like the code assumes that CORE​::... is never bogus?

It adjusts the length by subtracting 6 (length("CORE​::")) but does not set it back if it does not find a keyword.

$ ./perl -Ilib -le 'sub C { $b <=> $a } print for sort CORE​::f 1..10'
10
9
8
7
6
5
4
3
2
1

How do we want this to behave? Normally require and sort treat a word as a bareword (and not a sub call) unless it is a keyword. It’s just that before 01b5ef5 CORE​::lc was not treated as a keyword.

If we have CORE​::elsewhat should we revert to the previous behaviour of treating it as a bareword (a sub name)? Or should we explicitly forbid it the way we do with CORE​::elsewhat elsewhere?

Either way it’s going to croak, and the former is easier. (Also, I have my doubts as to whether croaking for CORE​::thing in general is a wise decision, especially if core keywords are just special subroutines.)

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2014

From @cpansprout

On Thu Dec 11 17​:55​:48 2014, sprout wrote​:

On Thu Dec 11 10​:45​:12 2014, perl.p5p@​rjbs.manxome.org wrote​:

* "Matthew Horsfall (alh)" <wolfsage@​gmail.com> [2014-12-11T12​:00​:01]

Looks like this broke between 5.19.0 and 5.19.1​:

Unsurprisingly, it bisects to
01b5ef5

commit 01b5ef5
Author​: Father Chrysostomos <sprout@​cpan.org>
Date​: Fri Jun 7 20​:16​:23 2013 -0700

[perl #24482] Fix sort and require to treat CORE​:: as keyword

Looks like the code assumes that CORE​::... is never bogus?

It adjusts the length by subtracting 6 (length("CORE​::")) but does not
set it back if it does not find a keyword.

$ ./perl -Ilib -le 'sub C { $b <=> $a } print for sort CORE​::f 1..10'
10
9
8
7
6
5
4
3
2
1

How do we want this to behave? Normally require and sort treat a word
as a bareword (and not a sub call) unless it is a keyword. It’s just
that before 01b5ef5 CORE​::lc was not treated as a keyword.

If we have CORE​::elsewhat should we revert to the previous behaviour
of treating it as a bareword (a sub name)? Or should we explicitly
forbid it the way we do with CORE​::elsewhat elsewhere?

Either way it’s going to croak, and the former is easier. (Also, I
have my doubts as to whether croaking for CORE​::thing in general is a
wise decision, especially if core keywords are just special
subroutines.)

I went with the former in 487e470.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2014

@cpansprout - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2014

From @rjbs

* Father Chrysostomos via RT <perlbug-followup@​perl.org> [2014-12-12T01​:29​:13]

I went with the former in 487e470.

+1

--
rjbs

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2015

From @khwilliamson

Thanks for submitting this ticket

The issue should be resolved with the release today of Perl v5.22, available at http​://www.perl.org/get.html
If you find that the problem persists, feel free to reopen this ticket

--
Karl Williamson for the Perl 5 porters team

@p5pRT p5pRT closed this as completed Jun 2, 2015
@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2015

@khwilliamson - Status changed from 'pending release' to 'resolved'

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

1 participant