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

do file: Add './' in additional cases #15934

Closed
p5pRT opened this issue Mar 27, 2017 · 16 comments
Closed

do file: Add './' in additional cases #15934

p5pRT opened this issue Mar 27, 2017 · 16 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 27, 2017

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

Searchable as RT131069$

@p5pRT
Copy link
Author

p5pRT commented Mar 27, 2017

From @jkeenan

Created by jkeenan@zareason.(none)

  From #p5p​: Mon Mar 27 2017​:

(05​:21​:57 PM) khw​: On some platforms, I'm getting
(05​:21​:59 PM) khw​: do "lib/locale/latin1" failed, '.' is no longer in
@​INC at ./loc_tools.pl line 347.
(05​:22​:00 PM) khw​: I haven't been following all that closely the dot
@​INC issues.
(05​:22​:02 PM) khw​: I presume the solution is to add an explicit "./",
and I presume that it should be added in the freeze
(05​:22​:03 PM) khw​: No tests fail as a result of this, but it causes some
tests that should have been done to be skipped.
(05​:24​:34 PM) leont_​: Good catch
(05​:37​:51 PM) khw​: Somebody should have done an audit of the
distribution, as I see this elsewhere as well.

I ack-ed for 'do ' under t and came up with these likely additional cases.
Please review carefully; some of these revisions may not really be needed.

Perl Info

Flags:
      category=core
      severity=low

Site configuration information for perl 5.24.1:

Configured by jkeenan at Sat Jan 14 20:56:26 EST 2017.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration:

    Platform:
      osname=linux, osvers=4.4.0-59-generic, archname=x86_64-linux
      uname='linux zareason 4.4.0-59-generic #80-ubuntu smp fri jan 6 
17:47:47 utc 2017 x86_64 x86_64 x86_64 gnulinux '
      config_args='-de 
-Dprefix=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.1 
-Aeval:scriptdir=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/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-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='5.4.0 20160609', 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/5/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 /lib64 /usr/lib64
      libs=-lpthread -lnsl -ldb -ldl -lm -lcrypt -lutil -lc
      perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
      libc=libc-2.23.so, so=so, useshrplib=false, libperl=libperl.a
      gnulibc_version='2.23'
    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'



@INC for perl 5.24.1:
 
/home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1/x86_64-linux
      /home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/lib/site_perl/5.24.1
      /home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/lib/5.24.1/x86_64-linux
      /home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/lib/5.24.1


Environment for perl 5.24.1:
      HOME=/home/jkeenan
      LANG=en_US.UTF-8
      LANGUAGE=en_US
      LD_LIBRARY_PATH (unset)
      LOGDIR (unset)
 
PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/bin:/usr/lib/ccache:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/jkeenan/bin:/home/jkeenan/bin/perl:/home/jkeenan/bin/shell
      PERLBREW_BASHRC_VERSION=0.78
      PERLBREW_HOME=/home/jkeenan/.perlbrew
      PERLBREW_MANPATH=/home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/man
 
PERLBREW_PATH=/home/jkeenan/perl5/perlbrew/bin:/home/jkeenan/perl5/perlbrew/perls/perl-5.24.1/bin
      PERLBREW_PERL=perl-5.24.1
      PERLBREW_ROOT=/home/jkeenan/perl5/perlbrew
      PERLBREW_VERSION=0.78
      PERL_BADLANG (unset)
      PERL_WORKDIR=/home/jkeenan/gitwork/perl
      SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Mar 27, 2017

From @jkeenan

0001-Additional-cases-where-do-file-should-be-do-.-file.patch
>From c9c64ceb4aea28b1a9ea252cd60d38ef2bd7098c Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 27 Mar 2017 19:31:34 -0400
Subject: [PATCH] Additional cases where 'do file' should be 'do ./file'.

---
 t/comp/require.t | 4 ++--
 t/loc_tools.pl   | 4 ++--
 t/op/threads.t   | 2 +-
 t/run/dtrace.t   | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/t/comp/require.t b/t/comp/require.t
index c4889bb..e6fadd5 100644
--- a/t/comp/require.t
+++ b/t/comp/require.t
@@ -182,9 +182,9 @@ my $x = "ok $i - bleah.do\n";
 write_file("bleah.do", <<EOT);
 \$x = "not ok $i - bleah.do\\n";
 EOT
-do "bleah.do" or die $@;
+do "./bleah.do" or die $@;
 dofile();
