Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.99k stars 559 forks source link

no PERL_IMPLICT_SYS Win32, exactly 4 .. in relative path, DynaLoader loads wrong dll #13680

Open p5pRT opened 10 years ago

p5pRT commented 10 years ago

Migrated from rt.perl.org#121513 (status was 'new')

Searchable as RT121513$

p5pRT commented 10 years ago

From @bulk88

Created by @bulk88

This is a very strange bug\, maybe with Windows XP SP3 specifically but it causes ExtUtils-Constant to fail on no PERL_IMPLICIT_SYS builds. DynaLoader and XSLoader both call win32_dynaload which contains the actual call to the Win OS (LoadLibraryExA). With PerlDir_mapA\, which does something on PERL_IMPLICIT_SYS builds. PerlDir_mapA will convert relative paths "../../lib/auto/something/something.dll" to absolute paths through VDir​::MapPathA. How VDir​::MapPathA converts relative to absolute paths IDK. But anyway. Without PerlDir_mapA\, LoadLibraryExA will get a relative path. Perl uses the flag LOAD_WITH_ALTERED_SEARCH_PATH. On MSDN today the description for the flag is.

--------------------------------------------
C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164>C:\perl519\nothd\bin\perl.
xe "-I..\..\..\lib" t.pl ..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\lib
C:/perl519/nothd/site/lib

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164>C:\perl519\nosys\bin\perl.
xe "-I..\..\..\lib" t.pl ..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\lib
C:/perl519/nosys/site/lib
Can't load '..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownName: lo
d_file:The specified procedure could not be found at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164>C:\perl519\bin\perl.exe
"-
..\..\..\lib" t.pl ..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\lib
C:/perl519/site/lib
Can't load '..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownName: lo
d_file:The specified procedure could not be found at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164>
------------------------------------------

All successful. Now 1 dir down.

------------------------------------------

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa>C:\perl519\nothd\bin\pe
rl.exe "-I..\..\..\..\lib" t.pl ..\..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\..\lib
C:/perl519/nothd/site/lib
Can't load '..\..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownName:
load_file:%1 is not a valid Win32 application at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa>C:\perl519\nosys\bin\pe
rl.exe "-I..\..\..\..\lib" t.pl ..\..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\..\lib
C:/perl519/nosys/site/lib
Can't load '..\..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownName:
load_file:%1 is not a valid Win32 application at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa>C:\perl519\bin\perl.exe
"-I..\..\..\..\lib" t.pl ..\..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\..\lib
C:/perl519/site/lib
Can't load '..\..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownName:
load_file:The specified procedure could not be found at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa>
---------------------------------------------

nothd and nosys failed. With imp sys passed. "is not a valid Win32
application " means the poisoned 0 byte Win32.dll was attempted to be
loaded, that is the ONLY "fail" condition for this bug. Now 1 more dir
down, so we are 5 deep.

---------------------------------------------
C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>C:\perl519\bin\perl
.exe "-I..\..\..\..\..\lib" t.pl ..\..\..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\..\..\lib
C:/perl519/site/lib
Can't load '..\..\..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownNam
e: load_file:The specified procedure could not be found at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>C:\perl519\nothd\bi
n\perl.exe "-I..\..\..\..\..\lib" t.pl
..\..\..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\..\..\lib
C:/perl519/nothd/site/lib

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>C:\perl519\nosys\bi
n\perl.exe "-I..\..\..\..\..\lib" t.pl
..\..\..\..\..\lib\auto\Win32\Win32.dll
INC is
..\..\..\..\..\lib
C:/perl519/nosys/site/lib
Can't load '..\..\..\..\..\lib\auto\Win32\Win32.dll' for module
ThisIsUnknownNam
e: load_file:The specified procedure could not be found at t.pl line 16.
at t.pl line 16.

C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>
----------------------------------------------

All passed.

In ExtUtils-Constant dir "aaa" is "0". But names dont matter\, apparantly only their ".." positions do.

I dont have any ideas what to do about this.

Now for the -V of the 3 perls used above.

