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

disabling bareword filehandles erroneously forbids package method calls #19704

Closed
ilmari opened this issue May 10, 2022 · 6 comments · Fixed by #19832
Closed

disabling bareword filehandles erroneously forbids package method calls #19704

ilmari opened this issue May 10, 2022 · 6 comments · Fixed by #19832

Comments

@ilmari
Copy link
Member

ilmari commented May 10, 2022

Description

When the bareworld_filehandles feature is disabled (e.g. under use v5.35;), package method calls are also forbidden where a bareword filehandle would be.

Steps to Reproduce

$ perl -le 'no feature "bareword_filehandles"; sub foo { "foo" } print main->foo'
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at -e line 1.
Execution of -e aborted due to compilation errors.

It seems to be interpreting the bareword const op under the entersub as a bareword filehandle, even though that's actually the argument to method_named:

$ perl -MO=Concise -e 'no feature "bareword_filehandles"; sub foo { "foo" } print main->foo'
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at -e line 1.
-e had compilation errors.
9  <@> leave[1 ref] KP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 4 -e:1) :us,*,&,{,$,fea=6 ->3
8     <@> print K ->9
3        <0> pushmark ->4
7        <1> entersub[t1] KRS/TARG,STRICT ->8
4           <0> pushmark ->5
5           <$> const(PV "main") s/BARE ->6
6           <.> method_named(PV "foo") ->7

Expected behavior

Same as with the feature enabled:

$ perl -le 'sub foo { "foo" } print main->foo'
foo

Perl configuration

Summary of my perl5 (revision 5 version 35 subversion 10) configuration:
   
  Platform:
    osname=linux
    osvers=5.10.0-12-amd64
    archname=x86_64-linux
    uname='linux ilmari-thinkpad 5.10.0-12-amd64 #1 smp debian 5.10.103-1 (2022-03-07) x86_64 gnulinux '
    config_args='-de -Dprefix=/home/ilmari/perl5/perlbrew/perls/35.10 -Duseshrplib -Dman1dir=none -Dman3dir=none -Dusedevel -Aeval:scriptdir=/home/ilmari/perl5/perlbrew/perls/35.10/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
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='10.2.1 20210110'
    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/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib
    libs=-lpthread -lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.31.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.31'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/home/ilmari/perl5/perlbrew/perls/35.10/lib/5.35.10/x86_64-linux/CORE'
    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
    PERL_USE_DEVEL
    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
  Built under linux
  Compiled at Mar 24 2022 20:23:54
  %ENV:
    PERL5LIB="/home/ilmari/.perlbrew/libs/35.10@std/lib/perl5"
    PERLBREW_HOME="/home/ilmari/.perlbrew"
    PERLBREW_LIB="std"
    PERLBREW_MANPATH="/home/ilmari/.perlbrew/libs/35.10@std/man:/home/ilmari/perl5/perlbrew/perls/35.10/man"
    PERLBREW_PATH="/home/ilmari/.perlbrew/libs/35.10@std/bin:/home/ilmari/perl5/perlbrew/bin:/home/ilmari/perl5/perlbrew/perls/35.10/bin"
    PERLBREW_PERL="35.10"
    PERLBREW_ROOT="/home/ilmari/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.82"
    PERLBREW_VERSION="0.91"
    PERL_LOCAL_LIB_ROOT="/home/ilmari/.perlbrew/libs/35.10@std"
    PERL_MB_OPT="--install_base /home/ilmari/.perlbrew/libs/35.10@std"
    PERL_MM_OPT="INSTALL_BASE=/home/ilmari/.perlbrew/libs/35.10@std"
  @INC:
    /home/ilmari/.perlbrew/libs/35.10@std/lib/perl5/x86_64-linux
    /home/ilmari/.perlbrew/libs/35.10@std/lib/perl5
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/site_perl/5.35.10/x86_64-linux
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/site_perl/5.35.10
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/5.35.10/x86_64-linux
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/5.35.10
@ilmari
Copy link
Member Author

ilmari commented May 10, 2022

Here are some tests that demonstrate the issue:

diff --git a/t/lib/feature/bareword_filehandles b/t/lib/feature/bareword_filehandles
index a3604770d4..fba6a59927 100644
--- a/t/lib/feature/bareword_filehandles
+++ b/t/lib/feature/bareword_filehandles
@@ -496,3 +496,15 @@ say foo;
 -x foo();
 -x foo;
 EXPECT
+########
+# NAME method calls
+use feature "say";
+no feature "bareword_filehandles";
+sub foo {}
+print main->foo();
+print main->foo;
+say main->foo();
+say main->foo;
+-x main->foo();
+-x main->foo;
+EXPECT

Result:

ilmari@ilmari-thinkpad:~/src/perl/t (blead *$%)$ ./TEST ../lib/feature.t 
t/../lib/feature ... FILE: lib/feature/bareword_filehandles ; line 500
PROG: 
use feature "say";
no feature "bareword_filehandles";
sub foo { "" }
print main->foo();
print main->foo;
say main->foo();
say main->foo;
-x main->foo();
-x main->foo;
EXPECTED:

GOT:
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at - line 4.
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at - line 5.
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at - line 6.
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at - line 7.
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at - line 8.
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at - line 9.
Execution of - aborted due to compilation errors.
# Failed test 26 - method calls at lib/feature/bareword_filehandles line 500
#
# Note: 'run_multiple_progs' run has one or more failures
#        you can consider setting the environment variable
#        PERL_TEST_ABORT_FIRST_FAILURE=1 before running the test
#        to stop on the first error.
#
FAILED at test 26
Failed 1 test out of 1, 0.00% okay.
	../lib/feature.t

@ilmari
Copy link
Member Author

ilmari commented May 10, 2022

@tonycoz any ideas?

@leonerd
Copy link
Contributor

leonerd commented May 10, 2022

#19426 may be related

@rjbs
Copy link
Member

rjbs commented May 10, 2022

Oof. We should turn bareword filehandles back on in the bundle for sure, right? I can't see why we wouldn't, at this point.

@leonerd
Copy link
Contributor

leonerd commented May 10, 2022

Even if a bugfix turned up right now and was trivial and obviously-correct, I think we'd still feel rather nervous about deploying it directly for an RC1. It feels like this feature hasn't really had enough stress-testing yet, if this much of a showstopper turns up quite this late.

I agree with @rjbs - we should back it out and reënable it in the prevailing feature bundle.

@leonerd
Copy link
Contributor

leonerd commented May 11, 2022

I've begun a PR here - #19705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants