Skip to content
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

File::Find::find fails on Win32 with follow => 1 #8120

Closed
p5pRT opened this issue Sep 21, 2005 · 11 comments
Closed

File::Find::find fails on Win32 with follow => 1 #8120

p5pRT opened this issue Sep 21, 2005 · 11 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 21, 2005

Migrated from rt.perl.org#37223 (status was 'resolved')

Searchable as RT37223$

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @steve-m-hay

Created by @steve-m-hay

The File​::Find​::find() function fails on Win32 if the "follow => 1"
option is
specified.

The following test script demonstrates the problem​:

use strict;
use warnings;
use Cwd;
use File​::Find;
my $cwd = cwd();
my $dir = '__empty__test__dir__';
my $i = 0;
eval {
  $i++;
  mkdir $dir or die;
  find({wanted => sub { 1 }, follow => 1}, $dir);
  print STDERR "ok $i\n";
  $i++;
  open my $fh, ">$dir/file" or die; close $fh;
  find({wanted => sub { 1 }, follow => 1}, $dir);
  print STDERR "ok $i\n";
  $i++;
  mkdir "$dir/dir" or die;
  find({wanted => sub { 1 }, follow => 1}, $dir);
  print STDERR "ok $i\n";
};
print STDERR "not ok $i​: $@​" if $@​;
END { chdir $cwd; rmdir "$dir/dir"; unlink "$dir/file"; rmdir $dir }

This produces the following output on my Windows XP machine​:

ok 1
ok 2
not ok 3​: C​:/Temp/__empty__test__dir__/dir encountered a second time at
C​:/perl5/lib/File/Find.pm line 560.

Changing the third "follow => 1" to "follow => 0" fixes the failure.

Presumably "follow" (and "follow_fast"?) should be no-ops on Win32 since
symbolic links are not supported on that OS.

Perl Info

Flags:
    category=library
    severity=medium

Site configuration information for perl v5.8.7:

Configured by steveh at Fri Jun  3 11:58:14 2005.

Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
  Platform:
    osname=MSWin32, osvers=5.1, archname=MSWin32-x86-perlio
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=undef usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_DEBUGGING_MSTATS 
-DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='12.00.8804', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=4
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  
-libpath:"C:\perl5\lib\CORE"  -machine:x86'
    libpth=C:\PROGRA~1\MICROS~2\VC98\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib 
odbc32.lib odbccp32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  
version.lib odbc32.lib odbccp32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
    gnulibc_version='undef'
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf  -libpath:"C:\perl5\lib\CORE"  -machine:x86'

Locally applied patches:
    


@INC for perl v5.8.7:
    C:/perl5/lib
    C:/perl5/site/lib
    .


Environment for perl v5.8.7:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\perl5\bin;U:\scripts\batch;C:\Program 
Files\ZipGenius 6\;C:\Program Files\Sybase\SQL Anywhere 
8\win32;C:\Program Files\Sybase\Shared\win32;C:\Program Files\Sybase\SQL 
Anywhere 8\drivers;C:\Program Files\Sybase\Shared\Sybase Central 
4.1;C:\Program Files\Subversion\bin
    PERL_BADLANG (unset)
    SHELL (unset)



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only.  If you have received this message in error or there are any problems, please notify the sender immediately.  The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden.  Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd.  The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.


@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @rgs

Steve Hay (via RT) wrote​:

The File​::Find​::find() function fails on Win32 if the "follow => 1"
option is
specified.

Presumably "follow" (and "follow_fast"?) should be no-ops on Win32 since
symbolic links are not supported on that OS.

Seems quite sensible.
Is this a new problem ? I can't believe nobody noticed it until now...

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @steve-m-hay

Oops! I meant to hit Reply All there.


Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only. If you have received this message in error or there are any problems, please notify the sender immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd. The recipient(s) of this message should check it and any attached files for viruses​: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @steve-m-hay