Perl Info ``` C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>C:\perl519\nosys\bi n\perl.exe -V Summary of my perl5 (revision 5 version 19 subversion 11) configuration: Derived from: fb9c5a1a0fcfb4a2365d1e1e33b5e738d5ff9302 Platform: osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL -DWIN32 -D_C ONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DPER L_IMPLICIT_CONTEXT -DUSE_PERLIO -D_USE_32BIT_TIME_T', optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL', cppflags='-DWIN32' ccversion='13.10.6030', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksi ze=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg -libpa th:"c:\perl519\nosys\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib" libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.l ib 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 comctl32.lib msvcrt. lib perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg 32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws 2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msv crt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -l tcg -libpath:"c:\perl519\nosys\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Locally applied patches: uncommitted-changes Built under MSWin32 Compiled at Mar 24 2014 00:48:28 @INC: C:/perl519/nosys/site/lib C:/perl519/nosys/lib . ```
Perl Info ``` C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>C:\perl519\nothd\bi n\perl.exe -V Summary of my perl5 (revision 5 version 19 subversion 11) configuration: Derived from: fb9c5a1a0fcfb4a2365d1e1e33b5e738d5ff9302 Platform: osname=MSWin32, osvers=5.1, archname=MSWin32-x86-perlio uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=undef, usemultiplicity=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL -DWIN32 -D_C ONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DUSE _PERLIO -D_USE_32BIT_TIME_T', optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL', cppflags='-DWIN32' ccversion='13.10.6030', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksi ze=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg -libpa th:"c:\perl519\nothd\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib" libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.l ib 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 comctl32.lib msvcrt. lib perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg 32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws 2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msv crt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -l tcg -libpath:"c:\perl519\nothd\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Locally applied patches: uncommitted-changes Built under MSWin32 Compiled at Mar 24 2014 02:25:16 @INC: C:/perl519/nothd/site/lib C:/perl519/nothd/lib . ```
Perl Info ``` C:\sources\dlbug\src\cpan\ExtUtils-Constant\ext-8164\aaa\bbb>C:\perl519\bin\perl .exe -V Summary of my perl5 (revision 5 version 19 subversion 10) configuration: Derived from: 2179658b5e799a6e3c4e736ec7c84b0f50bf3473 Ancestor: e9251c1a8f4944e6dceff5240d9e109ba075ff29 Platform: osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread uname='' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL -DWIN32 -D_C ONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DPERL_HASH_FUNC_ONE_AT_A_TIME -DPER L_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T', optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL', cppflags='-DWIN32' ccversion='13.10.6030', gccversion='', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksi ze=8 alignbytes=8, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf -ltcg -libpa th:"c:\perl519\lib\CORE" -machine:x86' libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib" libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.l ib 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 comctl32.lib msvcrt. lib perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg 32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib ws 2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib comctl32.lib msv crt.lib libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -l tcg -libpath:"c:\perl519\lib\CORE" -machine:x86' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_HASH_FUNC_ONE_AT_A_TIME PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF Locally applied patches: uncommitted-changes 2179658b5e799a6e3c4e736ec7c84b0f50bf3473 Built under MSWin32 Compiled at Mar 15 2014 22:32:09 @INC: C:/perl519/site/lib C:/perl519/lib . ```
p5pRT commented 10 years ago

From @bulk88

dlbug.zip

p5pRT commented 10 years ago

From @bulk88

On Wed Mar 26 17​:13​:50 2014\, bulk88 wrote​:

On MSDN today the description for the flag is.

------------------------------------------- If this value is used and lpFileName specifies an absolute path\, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. If this value is used and lpFileName specifies a relative path\, the behavior is undefined.

If this value is not used\, or if lpFileName does not specify a path\, the system uses the standard search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded.

This value cannot be combined with any LOAD_LIBRARY_SEARCH flag. -------------------------------------------

Forgot to add\, in an old "Longhorn" MSDN\, the no relative paths warning isnt there\,


If this value is used\, and lpFileName specifies a path\, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded.

If this value is not used\, or if lpFileName does not specify a path\, the system uses the standard search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded.


-- bulk88 ~ bulk88 at hotmail.com

p5pRT commented 10 years ago

From @bulk88

This is still a bug in blead/5.21.4 (ran into it again).

-- bulk88 ~ bulk88 at hotmail.com