rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

t/20-pp.t fails tests on macOS Sonoma with perl 5.38.2 #79

Closed shawnlaffan closed 8 months ago

shawnlaffan commented 8 months ago

I just updated my local Mac to Sonoma (14.1.2).

After building perl 5.38.2 using perlbrew I see the failures below.

Running one of the generated files (./contrib/automated_pp_test/pp_switch_tests/temp2/a.out) produces this result:

Can't locate hidden_print_caller.pm in @INC (you may need to install the hidden_print_caller module) (@INC entries checked: /var/folders/pt/h6h_6z6x5w75jzcd65r_s7zw0000gq/T/par-736861776e/cache-6ea2f32ac3fed6c316ef6eb6b0b23e94e8260e62/inc CODE(0x14a40d878) CODE(0x14a40def0)) at script/foo.pl line 2.
BEGIN failed--compilation aborted at script/foo.pl line 2.

Please let me know what other debugging steps are needed.

====

Test results:

t/20-pp.t ................ 17/34 
#   Failed test 'pp_minus_I_foo_hello 
# [430]
# Test 17_1 The command string " ./a.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp2,did not produce :: "hello" ::
# Instead, it produced :: 
# The Line Below SHOULD BE  "Can't locate ...  along with a "BEGIN failed ... " line ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp2/subdir1" foo.pl produce a.out?
# '
#   at ./automated_pp_test.pl line 7597.
t/20-pp.t ................ 18/34 
#   Failed test 'pp_minus_I_foo_minus_I_bar_hello 
# [430]
# Test 18_1 The command string " ./a.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0,did not produce :: "hello" ::
# Instead, it produced :: 
# The Line Below SHOULD BE  "Can't locate ...  along with a "BEGIN failed ... " line ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/subdir1" -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/subdir2" "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/foo.pl" produce a.out?
# '
#   at ./automated_pp_test.pl line 7642.
t/20-pp.t ................ 19/34 
#   Failed test 'pp_minus_lib_foo_hello 
# [430]
# Test 19_1 The command string " ./a.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp1,did not produce :: "hello" ::
# Instead, it produced :: 
# The Line Below SHOULD BE  "Can't locate ...  along with a "BEGIN failed ... " line ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" --lib "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp1/subdir1" foo.pl produce a.out?
# '
#   at ./automated_pp_test.pl line 7687.
t/20-pp.t ................ 21/34 
#   Failed test 'pp_minus_M_foo_hidden_print_foo 
# [430]
# Test 21_1 The command string " ./a.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0,did not produce :: "hello" ::
# Instead, it produced ::  ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" -M subdir1::hidden_print foo.pl produce a.out?
# '
#   at ./automated_pp_test.pl line 7777.
t/20-pp.t ................ 23/34 
#   Failed test 'pp_minus_X_module_foo 
# [430]
# Test 23_0 The command string " ./a.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp2,did not produce :: "perl" ::
# Instead, it produced ::  ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp2/foo.pl" produce a.out?
# '
#   at ./automated_pp_test.pl line 7866.
t/20-pp.t ................ 34/34 # Looks like you failed 5 tests of 34.
t/20-pp.t ................ Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/34 subtests 
t/30-current_exec.t ...... ok   
t/40-packer_cd_option.t .. ok   
t/80-doublecolon.t ....... ok   
t/85-crt-glob.t .......... ok   
t/85-myfile.t ............ 2/6 
#   Failed test 'successfully ran "/var/folders/pt/h6h_6z6x5w75jzcd65r_s7zw0000gq/T/wnsA1xLMRn/pp000"'
#   at ./t/utils.pl line 45.
#          got: '9'
#     expected: '0'
# OUT:
# 
# ERR:
Use of uninitialized value $out in eval "string" at t/85-myfile.t line 30.
Use of uninitialized value in subroutine entry at t/85-myfile.t line 32.

#   Failed test 'expected source path from __FILE__'
#   at t/85-myfile.t line 35.
#          got: undef
#     expected: '/inc/lib/Myfile.pm'
Use of uninitialized value in -e at t/85-myfile.t line 36.

#   Failed test 'file __FILE__ exists'
#   at t/85-myfile.t line 36.

#   Failed test 'expected source path from (caller)[1]'
#   at t/85-myfile.t line 37.
#          got: undef
#     expected: '/inc/lib/Myfile.pm'
Use of uninitialized value in -e at t/85-myfile.t line 38.

