ExtUtils::MM_Unix: avoid die in _find_static_libs on removed dirs (fixes #24561) - #24839
goanscryca wants to merge 1 commit into
Conversation
During parallel test runs (e.g., core smoke tests), cpan/ExtUtils-MakeMaker/t/03-xsstatic.t
could intermittently fail during static makeaperl with:
Can't cd to .. from ../../../../lib/auto/ExtTest: No such file or directory at File/Find.pm line 477.
or:
Can't opendir(../../../../lib/auto/ExtTest): Stale file handle
Can't cd to .. from ../../../../lib/auto/ExtTest: Stale file handle at File/Find.pm line 477.
This happens because another test running concurrently (such as
cpan/ExtUtils-Constant/t/Constant.t) creates and cleans up modules in the
core lib/auto directory (e.g., ExtTest) while 03-xsstatic.t is running
_find_static_libs. Because File::Find defaulted to chdir'ing into each
directory (no_chdir => 0), when a visited directory was deleted concurrently,
File::Find failed to chdir('..') and died.
Fix by running File::Find::find with no_chdir => 1 and disabling File::Find
warnings, preventing chdir into subdirectories and safely ignoring directories
that vanish during traversal.
Fixes Perl#24561.
| return unless -f 'extralibs.ld'; # this checks is a "proper" XS installation | ||
| return unless -f "$File::Find::dir/extralibs.ld"; # this checks is a "proper" XS installation | ||
|
|
||
| my ($base) = $File::Find::name =~ m{([^/\\]+)\z}; |
I can't claim deep expertise in this area and have not yet evaluated the p.r., but I do note that our smoke-test reports show intermittent failures to complete
Among the above reports, the following reports also showed premature exits in |
|
@goanscryca, thank you for your patch. Since ExtUtils-MakeMaker is primarily maintained upstream on CPAN, it will have to be evaluated by the maintainers of that CPAN library. To get the ball rolling on that, I have filed Perl-Toolchain-Gang/ExtUtils-MakeMaker#488; you should follow that ticket. When we ran your pull request through our CI system, we noted two porting test (metadata) failures: one in As noted in posts above, we have identified smoke-test reports with the test failures you have reported. For diagnostic purposes we'll be running additional smoke-tests on a branch created from your pull request. |
Yeah, this should be closed here and opened in ExtUtils::MakeMaker's repository. |
This OTOH sounds like it's ExtUtils::Constant that should do something more sensible. |
Summary
Fixes #24561.
During parallel test runs (such as core smoke tests with multiple jobs),
cpan/ExtUtils-MakeMaker/t/03-xsstatic.tcould intermittently fail during staticmakeaperlwith errors such as:or
Root Cause
Another test running concurrently (such as
cpan/ExtUtils-Constant/t/Constant.t) builds and cleans up test modules in the corelib/autodirectory (e.g.,lib/auto/ExtTest) while03-xsstatic.trunsmake testfor a static perl binary.When
staticmakeinvokesExtUtils::MM_Unix::_find_static_libsto discover static extension libraries underauto/,File::Find::findwas called with default settings (no_chdir => 0).If a directory under
auto/was deleted concurrently whileFile::Findwas traversing it,File::Findfailed when attempting tochdir('..')back to the parent directory and died at line 477.Solution
File::Find::findwithno_chdir => 1in_find_static_libs, avoiding directory changes during traversal.no warnings;within the search scope so removed directories don't emit spurious errors if unlinked right beforeopendir.abs_path($File::Find::name)/rel2absrather than relying oncwd().cpan/ExtUtils-MakeMaker/t/MM_Unix.tsimulating concurrent directory removal during_find_static_libs.