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

Bug in File::Find on Windows when target dir is bare drive letter and no_chdir = 1 #8788

Closed
p5pRT opened this issue Feb 20, 2007 · 11 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Feb 20, 2007

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

Searchable as RT41555$

@p5pRT
Copy link
Author

p5pRT commented Feb 20, 2007

From johndporter@yahoo.com

Created by johndporter@yahoo.com

Bug in File​::Find on Windows when target dir is bare drive letter and
no_chdir = 1

This bug is not elicited when the target (search) directory has any
path info (i.e. slashes) in it, nor when no_chdir = 0 (the default).

To demonstrate, make a directory named Windows somewhere on C​: (or
wherever your Windows installation is) OTHER THAN in the root
directory (you wouldn't be able to anyway, since \Windows already
exists), and put a small amount of known stuff in it, e.g. one
subdirectory named foo. Make that directory (the one containing your
fake Windows) the currently logged directory on that drive​:

  cd /d c​:\

  mkdir test\windows\foo

  cd test

Now go to a different drive (pick one you have; it doesn't matter
which)​:

  cd /d d​:\

and execute the following Perl test script. Note that the target
directory is the bare drive C​: with no path info (slashes)​:

  perl -MFile​::Find -e "$\=$/; find( sub { print if -d }, 'c​:' );"

Output is just as you'd expect​:

  .
  windows
  foo

Now run the following, which is identical except that no_chdir is
turned on​:

  perl -MFile​::Find -e "$\=$/; find({ no_chdir => 1, wanted => sub {
print if -d } }, 'c​:' );"

You get erroneous output​:

  . . .
  c​:/windows/$hf_mig$/KB898461/update
  c​:/windows/$MSI31Uninstall_KB893803$
  c​:/windows/$MSI31Uninstall_KB893803$/spuninst
  c​:/windows/$NtServicePackUninstall$
  c​:/windows/$NtServicePackUninstall$/spuninst
  c​:/windows/$NtUninstallKB816486$
  . . .
  c​:/windows/ADDINS
  c​:/windows/AppPatch
  c​:/windows/assembly
  c​:/windows/assembly/GAC_32
  c​:/windows/assembly/GAC_32/CustomMarshalers
  . . .

It appears that if find() finds, in the target directory, a
subdirectory named X, it searches in C​:\X, even though the target
directory is not C​:\.

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.8:

Configured by SYSTEM at Tue Aug 29 12:39:43 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=MSWin32, osvers=5.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED
-DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-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='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth=\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=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    Iin_load_module moved for compatibility with build 806
    Avoid signal flag SA_RESTART for older versions of HP-UX
    PerlEx support in CGI::Carp
    Less verbose ExtUtils::Install and Pod::Find
    Patch for CAN-2005-0448 from Debian with modifications
    Rearrange @INC so that 'site' is searched before 'perl'
    Partly reverted 24733 to preserve binary compatibility
    28671 Define PERL_NO_DEV_RANDOM on Windows
    28376 Add error checks after execing PL_cshname or PL_sh_path
    28305 Pod::Html should not convert \"foo\" into ``foo''
    27736 Make perl_fini() run with Sun WorkShop compiler
    27619 Bug in Term::ReadKey being triggered by a bug in
Term::ReadLine
    27549 Move DynaLoader.o into libperl.so
    27528 win32_pclose() error exit doesn't unlock mutex
    27527 win32_async_check() can loop indefinitely
    27515 ignore directories when searching @INC
    27359 Fix -d:Foo=bar syntax
    27210 Fix quote typo in c2ph
    27203 Allow compiling swigged C++ code
    27200 Make stat() on Windows handle trailing slashes correctly
    27194 Get perl_fini() running on HP-UX again
    27133 Initialise lastparen in the regexp structure
    27034 Avoid \"Prototype mismatch\" warnings with autouse
    26970 Make Passive mode the default for Net::FTP
    26921 Avoid getprotobyname/number calls in IO::Socket::INET
    26897,26903 Make common IPPROTO_* constants always available
    26670 Make '-s' on the shebang line parse -foo=bar switches
    26536 INSTALLSCRIPT versus INSTALLDIRS
    26379 Fix alarm() for Windows 2003
    26087 Storable 0.1 compatibility
    25861 IO::File performace issue
    25084 long groups entry could cause memory exhaustion
    24699 ICMP_UNREACHABLE handling in Net::Ping


