Skip to content

op/glob.t failing on macos monterey for 5.38.0-RC1 #21156

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

Closed
dur-randir opened this issue Jun 16, 2023 · 16 comments · Fixed by #21157
Closed

op/glob.t failing on macos monterey for 5.38.0-RC1 #21156

dur-randir opened this issue Jun 16, 2023 · 16 comments · Fixed by #21157
Assignees

Comments

@dur-randir
Copy link
Member

Description
op/glob.t fails with the following

./perl harness -v op/glob.t
op/glob.t ..
1..18
not ok 1 - leftover op/* files
ok 2 - sane input record separator
# Failed test 1 - leftover op/* files at op/glob.t line 25
# op/hook
ok 3 - glob amid garbage []
ok 4 - input record separator still sane
ok 5 - glob operator 1
ok 6 - glob operator 2
ok 7 - eval'ed a glob 1
ok 8 - eval'ed a glob 2
ok 9 - remove File::Glob stash
ok 10 - remove File::Glob stash *and* CORE::GLOBAL::glob
ok 11 - undefined *CORE::GLOBAL::glob{CODE} at run time
ok 12 - undefined *CORE::GLOBAL::glob{CODE} at compile time
ok 13 - define versus truth
ok 14 - test definedness with LOGOP
ok 15 - glob globbed something
ok 16 - ~ works
ok 17 - CORE::glob bypasses overrides
ok 18 - Make sure the presence of the CORE::GLOBAL::glob typeglob does not affect whether File::Glob::csh_glob is called.
Failed 1/18 subtests

Test Summary Report
-------------------
op/glob.t (Wstat: 0 Tests: 18 Failed: 1)
  Failed test:  1
Files=1, Tests=18,  0 wallclock secs ( 0.00 usr  0.00 sys +  0.06 cusr  0.06 csys =  0.12 CPU)
Result: FAIL
Finished test run at Fri Jun 16 11:31:27 2023.

Steps to Reproduce

Run test suite for perl-5.38.0-RC1 on macos monterey 12.6.5.

Expected behavior

Passing test suite.

Perl configuration

Summary of my perl5 (revision 5 version 38 subversion 0) configuration:

  Platform:
    osname=darwin
    osvers=21.6.0
    archname=darwin-thread-multi-2level
    uname='darwin orthanc.lan 21.6.0 darwin kernel version 21.6.0: thu mar 9 20:12:21 pst 2023; root:xnu-8020.240.18.700.8~1release_arm64_t6000 x86_64 '
    config_args='-de -DDEBUGGING -Dusethreads'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=12.6 -DNO_POSIX_2008_LOCALE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include'
    optimize='-O3 -g'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=12.6 -DNO_POSIX_2008_LOCALE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include'
    ccversion=''
    gccversion='Apple LLVM 14.0.0 (clang-1400.0.29.202)'
    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 =' -mmacosx-version-min=12.6 -fstack-protector-strong -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /opt/local/lib /usr/lib
    libs=-lgdbm
    perllibs=
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=12.6 -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl):
  Compile-time options:
    DEBUGGING
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_TRACK_MEMPOOL
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Locally applied patches:
    RC1
  Built under darwin
  Compiled at Jun 16 2023 09:47:13
  %ENV:
    PERLBREW_HOME="/Users/dur-randir/.perlbrew"
    PERLBREW_MANPATH="/Users/dur-randir/perlbrew/perls/perl-5.36.0-poison/man"
    PERLBREW_PATH="/Users/dur-randir/perlbrew/bin:/Users/dur-randir/perlbrew/perls/perl-5.36.0-poison/bin"
    PERLBREW_PERL="perl-5.36.0-poison"
    PERLBREW_ROOT="/Users/dur-randir/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.96"
    PERLBREW_VERSION="0.96"
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.38.0/darwin-thread-multi-2level
    /usr/local/lib/perl5/site_perl/5.38.0
    /usr/local/lib/perl5/5.38.0/darwin-thread-multi-2level
    /usr/local/lib/perl5/5.38.0
@jkeenan
Copy link
Contributor

jkeenan commented Jun 16, 2023

It appears that the purpose of the first unit test in t/op/glob.t is to ensure that the t/op/ directory is "clean", i.e., that there are no files in that directory left over from previous work therein.

 21 else {
 22   map { $files{$_}++ } <op/*>;
 23   map { delete $files{"op/$_"} } split /\n/, `ls op/ | cat`;
 24 }
 25 ok( !(keys(%files)),'leftover op/* files' ) or diag(join(' ',sort keys %files));

In t/op/ there is one subdirectory, t/op/hook, which is being identified as "leftover". Did you do previous runs of the test suite (or other work) in this directory tree after you unpacked the tarball? (I don't have access to your platform/OS version, so I'm limited in what I can diagnose.)

@dur-randir
Copy link
Member Author

This happens on the 1st run after tar -xf perl-5.38.0-RC1.tar.gz && perl-5.38.0-RC1 && ./Configure -de -DDEBUGGING -Dusethreads && TEST_JOBS=10 make -j10 test_harness

@demerphq
Copy link
Collaborator

It isn't clear to me if the way the test is being invoked is correct. The test should exclude op/hook and I wonder if it's being executed right. What happens if you do:

make test_harness TEST_ARGS='-re glob.t'

@demerphq demerphq self-assigned this Jun 16, 2023
@demerphq
Copy link
Collaborator

I will take a look at this as I added t/op/hook

@dur-randir
Copy link
Member Author

dur-randir commented Jun 16, 2023

It isn't clear to me if the way the test is being invoked is correct

The same happens after global TEST_JOBS=10 make -j10 test_harness. Running tar -xf perl-5.38.0-RC1.tar.gz && cd perl-5.38.0-RC1 && ./Configure -de -DDEBUGGING -Dusethreads && make -j10 test_prep && make test_harness TEST_ARGS='-re glob.t' I get

cd t && (rm -f perl; /bin/ln -s ../perl perl)
TESTFILE=harness  ./runtests choose
op/glob.t ................................ 1/18 # Failed test 1 - leftover op/* files at op/glob.t line 25
# op/hook
op/glob.t ................................ Failed 1/18 subtests
../cpan/Test-Harness/t/glob-to-regexp.t .. ok

Test Summary Report
-------------------
op/glob.t                              (Wstat: 0 Tests: 18 Failed: 1)
  Failed test:  1
Files=2, Tests=38,  0 wallclock secs ( 0.05 usr  0.01 sys +  0.12 cusr  0.06 csys =  0.24 CPU)
Result: FAIL
Finished test run at Fri Jun 16 16:14:52 2023.
make: *** [test_harness] Error 1

@demerphq
Copy link
Collaborator

I get ...

Ok, interesting. Can you change the code in glob.t to this:

$ diff -u ~/git_tree/perl/t/op/glob.t t/op/glob.t 
--- /home/yorton/git_tree/perl/t/op/glob.t	2023-04-28 15:47:03.727164988 +0200
+++ t/op/glob.t	2023-06-16 16:14:30.840376866 +0200
@@ -20,7 +20,11 @@
 }
 else {
   map { $files{$_}++ } <op/*>;
-  map { delete $files{"op/$_"} } split /\n/, `ls op/ | cat`;
+  my @files = split /\n/, `ls op/ | cat`;
+  use Data::Dumper;
+  diag Dumper(\@files);
+
+  map { delete $files{"op/$_"} } @files;
 }
 ok( !(keys(%files)),'leftover op/* files' ) or diag(join(' ',sort keys %files));
 

and tell me what it says please?

@demerphq
Copy link
Collaborator

@jkeenan said:

that there are no files in that directory left over from previous work therein

Actually that is wrong, this test is checking to see if the perl code <op/*> returns the same files as the shell command ls op/ | cat returns.

@dur-randir
Copy link
Member Author

cd t && (rm -f perl; /bin/ln -s ../perl perl)
TESTFILE=harness  ./runtests choose
op/glob.t ................................ # $VAR1 = [
#           '64bitint.t',
#           'aassign.t',
#           'alarm.t',
#           'anonconst.t',
#           'anonsub.t',
#           'append.t',
#           'args.t',
#           'arith2.t',
#           'array.t',
#           'assignwarn.t',
#           'attrhand.t',
#           'attrproto.t',
#           'attrs.t',
#           'auto.t',
#           'avhv.t',
#           'bless.t',
#           'blocks.t',
#           'bool.t',
#           'bop.t',
#           'caller.pl',
#           'caller.t',
#           'catch.t',
#           'chars.t',
#           'chdir.t',
#           'chop.t',
#           'chr.t',
#           'closure.t',
#           'closure_test.pl',
#           'cmpchain.t',
#           'concat2.t',
#           'cond.t',
#           'const-optree.t',
#           'context.t',
#           'coreamp.t',
#           'coresubs.t',
#           'cproto.t',
#           'crypt.t',
#           'current_sub.t',
#           'dbm.t',
#           'decl-refs.t',
#           'defer.t',
#           'defined.t',
#           'defins.t',
#           'delete.t',
#           'die.t',
#           'die_except.t',
#           'die_exit.t',
#           'die_keeperr.t',
#           'die_unwind.t',
#           'do.t',
#           'dor.t',
#           'dump.t',
#           'each.t',
#           'each_array.t',
#           'eval.t',
#           'evalbytes.t',
#           'exec.t',
#           'exists_sub.t',
#           'exp.t',
#           'fh.t',
#           'filehandle.t',
#           'filetest.t',
#           'filetest_stack_ok.t',
#           'filetest_t.t',
#           'flip.t',
#           'for-many.t',
#           'for.t',
#           'fork.t',
#           'fresh_perl_utf8.t',
#           'getpid.t',
#           'getppid.t',
#           'glob.t',
#           'gmagic.t',
#           'goto.t',
#           'goto_xs.t',
#           'grent.t',
#           'grep.t',
#           'groups.t',
#           'gv.t',
#           'hash-clear-placeholders.t',
#           'hash-rt85026.t',
#           'hash.t',
#           'hashassign.t',
#           'hashwarn.t',
#           'heredoc.t',
#           'hexfp.t',
#           'hook',
#           'inc.t',
#           'inccode-tie.t',
#           'inccode.t',
#           'incfilter.t',
#           'index.t',
#           'index_thr.t',
#           'infnan.t',
#           'int.t',
#           'isa.t',
#           'join.t',
#           'kill0.t',
#           'kill0_child',
#           'kvaslice.t',
#           'kvhslice.t',
#           'lc.t',
#           'leaky-magic.t',
#           'length.t',
#           'lex.t',
#           'lex_assign.t',
#           'lexsub.t',
#           'lfs.t',
#           'list.t',
#           'local.t',
#           'localref.t',
#           'lock.t',
#           'loopctl.t',
#           'lop.t',
#           'lvref.t',
#           'magic-27839.t',
#           'magic.t',
#           'method.t',
#           'mkdir.t',
#           'multideref.t',
#           'my.t',
#           'my_stash.t',
#           'mydef.t',
#           'negate.t',
#           'not.t',
#           'numconvert.t',
#           'numify.t',
#           'numify_chkflags.t',
#           'oct.t',
#           'or.t',
#           'ord.t',
#           'overload_integer.t',
#           'override.t',
#           'pack.t',
#           'packagev.t',
#           'pos.t',
#           'postfixderef.t',
#           'pow.t',
#           'print.t',
#           'protowarn.t',
#           'push.t',
#           'pwent.t',
#           'qr.t',
#           'quotemeta.t',
#           'rand.t',
#           'range.t',
#           'read.t',
#           'readdir.t',
#           'readline.t',
#           'recurse.t',
#           'ref.t',
#           'repeat.t',
#           'require_37033.t',
#           'require_errors.t',
#           'require_gh20577.t',
#           'require_override.t',
#           'reset.t',
#           'reverse.t',
#           'rt119311.t',
#           'runlevel.t',
#           'select.t',
#           'setpgrpstack.t',
#           'sigdispatch.t',
#           'signame_canonical.t',
#           'signatures.t',
#           'sigsystem.t',
#           'sleep.t',
#           'smartkve.t',
#           'smartmatch.t',
#           'sort.t',
#           'splice.t',
#           'split.t',
#           'split_unicode.t',
#           'sprintf.t',
#           'sprintf2.t',
#           'srand.t',
#           'sselect.t',
#           'stash.t',
#           'stash_parse_gv.t',
#           'stat.t',
#           'stat_errors.t',
#           'state.t',
#           'study.t',
#           'studytied.t',
#           'sub.t',
#           'sub_lval.t',
#           'substr.t',
#           'substr_thr.t',
#           'svflags.t',
#           'svleak.pl',
#           'svleak.t',
#           'switch.t',
#           'symbolcache.t',
#           'sysio.t',
#           'taint.t',
#           'threads-dirh.t',
#           'threads.t',
#           'threads_create.pl',
#           'tie.t',
#           'tie_fetch_count.t',
#           'tiearray.t',
#           'tiehandle.t',
#           'tiehash.t',
#           'time.t',
#           'time_loop.t',
#           'tr.t',
#           'tr_latin1.t',
#           'try.t',
#           'undef.t',
#           'universal.t',
#           'unlink.t',
#           'unshift.t',
#           'upgrade.t',
op/glob.t ................................ 1/18 #           'utf8cache.t',
#           'utf8decode.t',
#           'utf8magic.t',
#           'utfhash.t',
#           'utftaint.t',
#           'vec.t',
#           'ver.t',
#           'waitpid.t',
#           'wantarray.t',
#           'warn.t',
#           'while.t',
#           'write.t',
#           'yadayada.t'
#         ];
# Failed test 1 - leftover op/* files at op/glob.t line 29
# op/hook
op/glob.t ................................ Failed 1/18 subtests
../cpan/Test-Harness/t/glob-to-regexp.t .. ok

Test Summary Report
-------------------
op/glob.t                              (Wstat: 0 Tests: 18 Failed: 1)
  Failed test:  1
Files=2, Tests=38,  1 wallclock secs ( 0.05 usr  0.01 sys +  0.13 cusr  0.06 csys =  0.25 CPU)
Result: FAIL
Finished test run at Fri Jun 16 17:40:39 2023.
make: *** [test_harness] Error 1

@demerphq
Copy link
Collaborator

Sorry, one more diff to apply and try

$ diff -u ~/git_tree/perl/t/op/glob.t t/op/glob.t 
--- /home/yorton/git_tree/perl/t/op/glob.t	2023-04-28 15:47:03.727164988 +0200
+++ t/op/glob.t	2023-06-16 16:55:43.402590951 +0200
@@ -20,7 +20,11 @@
 }
 else {
   map { $files{$_}++ } <op/*>;
-  map { delete $files{"op/$_"} } split /\n/, `ls op/ | cat`;
+  my %ls_files;
+  map { $ls_files{"op/$_"}++ } split /\n/, `ls op/ | cat`;
+  delete $files{$_} and delete $ls_files{$_} for keys %ls_files;
+  use Data::Dumper;
+  diag Dumper(\%files,\%ls_files);
 }
 ok( !(keys(%files)),'leftover op/* files' ) or diag(join(' ',sort keys %files));

I can't see why t/op/hook is being handled differently than the rest of the files. It is peculiar.

@dur-randir
Copy link
Member Author

dur-randir commented Jun 16, 2023

The difference is funny and would be lost after pasting here. Since you're calling external ls, it respects everything in %ENV. Which is inherited from the calling shell. Including such things as LSCOLORS, CLICOLORS and CLICOLORS_FORCE. Setting the last one is enough to trigger this. The actual key in %ls_files was "op/\x1B[1m\x1B[34mhook\x1B[39;49m\x1B[0m".

@demerphq
Copy link
Collaborator

demerphq commented Jun 16, 2023

The you're calling external ls, it respects everything in %ENV. .... CLICOLORS_FORCE. Setting the last one is enough to trigger this.

Yep, that explains it nicely. I think the idea of piping to cat is to disable such settings, but CLICOLORS_FORCE would add colors even though it is outputting to a pipe and not the normal STDOUT. I'll prepare a patch, thanks for your help!

@jkeenan
Copy link
Contributor

jkeenan commented Jun 16, 2023

The difference is funny and would be lost after pasting here. Since you're calling external ls, it respects everything in %ENV. Which is inherited from the calling shell. Including such things as LSCOLORS, CLICOLORS and CLICOLORS_FORCE. Setting the last one is enough to trigger this. The actual key in %ls_files was "op/\x1B[1m\x1B[34mhook\x1B[39;49m\x1B[0m".

Confirmed on FreeBSD.

$ uname -mrs
FreeBSD 12.3-RELEASE-p6 amd64
\# build a perl from blead
$ export CLICOLOR=1; export LSCOLORS=Exfxcxdxbxegedabagacad;
$ ./perl -Ilib t/op/glob.t
1..18
ok 1 - leftover op/* files
ok 2 - sane input record separator
...

$ export CLICOLOR=1; export LSCOLORS=Exfxcxdxbxegedabagacad; export CLICOLOR_FORCE=1
[perlmonger: perl] $ ./perl -Ilib t/op/glob.t
1..18
not ok 1 - leftover op/* files
# Failed test 1 - leftover op/* files at t/op/glob.t line 25
# op/hook
...

@demerphq
Copy link
Collaborator

Confirmed on FreeBSD.

Curious, if you look closely you and @dur-randir have used different settings, he said CLICOLORS_FORCE and you said CLICOLOR_FORCE=1 (notice the S is missing). Is this a portability issue?

@dur-randir
Copy link
Member Author

dur-randir commented Jun 16, 2023

Is this a portability issue?

No, just misspelling on my part. I didn't copy it but retyped - it's really without S. Only LSCOLORS is with S.

@jkeenan
Copy link
Contributor

jkeenan commented Jun 16, 2023

Is this a portability issue?

No, just misspelling on my part. I didn't copy it but retyped - it's really without S. Only LSCOLORS is with S.

Agree with @dur-randir . On FreeBSD, we have:

     CLICOLOR            Use ANSI color sequences to distinguish file types.
                         See LSCOLORS below.  In addition to the file types
                         mentioned in the -F option some extra attributes
                         (setuid bit set, etc.) are also displayed.  The
                         colorization is dependent on a terminal type with the
                         proper termcap(5) capabilities.  The default "cons25"
                         console has the proper capabilities, but to display
                         the colors in an xterm(1), for example, the TERM
                         variable must be set to "xterm-color".  Other
                         terminal types may require similar adjustments.
                         Colorization is silently disabled if the output is
                         not directed to a terminal unless the CLICOLOR_FORCE
                         variable is defined or --color is set to "always".

     CLICOLOR_FORCE      Color sequences are normally disabled if the output
                         is not directed to a terminal.  This can be
                         overridden by setting this variable.  The TERM
                         variable still needs to reference a color capable
                         terminal however otherwise it is not possible to
                         determine which color sequences to use.
...
     LSCOLORS            The value of this variable describes what color to
                         use for which attribute when colors are enabled with
                         CLICOLOR or COLORTERM.  This string is a
                         concatenation of pairs of the format fb, where f is
                         the foreground color and b is the background color.

                         The color designators are as follows:

                               a     black
                               b     red
...

demerphq added a commit that referenced this issue Jun 16, 2023
Disable any ENV vars with the word "color", "ls" or "cli" in them
(case insensitively) before running ls.  This appears to mostly
be a BSD/darwin issue, but we do it on all platforms where we call
ls in an abundance of caution.

Fixes #21156.
@demerphq
Copy link
Collaborator

Fix pushed. @rjbs you might want to include this in 5.38.

rjbs pushed a commit that referenced this issue Jun 17, 2023
Disable any ENV vars with the word "color", "ls" or "cli" in them
(case insensitively) before running ls.  This appears to mostly
be a BSD/darwin issue, but we do it on all platforms where we call
ls in an abundance of caution.

Fixes #21156.
khwilliamson pushed a commit to khwilliamson/perl5 that referenced this issue Jul 10, 2023
Disable any ENV vars with the word "color", "ls" or "cli" in them
(case insensitively) before running ls.  This appears to mostly
be a BSD/darwin issue, but we do it on all platforms where we call
ls in an abundance of caution.

Fixes Perl#21156.
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.

3 participants