On 2025-02-18 14:07:36 +0100, Vincent Lefevre wrote:
> On 2025-02-18 13:49:18 +0100, Vincent Lefevre wrote:
> > FYI, I can also reproduce this issue on my Samsung Galaxy S23 Ultra
> > phone under Termux/Android. Similarly, running the Perl script with
> > "strace -f" also yields a lot of stat failures.
> 
> I can also reproduce it under macOS (cfarm104.cfarm.net), so I'm
> wondering whether the bug could actually be in Perl. But in any case,
> I don't understand how this couldn't be a bug in the Linux kernel,
> according to the strace output.

Hmm... There's a fchdir in the strace output. If the current directory
is global to the process, this could be an issue. I now really suspect
a bug in perl.

If I change my script to do

opendir DIR, $dir or die "$0: opendir failed ($!)\n";
my @files = readdir DIR;
foreach my $file (@files)
  {
    $nthreads < $maxthreads or join_threads;
    $nthreads++ < $maxthreads or die "$0: internal error\n";
    threads->create(\&stat_test, $file);
  }
closedir DIR or die "$0: closedir failed ($!)\n";

then the failures still occur.

But if I then move the closedir as follows

opendir DIR, $dir or die "$0: opendir failed ($!)\n";
my @files = readdir DIR;
closedir DIR or die "$0: closedir failed ($!)\n";
foreach my $file (@files)
  {
    $nthreads < $maxthreads or join_threads;
    $nthreads++ < $maxthreads or die "$0: internal error\n";
    threads->create(\&stat_test, $file);
  }

the failures no longer occur.

-- 
Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)

Reply via email to