@INC for perl v5.8.8:
    C:/Perl/site/lib
    C:/Perl/lib
    .


Environment for perl v5.8.8:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Windows Resource
Kits\Tools\;C:\Perl\bin\;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Sun\AppServer\bin
    PERL_BADLANG (unset)
    SHELL (unset)



 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com

@p5pRT
Copy link
Author

p5pRT commented Feb 20, 2007

From johndporter@yahoo.com

Created by johndporter@yahoo.com

Bug in File​::Find on Windows when target dir is bare drive letter and no_chdir => 1

This bug is not elicited when the target (search) directory has any path info (i.e. slashes) in it, nor when no_chdir = 0 (the default).

To demonstrate, make a directory named Windows somewhere on C​: (or wherever your Windows installation is) OTHER THAN in the root directory (you wouldn't be able to anyway, since \Windows already exists), and put a small amount of known stuff in it, e.g. one subdirectory named foo. Make that directory (the one containing your fake Windows) the currently logged directory on that drive​:

  cd /d c​:\

  mkdir test\windows\foo

  cd test

Now go to a different drive (pick one you have; it doesn't matter which)​:

  cd /d d​:\

and execute the following Perl test script. Note that the target directory is the bare drive C​: with no path info (slashes)​:

  perl -MFile​::Find -e "$\=$/; find( sub { print if -d }, 'c​:' );"

Output is just as you'd expect​:

  .
  windows
  foo

Now run the following, which is identical except that no_chdir is turned on​:

  perl -MFile​::Find -e "$\=$/; find({ no_chdir => 1, wanted => sub { print if -d } }, 'c​:' );"

You get erroneous output​:

  . . .
  c​:/windows/$hf_mig$/KB898461/update
  c​:/windows/$MSI31Uninstall_KB893803$
  c​:/windows/$MSI31Uninstall_KB893803$/spuninst
  c​:/windows/$NtServicePackUninstall$
  c​:/windows/$NtServicePackUninstall$/spuninst
  c​:/windows/$NtUninstallKB816486$
  . . .
  c​:/windows/ADDINS
  c​:/windows/AppPatch
  c​:/windows/assembly
  c​:/windows/assembly/GAC_32
  c​:/windows/assembly/GAC_32/CustomMarshalers
  c​:/windows/assembly/GAC_32/CustomMarshalers/2.0.0.0__b03f5f7f11d50a3a
  . . .

It appears that if find() finds, in the target directory, a subdirectory named X, it searches in C​:\X, even though the target directory is not C​:\.

Perl Info

Flags:
    category=library
    severity=low

Site configuration information for perl v5.8.8:

Configured by SYSTEM at Tue Aug 29 12:39:43 2006.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=MSWin32, osvers=5.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DNO_HASH_SEED -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -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='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth=\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=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY
    Iin_load_module moved for compatibility with build 806
    Avoid signal flag SA_RESTART for older versions of HP-UX
    PerlEx support in CGI::Carp
    Less verbose ExtUtils::Install and Pod::Find
    Patch for CAN-2005-0448 from Debian with modifications
    Rearrange @INC so that 'site' is searched before 'perl'
    Partly reverted 24733 to preserve binary compatibility
    28671 Define PERL_NO_DEV_RANDOM on Windows
    28376 Add error checks after execing PL_cshname or PL_sh_path
    28305 Pod::Html should not convert \"foo\" into ``foo''
    27736 Make perl_fini() run with Sun WorkShop compiler
    27619 Bug in Term::ReadKey being triggered by a bug in Term::ReadLine
    27549 Move DynaLoader.o into libperl.so
    27528 win32_pclose() error exit doesn't unlock mutex
    27527 win32_async_check() can loop indefinitely
    27515 ignore directories when searching @INC
    27359 Fix -d:Foo=bar syntax
    27210 Fix quote typo in c2ph
    27203 Allow compiling swigged C++ code
    27200 Make stat() on Windows handle trailing slashes correctly
    27194 Get perl_fini() running on HP-UX again
    27133 Initialise lastparen in the regexp structure
    27034 Avoid \"Prototype mismatch\" warnings with autouse
    26970 Make Passive mode the default for Net::FTP
    26921 Avoid getprotobyname/number calls in IO::Socket::INET
    26897,26903 Make common IPPROTO_* constants always available
    26670 Make '-s' on the shebang line parse -foo=bar switches
    26536 INSTALLSCRIPT versus INSTALLDIRS
    26379 Fix alarm() for Windows 2003
    26087 Storable 0.1 compatibility
    25861 IO::File performace issue
    25084 long groups entry could cause memory exhaustion
    24699 ICMP_UNREACHABLE handling in Net::Ping


@INC for perl v5.8.8:
    C:/Perl/site/lib
    C:/Perl/lib
    .


Environment for perl v5.8.8:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Windows Resource Kits\Tools\;c:\program files\imagemagick-6.2.8-q16;C:\Program Files\MKS\IntegrityClient\bin;c:\ruby\bin;c:\progra~1\vim\vim63;C:\Perl\bin\;C:\PROGRA~1\MICROS~3\VSS\WIN32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Subversion\bin;C:\ocaml\bin;C:\PROGRA~1\ATT\Graphviz\bin;;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Sun\AppServer\bin
    PERL_BADLANG (unset)
    SHELL (unset)

@p5pRT
Copy link
Author

p5pRT commented Apr 30, 2008

From p5p@spam.wizbit.be

On Tue Feb 20 09​:39​:44 2007, johndporter@​yahoo.com wrote​:

Bug in File​::Find on Windows when target dir is bare drive letter and
no_chdir = 1

[...]

perl \-MFile​::Find \-e "$\\=$/; find\(\{ no\_chdir => 1\, wanted => 

sub {

print if -d } }, 'c​:' );"