#   Failed test 'file (caller)[1] exists'
#   at t/85-myfile.t line 38.
# Looks like you failed 5 tests of 6.
t/85-myfile.t ............ Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/6 subtests 
Summary of my perl5 (revision 5 version 38 subversion 2) configuration:

  Platform:
    osname=darwin
    osvers=23.1.0
    archname=darwin-2level
    uname='darwin w-c07jm03pq6p0.ad.unsw.edu.au 23.1.0 darwin kernel version 23.1.0: mon oct 9 21:28:12 pdt 2023; root:xnu-10002.41.9~6release_arm64_t8103 arm64 '
    config_args='-de -Dprefix=/Users/shawn/perl5/perlbrew/perls/perl-5.38.2 -Aeval:scriptdir=/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/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 ='-fno-common -DPERL_DARWIN -mmacosx-version-min=14.1 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=14.1 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='Apple LLVM 15.0.0 (clang-1500.0.40.1)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    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=14.1 -fstack-protector-strong -L/usr/local/lib'
    libpth=/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/lib /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib /Library/Developer/CommandLineTools/usr/lib /usr/local/lib /usr/lib
    libs= 
    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=14.1 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    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_USE_SAFE_PUTENV
    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 darwin
  Compiled at Dec  4 2023 15:27:05
  %ENV:
    PERLBREW_HOME="/Users/shawn/.perlbrew"
    PERLBREW_MANPATH="/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/man"
    PERLBREW_PATH="/Users/shawn/perl5/perlbrew/bin:/Users/shawn/perl5/perlbrew/perls/perl-5.38.2/bin"
    PERLBREW_PERL="perl-5.38.2"
    PERLBREW_ROOT="/Users/shawn/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.96"
    PERLBREW_VERSION="0.96"
  @INC:
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.2/lib/site_perl/5.38.2/darwin-2level
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.2/lib/site_perl/5.38.2
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.2/lib/5.38.2/darwin-2level
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.2/lib/5.38.2

When using 5.38.0 only two tests fail (noting that this was built prior to the OS update):

t/20-pp.t ................ 17/34 
#   Failed test 'pp_minus_I_foo_hello 
# [430]
# Test 17_1 The command string " ./a.out " in directory /Users/shawn/.cpanm/work/1701665708.7085/PAR-Packer-1.059/contrib/automated_pp_test/pp_switch_tests/temp2,did not produce :: "hello" ::
# Instead, it produced :: 
# The Line Below SHOULD BE  "Can't locate ...  along with a "BEGIN failed ... " line ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.0/bin/perl" "/Users/shawn/.cpanm/work/1701665708.7085/PAR-Packer-1.059/blib/script/pp" -I "/Users/shawn/.cpanm/work/1701665708.7085/PAR-Packer-1.059/contrib/automated_pp_test/pp_switch_tests/temp2/subdir1" foo.pl produce a.out?
# '
#   at ./automated_pp_test.pl line 7597.
t/20-pp.t ................ 21/34 
#   Failed test 'pp_minus_M_foo_hidden_print_foo 
# [430]
# Test 21_1 The command string " ./a.out " in directory /Users/shawn/.cpanm/work/1701665708.7085/PAR-Packer-1.059/contrib/automated_pp_test/pp_switch_tests/temp0,did not produce :: "hello" ::
# Instead, it produced ::  ::
# End of [430] results 
# 
# Did "/Users/shawn/perl5/perlbrew/perls/perl-5.38.0/bin/perl" "/Users/shawn/.cpanm/work/1701665708.7085/PAR-Packer-1.059/blib/script/pp" -M subdir1::hidden_print foo.pl produce a.out?
# '
#   at ./automated_pp_test.pl line 7777.
t/20-pp.t ................ 34/34 # Looks like you failed 2 tests of 34.
t/20-pp.t ................ Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/34 subtests 
Summary of my perl5 (revision 5 version 38 subversion 0) configuration:

  Platform:
    osname=darwin
    osvers=22.6.0
    archname=darwin-2level
    uname='darwin w-c07jm03pq6p0.ad.unsw.edu.au 22.6.0 darwin kernel version 22.6.0: fri sep 15 13:41:30 pdt 2023; root:xnu-8796.141.3.700.8~1release_arm64_t8103 arm64 '
    config_args='-de -Dprefix=/Users/shawn/perl5/perlbrew/perls/perl-5.38.0 -Aeval:scriptdir=/Users/shawn/perl5/perlbrew/perls/perl-5.38.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
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=13.6 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=13.6 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='Apple LLVM 14.0.3 (clang-1403.0.22.14.1)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    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=13.6 -fstack-protector-strong -L/usr/local/lib'
    libpth=/Library/Developer/CommandLineTools/usr/lib/clang/14.0.3/lib /Library/Developer/CommandLineTools/SDKs/MacOSX13.3.sdk/usr/lib /Library/Developer/CommandLineTools/usr/lib /usr/local/lib /usr/lib
    libs= 
    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=13.6 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    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_USE_SAFE_PUTENV
    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 darwin
  Compiled at Nov 17 2023 13:37:23
  %ENV:
    PERLBREW_HOME="/Users/shawn/.perlbrew"
    PERLBREW_MANPATH="/Users/shawn/perl5/perlbrew/perls/perl-5.38.0/man"
    PERLBREW_PATH="/Users/shawn/perl5/perlbrew/bin:/Users/shawn/perl5/perlbrew/perls/perl-5.38.0/bin"
    PERLBREW_PERL="perl-5.38.0"
    PERLBREW_ROOT="/Users/shawn/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.96"
    PERLBREW_VERSION="0.96"
  @INC:
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.0/lib/site_perl/5.38.0/darwin-2level
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.0/lib/site_perl/5.38.0
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0/darwin-2level
    /Users/shawn/perl5/perlbrew/perls/perl-5.38.0/lib/5.38.0