Message RFC822:
User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)
MIME-Version: 1.0
Subject: Re: [perl #37223] File::Find::find fails on Win32 with follow => 1
In-Reply-To: 20050921165731.0c8b6fde@grubert.mandrakesoft.com
X-Accept-Language: en-us, en
Date: Wed, 21 Sep 2005 16:05:28 +0100
References: rt-37223@perl
rt-3.0.11-37223-121154.12.2056276083332@perl.org
20050921165731.0c8b6fde@grubert.mandrakesoft.com
Message-ID: 433176B8.3000905@uk.radan.com
Content-Type: text/plain; charset="ISO-8859-1"; format="flowed"
To: Rafael Garcia-Suarez rgarciasuarez@mandriva.com
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
From: Steve Hay steve.hay@uk.radan.com
X-RT-Original-Encoding: utf-8
Content-Length: 694

Rafael Garcia-Suarez wrote:

Steve Hay (via RT) wrote:

The File::Find::find() function fails on Win32 if the "follow => 1"
option is
specified.

Presumably "follow" (and "follow_fast"?) should be no-ops on Win32 since
symbolic links are not supported on that OS.

Seems quite sensible.
Is this a new problem ? I can't believe nobody noticed it until now...

On perl-5.8.6 I get this from the test script in the bug report:

not ok 1: The stat preceding -l _ wasn't an lstat at
D:/Perls/perl586/lib/File/Find.pm line 532.

Earlier perls all the way back to 5.6.0 at least all do this too.

They all work if all the "follow => 1"'s are changed.

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @steve-m-hay

Rafael Garcia-Suarez wrote​:

Steve Hay (via RT) wrote​:

The File​::Find​::find() function fails on Win32 if the "follow => 1"
option is
specified.

Presumably "follow" (and "follow_fast"?) should be no-ops on Win32 since
symbolic links are not supported on that OS.

Seems quite sensible.
Is this a new problem ? I can't believe nobody noticed it until now...

On perl-5.8.6 I get this from the test script in the bug report​:

not ok 1​: The stat preceding -l _ wasn't an lstat at
D​:/Perls/perl586/lib/File/Find.pm line 532.

Earlier perls all the way back to 5.6.0 at least all do this too.

They all work if all the "follow => 1"'s are changed.

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @smpeters

On Wed, Sep 21, 2005 at 04​:57​:31PM +0200, Rafael Garcia-Suarez wrote​:

Steve Hay (via RT) wrote​:

The File​::Find​::find() function fails on Win32 if the "follow => 1"
option is
specified.

Presumably "follow" (and "follow_fast"?) should be no-ops on Win32 since
symbolic links are not supported on that OS.

Seems quite sensible.
Is this a new problem ? I can't believe nobody noticed it until now...

If its new, then I'm probably the one who broke it. Can you see which versions
that it is now broken on? Or did it just hit another bug previously.

Steve Peters
steve@​fisharerojo.org

@p5pRT
Copy link
Author

p5pRT commented Sep 21, 2005

From @smpeters

On Wed, Sep 21, 2005 at 10​:29​:25AM -0500, Steve Peters wrote​:

On Wed, Sep 21, 2005 at 04​:57​:31PM +0200, Rafael Garcia-Suarez wrote​:

Steve Hay (via RT) wrote​:

The File​::Find​::find() function fails on Win32 if the "follow => 1"
option is
specified.

Presumably "follow" (and "follow_fast"?) should be no-ops on Win32 since
symbolic links are not supported on that OS.

Seems quite sensible.
Is this a new problem ? I can't believe nobody noticed it until now...

If its new, then I'm probably the one who broke it. Can you see which versions
that it is now broken on? Or did it just hit another bug previously.

Steve Peters
steve@​fisharerojo.org

OK, it looks like there might be a problem with change #23510. I'll take a
look at it when I have a little more time this evening.

Steve Peters
steve@​fisharerojo.org

@p5pRT
Copy link
Author

p5pRT commented Sep 25, 2005

From @smpeters

[stmpeters - Wed Sep 21 08​:45​:33 2005]​:

On Wed, Sep 21, 2005 at 10​:29​:25AM -0500, Steve Peters wrote​:

On Wed, Sep 21, 2005 at 04​:57​:31PM +0200, Rafael Garcia-Suarez
wrote​:

Steve Hay (via RT) wrote​:

The File​::Find​::find() function fails on Win32 if the "follow =>
1"
option is
specified.

Presumably "follow" (and "follow_fast"?) should be no-ops on
Win32 since
symbolic links are not supported on that OS.

Seems quite sensible.
Is this a new problem ? I can't believe nobody noticed it until
now...

If its new, then I'm probably the one who broke it. Can you see
which versions
that it is now broken on? Or did it just hit another bug
previously.

Steve Peters
steve@​fisharerojo.org

OK, it looks like there might be a problem with change #23510. I'll
take a
look at it when I have a little more time this evening.

Hmmm...I backed out that above change to test and the errors were still
there. So, at least I didn't break anything, but I'm not sure what did.

Anyways, since symbolic links aren't available on Win32, below is a
patch to default Win32 to not follow, regardless of what is passed in.
The scary part is that this change allowed all the tests to continue to
pass on Win32.

Inline Patch
--- lib/File/Find.pm.old        Thu Jun 23 11:18:09 2005
+++ lib/File/Find.pm    Sun Sep 25 16:38:47 2005
@@ -603,8 +603,9 @@
     $pre_process       = $wanted->{preprocess};
     $post_process      = $wanted->{postprocess};
     $no_chdir          = $wanted->{no_chdir};
-    $full_check        = $wanted->{follow};
-    $follow            = $full_check || $wanted->{follow_fast};
+    $full_check        = $^O eq 'MSWin32' ? 0 : $wanted->{follow};
+    $follow            = $full_check || $^O eq 'MSWin32' ? 0 : 
+                             $wanted->{follow_fast};
     $follow_skip       = $wanted->{follow_skip};
     $untaint           = $wanted->{untaint};
     $untaint_pat       = $wanted->{untaint_pattern};

  

@p5pRT
Copy link
Author

p5pRT commented Sep 26, 2005

From @steve-m-hay

[stmpeters - Sun Sep 25 14​:41​:02 2005]​:
Anyways, since symbolic links aren't available on Win32, below is a
patch to default Win32 to not follow, regardless of what is passed in.

Thanks. Applied as change 25597 (with a brief mention of the no-op
behaviour in the docs).

The scary part is that this change allowed all the tests to continue to
pass on Win32.

Why shouldn't it? The really scary part is that the tests passed
*before* this change, when the find() function was broken on Win32!

@p5pRT
Copy link
Author

p5pRT commented Sep 26, 2005

@steve-m-hay - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant