File::Find find() with follow_fast => 1 doesn't always detect cycles as the documentation states
Needs Triage
Module: File::Find
**Description**
<!-- A clear and concise description of what the bug is. -->
I have a case where this find() call:
```
find({ wanted => sub { ; }, follow => 1, follow_skip => 1 }, '.');
```
Reports an error including this text:
```
encountered a second time at /home/bkerin/.plenv/versions/5.42.0/lib/perl5/5.42.0/File/Find.pm line 115
```
But if `follow => 1` in the call is replaced with `follow_fast => 1` no error occurs.
So I think this part of the documentation is wrong:
```
"follow_fast"
This is similar to "follow" except that it may report some files more than once. It does detect cycles, however. Since only symbolic links have to be hashed, this is much cheaper both in space and time. If processing
a file more than once (by the user's wanted() function) is worse than just taking time, the option "follow" should be used.
```
Assuming I'm correct that this error is how find() reports a cycle, it appears that follow can at least in some situations detect cycles that follow_fast doesn't.
I'll fill in the below steps with the best isolation in anyone cares enough to ask.
**Steps to Reproduce**
<!-- A one-liner or script to reproduce the issue. -->
I'll isolate as best I can and provide this if anyone cares enough to ask.
**Expected behavior**
<!-- A clear and concise description of what you expected to happen. -->
The same error for cycles under both follow and follow_fast as documented.
**Perl configuration**
<!-- Please paste `perl -V` output just below. -->
```
Summary of my perl5 (revision 5 version 42 subversion 0) configuration:
Platform:
osname=linux
osvers=6.8.0-58-generic
archname=x86_64-linux
uname='linux brittons-large-vivobook 6.8.0-58-generic #60~22.04.1-ubuntu smp preempt_dynamic fri mar 28 16:09:21 utc 2 x86_64 x86_64 x86_64 gnulinux '
config_args='-Dprefix=/home/bkerin/.plenv/versions/5.42.0 -de -Dversiononly -A'eval:scriptdir=/home/bkerin/.plenv/versions/5.42.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 ='-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='11.4.0'
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=/home/bkerin/opt/geda_full_stack/lib /home/bkerin/local/lib /usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /usr/lib64
libs=-lpthread -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=/lib/x86_64-linux-gnu/libc.so.6
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.35'
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'
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 linux
Compiled at Aug 18 2025 04:48:59
@INC:
/home/bkerin/.plenv/versions/5.42.0/lib/perl5/site_perl/5.42.0/x86_64-linux
/home/bkerin/.plenv/versions/5.42.0/lib/perl5/site_perl/5.42.0
/home/bkerin/.plenv/versions/5.42.0/lib/perl5/5.42.0/x86_64-linux
/home/bkerin/.plenv/versions/5.42.0/lib/perl5/5.42.0
```
0 条评论