rschupp commented 8 months ago

Let's focus on t/85-myfile.t. Please run

PAR_TMPDIR=some-existing-directory make test TEST_VERBOSE=1 TEST_FILES=t/85-myfile.t 

so that executables built by pp don't get cleaned up end at the end of test, then examine the file named in the error message

#   Failed test 'successfully ran "/var/folders/pt/h6h_6z6x5w75jzcd65r_s7zw0000gq/T/wnsA1xLMRn/pp000"'
#   at ./t/utils.pl line 45.
#          got: '9'
#     expected: '0'

got here is $? from running the executable.

shawnlaffan commented 8 months ago

Will do when I'm in front of that machine again, probably Friday AEDST.

shawnlaffan commented 8 months ago

t/85-myfile.t passes when PAR_TMP_DIR is set to a local dir.

Running the full set of tests with TMPDIR set to the full path of a local dir results in only test pp_minus_lib_foo_minus_lib_bar_hello from t/20-pp.t failing.

Runningperl Makefile and then make test with both env vars set results in pp_test_small_minus_a failing for one call but passing for another. Other tests fail on other runs.

So it would seem to be related to a system level constraint rather than PAR::Packer per se.

Pausing the backup system had no effect.

shawnlaffan commented 8 months ago

Inserting a sleep(1) before https://github.com/rschupp/PAR-Packer/blob/d2305afb319783c0694b455abce77979319c196e/contrib/automated_pp_test/pipe_a_command.pm#L116 seems to make things pass.

Using unique names for the executable might be a solution but finding the best location at which do so is more challenging.

rschupp commented 8 months ago

I can't see any "system level constraints" violated here, the code looks complicated (why read the command's output from a pipe, write it to a file, then read back that file?), but all filehandles are closed before proceeding....

Sprinkling sleeps looks like voodo to me, it will also add 100 seconds to make test.

automated_pp_test is a mess. It was generated by some tool using some spec, both lost in the mist of time. Its coding style is godawful, even in the non-generated parts. And it's only a unit test for pp etc command line options. Maybe we should kill t/20-pp.t?

shawnlaffan commented 8 months ago

My suspicion is that it's an antivirus scan that has not released the file by the time the next test tries to re-use that name. This machine is controlled by $work so I cannot disable such things.

The sleep was just a diagnostic step.

If t-20-pp.t is not needed then it can go.

Another option is to increment the file names after each test. They are set in one location but there is a test counter that can be used after each test. It would be tedious but possible.

rschupp commented 8 months ago

Another option is to increment the file names after each test. They are set in one location but there is a test counter that can be used after each test. It would be tedious but possible.

I'v done this now: all "toplevel" executables now have the test number in their name. However, several tests have subtests that reuse the per-test executable name. I've fixed the worst offenders by hand, but some duplicate names still remain.

Can you try the "ci" branch (passes on Linux and Windows)?

shawnlaffan commented 8 months ago

The tests still fails unfortunately, and inconsistently so. The example below is 18 (also failed 21), but the previous run failed for 19 and 23.

The is also using perl 5.36, so at least we can rule out 5.38.

Passing different executable name args seems to get the failing tests to pass (for a subset I checked) - usually this is the second test in the sub. The last test uses a different directory so is (should be) unaffected.

One does wonder what the benefit is to running the same test just with a different output dir, but I guess that's just one of the oddities of this test file.

not ok 18 - pp_minus_I_foo_minus_I_bar_hello 
# [430]
# Test 18_1 The command string " ./a18.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0,did not produce :: "hello" ::
# Instead, it produced :: 
# The Line Below SHOULD BE  "Can't locate ...  along with a "BEGIN failed ... " line ::
# End of [430] results 
# 
# Did "/opt/homebrew/Cellar/perl/5.36.1/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" -o "a18.out"  -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/subdir1" -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/subdir2" "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/foo.pl" produce a18.out?
# 

#   Failed test 'pp_minus_I_foo_minus_I_bar_hello 
# [430]
# Test 18_1 The command string " ./a18.out " in directory /Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0,did not produce :: "hello" ::
# Instead, it produced :: 
# The Line Below SHOULD BE  "Can't locate ...  along with a "BEGIN failed ... " line ::
# End of [430] results 
# 
# Did "/opt/homebrew/Cellar/perl/5.36.1/bin/perl" "/Users/shawn/git/PAR-Packer/blib/script/pp" -o "a18.out"  -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/subdir1" -I "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/subdir2" "/Users/shawn/git/PAR-Packer/contrib/automated_pp_test/pp_switch_tests/temp0/foo.pl" produce a18.out?
# '
#   at ./automated_pp_test.pl line 7660.
rschupp commented 8 months ago

I fixed hopefully all subtests to use unique names for executables generated with $RUN_PP, please try "ci" again.

shawnlaffan commented 8 months ago

Thanks. That seems to do the trick. All tests in t/20-pp.t now pass.

rschupp commented 8 months ago

Thanks for testing, released as 1.060