-sub dofile { do "bleah.do" or die $@; };
+sub dofile { do "./bleah.do" or die $@; };
 print $x;
 
 # Test that scalar context is forced for require
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index 4b99c45..ed24c37 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -342,9 +342,9 @@ sub find_locales ($;$) {
         # Locales whose name differs if the utf8 bit is on are stored in these two
         # files with appropriate encodings.
         if ($^H & 0x08 || (${^OPEN} || "") =~ /:utf8/) {
-            @Data = do "lib/locale/utf8";
+            @Data = do "./lib/locale/utf8";
         } else {
-            @Data = do "lib/locale/latin1";
+            @Data = do "./lib/locale/latin1";
         }
 
         # The rest of the locales are in this file.
diff --git a/t/op/threads.t b/t/op/threads.t
index a2dbdca..39f3968 100644
--- a/t/op/threads.t
+++ b/t/op/threads.t
@@ -105,7 +105,7 @@ EOI
 # http://www.nntp.perl.org/group/perl.perl5.porters/63123
 fresh_perl_is(<<'EOI', 'ok', { }, 'Ensure PL_linestr can be cloned');
 use threads;
-print do 'op/threads_create.pl' || die $@;
+print do './op/threads_create.pl' || die $@;
 EOI
 
 
diff --git a/t/run/dtrace.t b/t/run/dtrace.t
index 2140973..b66736f 100644
--- a/t/run/dtrace.t
+++ b/t/run/dtrace.t
@@ -136,7 +136,7 @@ dtrace_like(<< 'PERL_SCRIPT',
     BEGIN {@INC = '../lib'}
     use strict;
     require HTTP::Tiny;
-    do "run/dtrace.pl";
+    do "./run/dtrace.pl";
 PERL_SCRIPT
     << 'D_SCRIPT',
     loading-file { printf("loading-file <%s>\n", copyinstr(arg0)) }
-- 
2.7.4


@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

From @khwilliamson

On 03/27/2017 05​:39 PM, James E Keenan (via RT) wrote​:

# New Ticket Created by James E Keenan
# Please include the string​: [perl #131069]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=131069 >

This is a bug report for perl from jkeenan@​zareason.(none),
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
[Please describe your issue here]

From #p5p​: Mon Mar 27 2017​:

(05​:21​:57 PM) khw​: On some platforms, I'm getting
(05​:21​:59 PM) khw​: do "lib/locale/latin1" failed, '.' is no longer in
@​INC at ./loc_tools.pl line 347.
(05​:22​:00 PM) khw​: I haven't been following all that closely the dot
@​INC issues.
(05​:22​:02 PM) khw​: I presume the solution is to add an explicit "./",
and I presume that it should be added in the freeze
(05​:22​:03 PM) khw​: No tests fail as a result of this, but it causes some
tests that should have been done to be skipped.
(05​:24​:34 PM) leont_​: Good catch
(05​:37​:51 PM) khw​: Somebody should have done an audit of the
distribution, as I see this elsewhere as well.

I ack-ed for 'do ' under t and came up with these likely additional cases.
Please review carefully; some of these revisions may not really be needed.

Here's a more complete list from a more general ack. I included 'do
$foo', because without checking $foo, we don't know what it contains.
But I believe that going through this list would catch nearly all
possible ones.

This is updated from the one in
http​://nntp.perl.org/group/perl.perl5.porters/243746

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

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

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

From @khwilliamson

On 03/27/2017 08​:02 PM, Karl Williamson wrote​:

On 03/27/2017 05​:39 PM, James E Keenan (via RT) wrote​:

# New Ticket Created by James E Keenan
# Please include the string​: [perl #131069]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=131069 >

This is a bug report for perl from jkeenan@​zareason.(none),
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
[Please describe your issue here]

From #p5p​: Mon Mar 27 2017​:

(05​:21​:57 PM) khw​: On some platforms, I'm getting
(05​:21​:59 PM) khw​: do "lib/locale/latin1" failed, '.' is no longer in
@​INC at ./loc_tools.pl line 347.
(05​:22​:00 PM) khw​: I haven't been following all that closely the dot
@​INC issues.
(05​:22​:02 PM) khw​: I presume the solution is to add an explicit "./",
and I presume that it should be added in the freeze
(05​:22​:03 PM) khw​: No tests fail as a result of this, but it causes some
tests that should have been done to be skipped.
(05​:24​:34 PM) leont_​: Good catch
(05​:37​:51 PM) khw​: Somebody should have done an audit of the
distribution, as I see this elsewhere as well.

I ack-ed for 'do ' under t and came up with these likely additional
cases.
Please review carefully; some of these revisions may not really be
needed.

Here's a more complete list from a more general ack. I included 'do
$foo', because without checking $foo, we don't know what it contains.
But I believe that going through this list would catch nearly all
possible ones.

This is updated from the one in
http​://nntp.perl.org/group/perl.perl5.porters/243746

Now attached

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

From @khwilliamson

do.log

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

From @jkeenan

On Tue, 28 Mar 2017 02​:13​:45 GMT, public@​khwilliamson.com wrote​:

Here's a more complete list from a more general ack. I included 'do
$foo', because without checking $foo, we don't know what it contains.
But I believe that going through this list would catch nearly all
possible ones.

This is updated from the one in
http​://nntp.perl.org/group/perl.perl5.porters/243746

The do.log appears to have been generated post-build. Hence, it flags some instances in generated files. I tried to look only at source code files.

The pod/perlfunc.pod section on 'do' could use some additional eyeballs.

Entries under 'cpan/' would first need correction upstream (if they need correction at all).

There are some cases where a filename is passed to a subroutine, stored in $file and subsequently used as argument to 'do $file'. It's not clear (to me, at least) whether a correction is needed in such cases. Example​:

#####
vi +450 dist/Safe/Safe.pm
#####
sub rdo {
  my ($obj, $file) = @​_;
  die "Bad Safe object" unless $obj->isa('Safe');

  my $root = $obj->{Root};

  my $sg = sub_generation();
  my $evalsub = eval
  sprintf('package %s; sub { @​_ = (); do $file }', $root);
#####

Additional patch attached. Please review, particularly for false positives.

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Mar 28, 2017

From @jkeenan

0002-2-Additional-cases-where-do-file-should-be-do-.-file.patch
From 5416eef35cea669baca93f1e3a7d40be8d7fe2e7 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Tue, 28 Mar 2017 09:21:44 -0400
Subject: [PATCH 2/2] 2: Additional cases where 'do file' should be 'do
 ./file'.

---
 Porting/bench.pl              | 6 +++---
 dist/Safe/Safe.pm             | 4 ++--
 dist/Time-HiRes/Makefile.PL   | 2 +-
 ext/XS-APItest/t/blockhooks.t | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Porting/bench.pl b/Porting/bench.pl
index 62c6aaf..53e24fc 100755
--- a/Porting/bench.pl
+++ b/Porting/bench.pl
@@ -83,7 +83,7 @@ individual test.
 
 --benchfile=I<foo>
 
-The path of the file which contains the benchmarks (F<t/perf/benchmarks>
+The path of the file which contains the benchmarks (F<./t/perf/benchmarks>
 by default).
 
 =item *
@@ -314,7 +314,7 @@ usage: $0 [options] -- perl[=label] ...
   --action=foo       What action to perform [default: grind].
   --average          Only display average, not individual test results.
   --benchfile=foo    File containing the benchmarks;
-                       [default: t/perf/benchmarks].
+                       [default: ./t/perf/benchmarks].
   --bisect=f,min,max run a single test against one perl and exit with a
                        zero status if the named field is in the specified
                        range; exit 1 otherwise.
@@ -356,7 +356,7 @@ EOF
 my %OPTS = (
     action    => 'grind',
     average   => 0,
-    benchfile => 't/perf/benchmarks',
+    benchfile => './t/perf/benchmarks',
     bisect    => undef,
     compact   => undef,
     debug     => 0,
diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm
index d78fcc5..c5a838f 100644
--- a/dist/Safe/Safe.pm
+++ b/dist/Safe/Safe.pm
@@ -3,7 +3,7 @@ package Safe;
 use 5.003_11;
 use Scalar::Util qw(reftype refaddr);
 
-$Safe::VERSION = "2.39";
+$Safe::VERSION = "2.40";
 
 # *** Don't declare any lexicals above this point ***
 #
@@ -512,7 +512,7 @@ assignment of arguments to @_ on subroutine entry.
 
 Each compartment has an associated "operator mask". Recall that
 perl code is compiled into an internal format before execution.
-Evaluating perl code (e.g. via "eval" or "do 'file'") causes
+Evaluating perl code (e.g. via "eval" or "do '/path/to/file'") causes
 the code to be compiled into an internal format and then,
 provided there was no error in the compilation, executed.
 Code evaluated in a compartment compiles subject to the
diff --git a/dist/Time-HiRes/Makefile.PL b/dist/Time-HiRes/Makefile.PL
index ccad6a3..ca4d4dc 100644
--- a/dist/Time-HiRes/Makefile.PL
+++ b/dist/Time-HiRes/Makefile.PL
@@ -417,7 +417,7 @@ sub DEFINE {
 }
 
 sub init {
-    my $hints = File::Spec->catfile("hints", "$^O.pl");
+    my $hints = File::Spec->catfile(".", "hints", "$^O.pl");
     if (-f $hints) {
 	print "Using hints $hints...\n";
 	local $self;
diff --git a/ext/XS-APItest/t/blockhooks.t b/ext/XS-APItest/t/blockhooks.t
index 37590bc..e409134 100644
--- a/ext/XS-APItest/t/blockhooks.t
+++ b/ext/XS-APItest/t/blockhooks.t
@@ -121,7 +121,7 @@ is_deeply \@bhkav,
 delete @INC{qw{t/Null.pm t/Block.pm}};
 
 t::BHK->import;
-    do "t/Null.pm";
+    do "./t/Null.pm";
 t::BHK->unimport;
 
 is_deeply \@bhkav,
@@ -133,7 +133,7 @@ is_deeply \@bhkav,
     "do file (null)";
 
 t::BHK->import;
-    do "t/Block.pm";
+    do "./t/Block.pm";
 t::BHK->unimport;
 
 is_deeply \@bhkav,
-- 
2.7.4

@p5pRT
Copy link
Author

p5pRT commented Mar 31, 2017

From @jkeenan

On Tue, 28 Mar 2017 14​:10​:31 GMT, jkeenan wrote​:

On Tue, 28 Mar 2017 02​:13​:45 GMT, public@​khwilliamson.com wrote​:

Here's a more complete list from a more general ack. I included
'do
$foo', because without checking $foo, we don't know what it
contains.
But I believe that going through this list would catch nearly all
possible ones.

This is updated from the one in
http​://nntp.perl.org/group/perl.perl5.porters/243746

The do.log appears to have been generated post-build. Hence, it flags
some instances in generated files. I tried to look only at source
code files.

The pod/perlfunc.pod section on 'do' could use some additional
eyeballs.

Entries under 'cpan/' would first need correction upstream (if they
need correction at all).

There are some cases where a filename is passed to a subroutine,
stored in $file and subsequently used as argument to 'do $file'. It's
not clear (to me, at least) whether a correction is needed in such
cases. Example​:

#####
vi +450 dist/Safe/Safe.pm
#####
sub rdo {
my ($obj, $file) = @​_;
die "Bad Safe object" unless $obj->isa('Safe');

my $root = $obj->{Root};

my $sg = sub_generation();
my $evalsub = eval
sprintf('package %s; sub { @​_ = (); do $file }', $root);
#####

Additional patch attached. Please review, particularly for false
positives.

Thank you very much.

Could we get some eyeballs on the two patches I've already submitted for this ticket?

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2017

From @iabyn

On Fri, Mar 31, 2017 at 04​:59​:48AM -0700, James E Keenan via RT wrote​:

Could we get some eyeballs on the two patches I've already submitted for
this ticket?

Here is my complete review of all the 'do' candidates found through the
earlier grepping. It includes some patches of my own in the branch
davem/do_fixups, and I've also individually given agreement/disagreement
to James' fixups.

Unless there's any disagreement, I'll apply my and the relevant parts of
James's fixes in the next day or two.

What follows is divided into these sections​:

  James has a patch which I agree should be applied
  James has a patch which I think need not be applied
  I have a patch (or alternative patch)
  Things which require further discussion
  Nothing needing doing

I'd suggest people read up to at least the 'things which require further
discussion' section.


JAMES HAS A PATCH WHICH I AGREE SHOULD BE APPLIED

  t/loc_tools.pl​:345​: @​Data = do "lib/locale/utf8";
  t/loc_tools.pl​:347​: @​Data = do "lib/locale/latin1";

  The patch for this looks good

  t/run/dtrace.t​:139​: do "run/dtrace.pl";

  The patch for this looks good


JAMES HAS A PATCH WHICH I THINK NEED NOT BE APPLIED

  t/comp/require.t​:182​:write_file("bleah.do", <<EOT);
  t/comp/require.t​:185​:do "bleah.do" or die $@​;
  t/comp/require.t​:187​:sub dofile { do "bleah.do" or die $@​; };

  Changes not needed​: require.t itself adds '.' to @​INC

  t/op/threads.t​:108​:print do 'op/threads_create.pl' || die $@​;

  Adding '.' to the filename isn't needed, as fresh_perl_is() will
  run perl with -I. anyway.

  ext/XS-APItest/t/blockhooks.t​:124​: do "t/Null.pm";
  ext/XS-APItest/t/blockhooks.t​:136​: do "t/Block.pm";

  This test script relies on t/harness to set up an appropriate
  @​INC. These changes on their own don't make any difference.

  dist/Safe/Safe.pm​:515​:Evaluating perl code (e.g. via "eval" or "do 'file'") causes

  This is pod text, describing eval and do in a generic sense;
  it is making no assumption as to whether the file is searched with
  @​INC or not. I suggest leaving the text as-is.


I HAVE A PATCH (OR ALTERNATIVE PATCH)

  regen/regcharclass.pl​:385​: die "do '$1' failed​: $!$@​" if ! do $1 or $@​;
  regen/regcharclass.pl​:477​: die "Can't do 'cp' optree from multi-codepoint strings";

  This script was broken under no '.' in @​INC; presumably the breakage
  wasn't detected because this script is only occasionally run.

  I've fixed the "require 'regen/...'" line.

  The "do $1" line above is never actually triggered currently. If
  someone were to ever make use of this facility, the regen would
  fail unless they entered a suitable pathname. So its safe. The
  second 'do' is just text, so a false positive.

  Porting/bench.pl​:507​: my $ta = do $file;

  The original suggested patch fixed up bench.pl in a way that
  relative paths for --benchfile=file no longer worked. My suggested
  commit instead treats 'file' as a relative path.

  utils/libnetcfg.PL​:346​: %oldcfg = ( %{ do $libnet_cfg_in } );

  I have patched it so that it can find the old config file via
  'do'; however; its not clear to me the current relationship
  (if any) between utils/libnetcfg.PL in perl core and Configure
  in the libnet distribution​: it looks like the latter was
  sucked into core in 2001, and they've been diverging ever
  since. I think the CPAN distribution needs a similar fix.


THINGS WHICH REQUIRE FURTHER DISCUSSION

  cpan/Unicode-Collate/Makefile.PL​:9​: do 'mkheader' or die $@​ || "mkheader​: $!";

  I think it currently works due to​:
  in core​: running under miniperl (which has '.' in @​INC);
  in the wild​: MakeMaker setting PERL_USE_UNSAFE_INC;
  Probably needs fixing by the author in the long term, but not for
  5.26.0.

  cpan/Test-Simple/t/Legacy/subtest/do.t​:13​:subtest $file => sub { do $file };

  Passes now due to t/harness adding '.' to path;
  probably needs fixing by the author in the long term

  cpan/Test-Simple/t/Legacy/Tester/tbt_09do.t​:12​:my $done = do $file;

  Passes now due to t/harness adding '.' to path;
  probably needs fixing by the author in the long term

  cpan/CPAN/lib/CPAN/Distribution.pm​:3451​: my $x = do $buildparams;

  I don't know what this code does, but nothing in the test suite
  triggers it on my system. Probably needs fixing and tests adding.

  ext/DynaLoader/DynaLoader_pm.PL​:376​: eval { do $bs; };

  This bit of code is for loading a non-empty .bs file, which
  doesn't occur within the test suite under linux. I don't know what
  circumstances it *should* occur under, but it probably needs
  fixing and tests adding.
  The .bs file loading was introduced by 8e07c86 in perl-5.001n.

  dist/Safe/Safe.pm​:458​: sprintf('package %s; sub { @​_ = (); do $file }', $root);

  This implements Safe​::rdo() - a restricted version of do(). The
  docs don't specify whether it should behave like do() as regards @​INC
  handling. My gut feeling is that it should, and that therefore the
  docs should be amended to reflect this.

  dist/Unicode-Normalize/Makefile.PL​:11​: do 'mkheader' or die $@​ || "mkheader​: $!";

  As for Unicode-Collate/Makefile.PL above, it probably needs fixing
  in the long term, but not for 5.26.0.

  dist/Time-HiRes/Makefile.PL​:424​: do $hints;

  As for Unicode-Collate/Makefile.PL above, it probably needs fixing
  in the long term, but not for 5.26.0.

  dist/XSLoader/XSLoader_pm.PL​:148​: eval { do $bs; };

  This is a similar issue to DynaLoader (see above).
  The .bs file loading was added by v5.10.0-1245-g73bf755

  win32/ce-helpers/makedist.pl​:240​: do $bs;
  This is a similar issue to DynaLoader (see above).


NOTHING NEEDING DOING

  h2pl/mkvars​:9​: do $include;

  ancient perl3 script. If anyone still uses it
  and it fails, they can always raise a ticket

  t/run/switchC.t​:70​: prog => "do q($scriptfile)",

  runperl adds -I. so this is ok

  t/perf/benchmarks.t​:17​:my $benchmark_array = do $file;

  the test script adds '.' to @​INC first

  t/re/regexp_notrie.t​:11​: do $file or die $@​;
  t/re/regexp_trielist.t​:11​: do $file or die $@​;
  t/re/regex_sets_compat.t​:11​: do $file or die $@​;
  t/re/regexp_qr.t​:6​: do $file or die $@​;
  t/re/regexp_nonull.t​:13​: do $file or die $@​;
  t/re/regexp_qr_embed.t​:7​: do $file or die $@​;
  t/re/regexp_noamp.t​:8​: do $file or die $@​;

  $file always has a ./ prefix

  t/op/inccode.t​:65​:$evalret = eval { do 'Foo2.pl'; 1 };
  t/op/inccode.t​:67​:ok( $evalret, 'do "Foo2.pl"' );
  t/op/inccode.t​:106​:ok( eval { do 'Bar2.pl'; 1 }, 'do "Bar2.pl"' );
  t/op/inccode.t​:193​:$ret ||= do 'abc.pl';
  t/op/inccode.t​:194​:is( $ret, 'abc', 'do "abc.pl" sees return value' );
  t/op/inccode.t​:253​: do "foo";
  t/op/inccode.t​:257​: do "bar";

  This uses coderefs in @​INC, which removes the need for '.' in @​INC

  t/op/require_errors.t​:127​: my $ret = do "strict.pm\0invalid";
  t/op/require_errors.t​:169​:eval { do "" };

  Its looking for strict in lib, not '.'

  t/op/taint.t​:1162​: violates_taint(sub { do $foo }, 'do');

  it dies with a taint failure before it has a chance to (fail to)
  execute the script

  t/op/do.t​:34​:my @​a = do $file17; die $@​ if $@​;
  t/op/do.t​:42​:do $file18; die $@​ if $@​;
  t/op/do.t​:278​: eval "do $mode";

  The script adds '.' to @​INC

  t/op/inccode-tie.t​:11​: do $file; die $@​ if $@​;

  $file has ./ prefix

  t/op/incfilter.t​:30​:do $fh or die;
  t/op/incfilter.t​:93​:do $fh or die;
  t/op/incfilter.t​:112​:do $fh or die;
  t/op/incfilter.t​:289​: do $fh or die;
  t/op/incfilter.t​:296​: do "dah";

  @​INC uses coderefs

  t/comp/line_debug.t​:25​:do "comp/line_debug_0.aux";

  the script adds '.' to @​INC

  lib/_charnames.pm​:243​: if (my @​alias = do $file) {

  This implements the
  use charnames '​:alias' => $file
  feature, which is documented to search @​INC for
  "unicore/$file.pl". So it shouldn't need fixing.
  charnames.t adds ../lib to @​INC, which is where unicore is
  located.

  lib/utf8_heavy.pl​:534​: $list = do $file; die $@​ if $@​;

  This expects to load "unicore/foo.pl" files via @​INC

  lib/B/Deparse.t​:1724​:() = (do 'file') + time;

  The 'do' gets deparsed but not executed.

  lib/B/Deparse-core.t​:246​:testit do => 'do $a;', 'test​::do($a);';

  The 'do' gets deparsed but not executed.

  lib/perl5db.pl​:1271​: do $file;
  lib/perl5db.pl​:1972​: do 'dumpvar.pl' || die $@​ unless defined &main​::dumpvar;
  lib/perl5db.pl​:3496​: do 'dumpvar.pl' || die $@​ unless defined &main​::dumpvar;
  lib/perl5db.pl​:6387​: do 'dumpvar.pl' or die $@​;

  The "do $file" is always called with $file being absolute or ./...
  The dumpvar.pl file is found under lib/.

  win32/ce-helpers/comp.pl​:42​: 'do' => '',
  win32/ce-helpers/comp.pl​:55​:if ($opts{'do'}) {
  win32/bin/search.pl​:205​: $FIND_ONLY=1, next if $arg =~/^-f(ind)?$/;## do "find" only

  False positives in grep

  write_buildcustomize.pl​:101​: do $file and exit;

  This script is designed to be run my miniperl which has '.' in
  @​INC

  cpan/libnet/lib/Net/Config.pm​:81​: $ref = eval { local $SIG{__DIE__}; do $file };
  cpan/libnet/lib/Net/Config.pm​:92​: $ref = eval { local $SIG{__DIE__}; do $file } if -f $file;

  This looks for libnet.cfg using the same pathname prefix that
  Config.pm used - so presumably it will be found with the same @​INC
  that found Net​::Config.

  cpan/Unicode-Collate/Collate/Locale.pm​:101​: my $h = do $path;

  Documented (in code comments) as searching @​INC.

  cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm​:1166​: my $ret = do $hint_file;

  It locally adds '.' to @​INC

  cpan/ExtUtils-MakeMaker/lib/ExtUtils/Mksymlists.pm​:173​: require Config; # a reminder for once we do $^O

  False positive in grep

  cpan/Test-Simple/t/Legacy/Tester/tbt_09do_script.pl​:11​:test_test('test_fail caught fail message inside a do');

  False positive in grep

  cpan/Pod-Perldoc/corpus/perlfunc.pod​:1483​: unless ($return = do $file) {
  cpan/Pod-Perldoc/corpus/perlfunc.pod​:5177​: $result = do $realfilename;

  Just sample pod

  symbian/config.pl​:12​:do "sanity.pl" or die $@​;
  symbian/config.pl​:14​:my %VERSION = %{ do "version.pl" or die $@​ };
  symbian/config.pl​:23​: @​{ do "sdk.pl" or die $@​ };
  symbian/config.pl​:24​:my %PORT = %{ do "port.pl" or die $@​ };
  symbian/config.pl​:54​:my $CWD = do "cwd.pl" or die $@​;
  symbian/makesis.pl​:8​:do "sanity.pl" or die $@​;
  symbian/makesis.pl​:10​:my %VERSION = %{ do "version.pl" or die $@​ };
  symbian/makesis.pl​:15​: @​{ do "sdk.pl" or die $@​ };
  symbian/makesis.pl​:16​:my $UID = do "uid.pl" or die $@​;
  symbian/makesis.pl​:17​:my %PORT = %{ do "port.pl" or die $@​ };
  symbian/xsbuild.pl​:10​:do "sanity.pl" or die $@​;
  symbian/xsbuild.pl​:67​: do "sanity.pl" or die $@​;
  symbian/xsbuild.pl​:68​: my %VERSION = %{ do "version.pl" or die $@​ };
  symbian/xsbuild.pl​:70​: @​{ do "sdk.pl" or die $@​ };
  symbian/xsbuild.pl​:73​: $BUILDROOT = do "cwd.pl" or die $@​;

  these scripts add symbian/ or similar to @​INC

  ext/DynaLoader/Makefile.PL​:43​: do $(PERL) -I$(PERL_ARCHLIB) -I$(PERL_LIB) $(XSUBPP) $(XSUBPPARGS) $$i > /dev/null; \

  False positive​: the 'do' is part of shell script

  ext/Opcode/Opcode.pm​:101​:Evaluating perl code (e.g. via "eval" or "do 'file'") causes

  Just pod

  dist/base/t/base-open-chunk.t​:10​:unless (my $return = do $test_file) {
  dist/base/t/base-open-chunk.t​:12​: warn "couldn't do $test_file​: $!" unless defined $return;
  dist/base/t/base-open-line.t​:8​:unless (my $return = do $test_file) {
  dist/base/t/base-open-line.t​:10​: warn "couldn't do $test_file​: $!" unless defined $return;

  These test scripts run okay from harness which sets up @​INC

  dist/Safe/t/safeops.t​:411​:dofile do 'file'

  The 'do' is expected to die during compilation before being
  executed

  dist/lib/t/01lib.t​:65​: is( eval { do 'Yup.pm' }, 42, 'do() works' );
  dist/lib/t/01lib.t​:80​: ok( !do 'Yup.pm', ' do() effected' );

  This adds entries to @​INC and checks that it can load files there

  dist/SelfLoader/t/03taint.t​:7​:do $file or die "Cannot run $file​: ", $@​||$!;

  It adds '.' to @​INC

  pod/perlrun.pod​:481​: && do "$Config{sitelib}/sitecustomize.pl";

  That's pod

  pod/perlfunc.pod​:1825​: do 'stat.pl';
  pod/perlfunc.pod​:1855​: unless ($return = do $file) {
  pod/perlfunc.pod​:1857​: warn "couldn't do $file​: $!" unless defined $return;

  The man entry for 'do' has already been fixed up.

--
I don't want to achieve immortality through my work...
I want to achieve it through not dying.
  -- Woody Allen

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2017

From @Leont

On Tue, Apr 4, 2017 at 1​:26 PM, Dave Mitchell <davem@​iabyn.com> wrote​:

THINGS WHICH REQUIRE FURTHER DISCUSSION

cpan/Unicode\-Collate/Makefile\.PL&#8203;:9&#8203;:    do 'mkheader' or die $@&#8203; || "mkheader&#8203;: $\!";

    I think it currently works due to&#8203;:
        in core&#8203;: running under miniperl \(which has '\.' in @&#8203;INC\);
        in the wild&#8203;: MakeMaker setting PERL\_USE\_UNSAFE\_INC;
    Probably needs fixing by the author in the long term\, but not for
    5\.26\.0\.
dist/Unicode\-Normalize/Makefile\.PL&#8203;:11&#8203;:    do 'mkheader' or die $@&#8203; || "mkheader&#8203;: $\!";

    As for Unicode\-Collate/Makefile\.PL above\, it probably needs fixing
    in the long term\, but not for 5\.26\.0\.

dist/Time\-HiRes/Makefile\.PL&#8203;:424&#8203;:    do $hints;

    As for Unicode\-Collate/Makefile\.PL above\, it probably needs fixing
    in the long term\, but not for 5\.26\.0\.

MakeMaker doesn't set it, CPAN.pm does. We should fix this on CPAN (as
vendors might not), before 5.26.0 is out, but it doesn't matter if we
don't include it in 5.26.0.

ext/DynaLoader/DynaLoader\_pm\.PL&#8203;:376&#8203;:        eval \{ do $bs; \};

    This bit of code is for loading a non\-empty \.bs file\, which
    doesn't occur within the test suite under linux\. I don't know what
    circumstances it \*should\* occur under\, but it probably needs
    fixing and tests adding\.
    The \.bs file loading was introduced by 8e07c86e in perl\-5\.001n\.
dist/XSLoader/XSLoader\_pm\.PL&#8203;:148&#8203;:        eval \{ do $bs; \};

    This is a similar issue to DynaLoader \(see above\)\.
    The \.bs file loading was added by v5\.10\.0\-1245\-g73bf755

win32/ce\-helpers/makedist\.pl&#8203;:240&#8203;:        do $bs;
    This is a similar issue to DynaLoader \(see above\)\.

The .bs loading should be done from @​INC, just like the loading of the
shared library, (in fact, they should be in the same directory). Hence
this wouldn't require modification. Not that I'm aware of anything
using that functionality.

cpan/libnet/lib/Net/Config\.pm&#8203;:81&#8203;:  $ref = eval \{ local $SIG\{\_\_DIE\_\_\}; do $file \};
cpan/libnet/lib/Net/Config\.pm&#8203;:92&#8203;:    $ref       = eval \{ local $SIG\{\_\_DIE\_\_\}; do $file \} if \-f $file;

    This looks for libnet\.cfg using the same pathname prefix that
    Config\.pm used \- so presumably it will be found with the same @&#8203;INC
    that found Net&#8203;::Config\.

Correct.

Leon

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2017

From @andk

On Tue, 4 Apr 2017 12​:26​:58 +0100, Dave Mitchell <davem@​iabyn.com> said​:

  > cpan/CPAN/lib/CPAN/Distribution.pm​:3451​: my $x = do $buildparams;

  > I don't know what this code does, but nothing in the test suite
  > triggers it on my system. Probably needs fixing and tests adding.

$buildparams is generated as

  my $buildparams = File​::Spec->catfile($build_dir,"_build","build_params");

so I'm tempted to believe, this needs no fixing.

--
andreas

@p5pRT
Copy link
Author

p5pRT commented Apr 5, 2017

From @iabyn

On Tue, Apr 04, 2017 at 05​:13​:11PM +0200, Leon Timmermans wrote​:

On Tue, Apr 4, 2017 at 1​:26 PM, Dave Mitchell <davem@​iabyn.com> wrote​:

THINGS WHICH REQUIRE FURTHER DISCUSSION

cpan/Unicode\-Collate/Makefile\.PL&#8203;:9&#8203;:    do 'mkheader' or die $@&#8203; || "mkheader&#8203;: $\!";

    I think it currently works due to&#8203;:
        in core&#8203;: running under miniperl \(which has '\.' in @&#8203;INC\);
        in the wild&#8203;: MakeMaker setting PERL\_USE\_UNSAFE\_INC;
    Probably needs fixing by the author in the long term\, but not for
    5\.26\.0\.
dist/Unicode\-Normalize/Makefile\.PL&#8203;:11&#8203;:    do 'mkheader' or die $@&#8203; || "mkheader&#8203;: $\!";

    As for Unicode\-Collate/Makefile\.PL above\, it probably needs fixing
    in the long term\, but not for 5\.26\.0\.

dist/Time\-HiRes/Makefile\.PL&#8203;:424&#8203;:    do $hints;

    As for Unicode\-Collate/Makefile\.PL above\, it probably needs fixing
    in the long term\, but not for 5\.26\.0\.

MakeMaker doesn't set it, CPAN.pm does. We should fix this on CPAN (as
vendors might not), before 5.26.0 is out, but it doesn't matter if we
don't include it in 5.26.0.

I suppose we might as well patch the two dist/ distributions in core now,
and leave Unicode-Collate alone.

ext/DynaLoader/DynaLoader\_pm\.PL&#8203;:376&#8203;:        eval \{ do $bs; \};

    This bit of code is for loading a non\-empty \.bs file\, which
    doesn't occur within the test suite under linux\. I don't know what
    circumstances it \*should\* occur under\, but it probably needs
    fixing and tests adding\.
    The \.bs file loading was introduced by 8e07c86e in perl\-5\.001n\.
dist/XSLoader/XSLoader\_pm\.PL&#8203;:148&#8203;:        eval \{ do $bs; \};

    This is a similar issue to DynaLoader \(see above\)\.
    The \.bs file loading was added by v5\.10\.0\-1245\-g73bf755

win32/ce\-helpers/makedist\.pl&#8203;:240&#8203;:        do $bs;
    This is a similar issue to DynaLoader \(see above\)\.

The .bs loading should be done from @​INC, just like the loading of the
shared library, (in fact, they should be in the same directory). Hence
this wouldn't require modification. Not that I'm aware of anything
using that functionality.

But the "do" in XSLoader.pm etc only gets calls once a .bs file has been
located​:

  if (-s $bs) { # only read file if it's not empty
  eval { do $bs; };

so at this point it's clear that it's trying to load a specific file rather
than search @​INC.

Since I have no idea what .bs files are used for (apart from the fact that
lots of zero-sized ones are created during a perl build), I have no idea
how to add a test for a non-zero-seized one being loaded and executed. Do
other platforms use this, or this is a feature that has been added but is
never used?

--
A problem shared is a problem doubled.

@p5pRT
Copy link
Author

p5pRT commented Apr 6, 2017

From @craigberry

On Wed, Apr 5, 2017 at 2​:51 AM, Dave Mitchell <davem@​iabyn.com> wrote​:

On Tue, Apr 04, 2017 at 05​:13​:11PM +0200, Leon Timmermans wrote​:

The .bs loading should be done from @​INC, just like the loading of the
shared library, (in fact, they should be in the same directory). Hence
this wouldn't require modification. Not that I'm aware of anything
using that functionality.

But the "do" in XSLoader.pm etc only gets calls once a .bs file has been
located​:

if \(\-s $bs\) \{ \# only read file if it's not empty
    eval \{ do $bs; \};

so at this point it's clear that it's trying to load a specific file rather
than search @​INC.

Since I have no idea what .bs files are used for (apart from the fact that
lots of zero-sized ones are created during a perl build), I have no idea
how to add a test for a non-zero-seized one being loaded and executed. Do
other platforms use this, or this is a feature that has been added but is
never used?

I've never used it, but C<perldoc ExtUtils​::Mkbootstrap> says a little
about what it is. The only example I could find is the following,
which only gets built into a .bs file on NeXT​:

$ cat cpan/DB_File/DB_File_BS
# NeXT needs /usr/lib/libposix.a to load along with DB_File.so
if ( $dlsrc eq "dl_next.xs" ) {
  @​DynaLoader​::dl_resolve_using = ( '/usr/lib/libposix.a' );
}

1;

@p5pRT
Copy link
Author

p5pRT commented Apr 7, 2017

From @iabyn

I've just pushed v5.25.11-47-g82421f5, a big merge commit, which has fixes
for many of the thing listed below.

On Tue, Apr 04, 2017 at 12​:26​:58PM +0100, Dave Mitchell wrote​:

JAMES HAS A PATCH WHICH I AGREE SHOULD BE APPLIED

t/loc\_tools\.pl&#8203;:345&#8203;:            @&#8203;Data = do "lib/locale/utf8";
t/loc\_tools\.pl&#8203;:347&#8203;:            @&#8203;Data = do "lib/locale/latin1";

    The patch for this looks good

t/run/dtrace\.t&#8203;:139&#8203;:    do "run/dtrace\.pl";

    The patch for this looks good

These parts are now applied.

--------------------------------------------------------------------

JAMES HAS A PATCH WHICH I THINK NEED NOT BE APPLIED

ext/XS\-APItest/t/blockhooks\.t&#8203;:124&#8203;:    do "t/Null\.pm";
ext/XS\-APItest/t/blockhooks\.t&#8203;:136&#8203;:    do "t/Block\.pm";
    This test script relies on t/harness to set up an appropriate
    @&#8203;INC\. These changes on their own don't make any difference\.

I fixed this by adding '.'to @​INC instead

--------------------------------------------------------------------

I HAVE A PATCH (OR ALTERNATIVE PATCH)

regen/regcharclass\.pl&#8203;:385&#8203;:            die "do '$1' failed&#8203;: $\!$@&#8203;" if \! do $1 or $@&#8203;;
regen/regcharclass\.pl&#8203;:477&#8203;:        die "Can't do 'cp' optree from multi\-codepoint strings";

    This script was broken under no '\.' in @&#8203;INC; presumably the breakage 
    wasn't detected because this script is only occasionally run\.

    I've fixed the "require 'regen/\.\.\.'" line\.

    The "do $1" line above is never actually triggered currently\. If
    someone were to ever make use of this facility\, the regen would
    fail unless they entered a suitable pathname\. So its safe\.  The
    second 'do' is just text\, so a false positive\.

Porting/bench\.pl&#8203;:507&#8203;:    my $ta = do $file;

    The original suggested patch fixed up bench\.pl in a way that
    relative paths for \-\-benchfile=file no longer worked\. My suggested
    commit instead treats 'file' as a relative path\.

utils/libnetcfg\.PL&#8203;:346&#8203;:  %oldcfg = \( %\{ do $libnet\_cfg\_in \} \);

        I have patched it so that it can find the old config file via
        'do'; however; its not clear to me the current relationship
        \(if any\) between utils/libnetcfg\.PL in perl core and Configure
        in the libnet distribution&#8203;: it looks like the latter was
        sucked into core in 2001\, and they've been diverging ever
        since\.  I think the CPAN distribution needs a similar fix\.

These three are applied.

--------------------------------------------------------------------

THINGS WHICH REQUIRE FURTHER DISCUSSION

cpan/Unicode\-Collate/Makefile\.PL&#8203;:9&#8203;:    do 'mkheader' or die $@&#8203; || "mkheader&#8203;: $\!";
cpan/Test\-Simple/t/Legacy/subtest/do\.t&#8203;:13&#8203;:subtest $file => sub \{ do $file \};
cpan/Test\-Simple/t/Legacy/Tester/tbt\_09do\.t&#8203;:12&#8203;:my $done = do $file;
cpan/CPAN/lib/CPAN/Distribution\.pm&#8203;:3451&#8203;:        my $x = do $buildparams;

I've left cpan/ distributions alone.

ext/DynaLoader/DynaLoader\_pm\.PL&#8203;:376&#8203;:        eval \{ do $bs; \};
dist/XSLoader/XSLoader\_pm\.PL&#8203;:148&#8203;:        eval \{ do $bs; \};
win32/ce\-helpers/makedist\.pl&#8203;:240&#8203;:        do $bs;

    This bit of code is for loading a non\-empty \.bs file\, which
    doesn't occur within the test suite under linux\. I don't know what
    circumstances it \*should\* occur under\, but it probably needs
    fixing and tests adding\.
    The \.bs file loading was introduced by 8e07c86e in perl\-5\.001n\.

These have been fixed and a test for executing a non-empty .bs file has
been added to XS-APItest.

dist/Safe/Safe\.pm&#8203;:458&#8203;:            sprintf\('package %s; sub \{ @&#8203;\_ = \(\); do $file \}'\, $root\);

    This implements Safe&#8203;::rdo\(\) \- a restricted version of do\(\)\. The
    docs don't specify whether it should behave like do\(\) as regards @&#8203;INC
    handling\. My gut feeling is that it should\, and that therefore the
    docs should be amended to reflect this\.

docs amended.

dist/Unicode\-Normalize/Makefile\.PL&#8203;:11&#8203;:    do 'mkheader' or die $@&#8203; || "mkheader&#8203;: $\!";
dist/Time\-HiRes/Makefile\.PL&#8203;:424&#8203;:    do $hints;

the blead distributions have been fixed.

--
"Emacs isn't a bad OS once you get used to it.
It just lacks a decent editor."

@p5pRT p5pRT closed this as completed Apr 16, 2017
@p5pRT
Copy link
Author

p5pRT commented Apr 16, 2017

@iabyn - Status changed from 'open' 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