Patch attached.

File​::Find turned c​: into c​:/ (which is a completly different path).

No tests for it added. (No idea how this can be tested automatically)

Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented Apr 30, 2008

From p5p@spam.wizbit.be

patch_File.pm

@p5pRT
Copy link
Author

p5pRT commented Apr 30, 2008

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

@p5pRT
Copy link
Author

p5pRT commented Apr 30, 2008

p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'

@p5pRT p5pRT closed this as completed Apr 30, 2008
@p5pRT
Copy link
Author

p5pRT commented May 5, 2008

From david@landgren.net

Bram via RT wrote​:

On Tue Feb 20 09​:39​:44 2007, johndporter@​yahoo.com wrote​:

Bug in File​::Find on Windows when target dir is bare drive letter and
no_chdir = 1

[...]

perl \-MFile​::Find \-e "$\\=$/; find\(\{ no\_chdir => 1\, wanted => 

sub {

print if -d } }, 'c​:' );"

Patch attached.

File​::Find turned c​: into c​:/ (which is a completly different path).

No tests for it added. (No idea how this can be tested automatically)

Without looking at what you can recycle from the current test suite...

Create a subdir on the current drive (might be D​:, E​: or other),
populate it with two or three temp files in a couple of subdirs, chdir
to the first subdir and then go and File​::Find them using C​: as your
starting point.

You may need to skip if $^O ne 'Win32'.

David

@p5pRT
Copy link
Author

p5pRT commented May 12, 2008

From p5p@perl.wizbit.be

Patch with test attached.

(Original patch attached as well - since it has not yet been applied)
Kind regards,

Bram

@p5pRT
Copy link
Author

p5pRT commented May 12, 2008

From p5p@perl.wizbit.be

patch_Find.pm

@p5pRT
Copy link
Author

p5pRT commented May 16, 2008

From @rgs

Looks good to apply. (assuming the test pass on windows, but smokes
are here to find out)

2008/5/12 Bram <p5p@​perl.wizbit.be>​:

Patch with test attached.

(Original patch attached as well - since it has not yet been applied)
Kind regards,

Bram

--
'Do you know what they called a sausage-in-a-bun in Quirm?' said Mr Pin,
as the two walked away. --- 'No?' said Mr Tulip. --- 'They called it "le
sausage-in-le-bun".' -- Terry Pratchett, The Truth

@p5pRT
Copy link
Author

p5pRT commented May 23, 2008

From @rgs

2008/5/12 Bram <p5p@​perl.wizbit.be>​:

Patch with test attached.

Thanks, applied as #33911.

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