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

Failure testing libapreq2 with perl-5.38.0-RC2 #21179

Closed
steve-m-hay opened this issue Jun 27, 2023 · 12 comments · Fixed by #21182
Closed

Failure testing libapreq2 with perl-5.38.0-RC2 #21179

steve-m-hay opened this issue Jun 27, 2023 · 12 comments · Fixed by #21182

Comments

@steve-m-hay
Copy link
Contributor

In the course of testing perl-5.38.0-RC2 I have run into a failure in the test suite of libapreq2:

The Apache httpd server used for running this module's glue\perl\t tests crashes on start up. The server is started with the command: D:\Dev\Temp\apache\bin\httpd.exe -d D:/Dev/Temp/libapreq2-2.17/glue/perl/t -f D:/Dev/Temp/libapreq2-2.17/glue/perl/t/conf/httpd.conf -D APACHE2 -D APACHE2_4 -D PERL_USEITHREADS

Debugging that command, I find that it fails in perl's my_CloseHandle() in win32\win32.c. That function was quite recently added by commit 8552f09 in March this year. The error (from a release build with debug info) is:

Exception thrown at 0x0000000000000000 in httpd.exe: 0xC0000005: Access violation executing location 0x0000000000000000.

0000000000000000()	Unknown

perl538.dll!my_CloseHandle(void * h) Line 5305 C
[External Code]
libapr-1.dll!apr_file_dup2(apr_file_t * new_file, apr_file_t * old_file, apr_pool_t * p) Line 133 C
libhttpd.dll!winnt_pre_config(apr_pool_t * pconf_, apr_pool_t * plog, apr_pool_t * ptemp) Line 1412 C
libhttpd.dll!ap_run_pre_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp) Line 88 C
httpd.exe!main(int argc, const char * const * argv) Line 797 C
[External Code]

The httpd server starts and all of the libapreq2 tests pass if I replace perl-5.38.0-RC2 with perl-5.36.1, keeping everything else the same.

Version numbers of everything used are as follows:
Microsoft Visual Studio Professional 2022 (64-bit) LTSC 17.4 Version 17.4.8 on Windows 10 Enterprise Version 22H2
perl-5.38.0-RC2 (perl -V output is below)
Apache httpd-2.4.57 (with pcre-8.45, expat-2.5.0, apr-1.7.4, and apr-util-1.6.3)
mod_perl-2.0.12 (with Win32-Process-0.17, the latest apxs, and the do_open9() fix from CPAN RT#148451)
libapreq2-2.17 (with Parse-RecDescent-1.967015, Tie-IxHash-1.23, and ExtUtils-XSBuilder-0.28)

All build options (apart from some install locations) are out-of-the-box. I can assist if anyone is willing and able to look at this but has trouble building any of these things.

Similar tests using the Apache httpd server have run and passed during the earlier build of mod_perl, so it is possible that it is something being done by libapreq2 that is at fault, but it's troubling from perl's perspective that no problem is seen when switching to perl-5.3.6.1 with everything else the same.

perl -V output:

Summary of my perl5 (revision 5 version 38 subversion 0) configuration:

Platform:
osname=MSWin32
osvers=10.0.19045.3086
archname=MSWin32-x64-multi-thread
uname=''
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cl'
ccflags ='-nologo -GF -W3 -MD -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS'
optimize='-O1 -Zi -GL -fp:precise'
cppflags='-DWIN32'
ccversion='19.34.31946'
gccversion=''
gccosandvers=''
intsize=4
longsize=4
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=undef
longlongsize=8
d_longdbl=define
longdblsize=8
longdblkind=0
ivtype='__int64'
ivsize=8
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 -ltcg -libpath:"D:\Dev\Temp\perl\lib\CORE" -machine:AMD64 -subsystem:console,"5.02"'
libpth="C:\Program Files\Microsoft Visual Studio\2022 17.4\Professional\VC\Tools\MSVC\14.34.31933\lib\x64"
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 comctl32.lib msvcrt.lib vcruntime.lib ucrt.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 comctl32.lib msvcrt.lib vcruntime.lib ucrt.lib
libc=ucrt.lib
so=dll
useshrplib=true
libperl=perl538.lib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs
dlext=dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf -ltcg -libpath:"D:\Dev\Temp\perl\lib\CORE" -machine:AMD64 -subsystem:console,"5.02"'

Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_TIMES
HAVE_INTERP_INTERN
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_SAFE_PUTENV
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_THREAD_SAFE_LOCALE
Locally applied patches:
RC2
Built under MSWin32
Compiled at Jun 27 2023 08:07:13
@inc:
D:/Dev/Temp/perl/site/lib
D:/Dev/Temp/perl/lib

@xenu
Copy link
Member

xenu commented Jun 27, 2023

If you upload debug binaries of everything somewhere, I can look into it. Building apache is a painful and pretty much undocumented process.

@steve-m-hay
Copy link
Contributor Author

If you upload debug binaries of everything somewhere, I can look into it. Building apache is a painful and pretty much undocumented process.

Unfortunately, the mod_perl build is failing with debug builds of everything due to 3 unresolved externals:

libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_RV
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_IV_set
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_NV_set

It was (obviously) fine with release builds. I haven't seen this before and I currently have no idea what the problem is. I will try it again tomorrow.

@tonycoz
Copy link
Contributor

tonycoz commented Jun 28, 2023

Unfortunately, the mod_perl build is failing with debug builds of everything due to 3 unresolved externals:

libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_RV
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_IV_set
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_NV_set

A build with CFG=DebugSymbols should prevent the references to those symbols and be debuggable.

If I build blead with CFG=Debug the generated dll exports the above symbols and the import library also includes them.

My first though is that perhaps somehow the symbol isn't marked as an import, which for a data reference would generate code referencing __imp_PL_valid_types_RV. I'd expect the errors to use those names, though perhaps Microsoft have made the errors more friendly.

If you could get the preprocessed version of modperl_error.c, hopefully with nmake modperl_error.i in the right directory, it should be possible to see whether that's the case here. I tried looking through the mod_perl source but nothing leapt out at me.

@steve-m-hay
Copy link
Contributor Author

If you could get the preprocessed version of modperl_error.c, hopefully with nmake modperl_error.i in the right directory, it should be possible to see whether that's the case here. I tried looking through the mod_perl source but nothing leapt out at me.

Attached.
modperl_error.txt

For reference, this is the command that was run during the build process to compile modperl_error.c:

cl -ID:/Dev/Temp/mod_perl-2.0.12/src/modules/perl -ID:/Dev/Temp/mod_perl-2.0.12/xs -ID:\Dev\Temp\apache\include -I"D:\Dev\Temp\apache\include" -ID:\Dev\Temp\apache\include -nologo -GF -W3 -MDd -DWIN32 -D_CONSOLE -DNO_STRICT -D_DEBUG -DDEBUGGING -DWIN64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -I"D:\Dev\Temp\perl\lib\CORE" -DMOD_PERL -DMP_COMPAT_1X -DMP_TRACE -Od -Zi -fp:precise -c modperl_error.c

@steve-m-hay
Copy link
Contributor Author

A build with CFG=DebugSymbols should prevent the references to those symbols and be debuggable.

Using debug builds of PCRE, Expat, apr, apr-util and httpd I find that mod_perl fails to build if perl is built in Debug (or DebugFull) configuration due to the valid_types_* unresolved symbols mentioned above.

So I had to use a DebugSymbols (or default (release)) build of perl. mod_perl then builds, but the problem disappears: libapreq2 passes all tests.

Reverting to default (release) builds of PCRE, Expat, apr, apr-util and httpd I again find that mod_perl fails to build if perl is built in Debug (or DebugFull) configuration due to the valid_types_* unresolved symbols.

So again I had to use a DebugSymbols build of perl. mod_perl then builds (as it did originally with a default (release) build of perl), and fortunately the problem still manifests itself: libapreq2's test suite crashes when starting up the httpd server.

I have breakpoints on lines 5304 (the last line of my_CloseHandle(), which calls CloseHandle_orig(h)) and 5327 (the return in win32_hook_closehandle_in_crt() if the attemnpt to get the CloseHandle_orig handle has failed) of perl's win32\win32.c.

I also have a breakpoint on line 132 (the _dup2(fd, 1) call in apr_file_dup2(), conditional on fd==3) of apr's file_io\win32\filedup.c.

The apr breakpoint is hit first, with this call stack:

libapr-1.dll!apr_file_dup2(apr_file_t * new_file, apr_file_t * old_file, apr_pool_t * p) Line 132 C
libhttpd.dll!winnt_pre_config(apr_pool_t * pconf_, apr_pool_t * plog, apr_pool_t * ptemp) Line 1412 C
libhttpd.dll!ap_run_pre_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp) Line 88 C
httpd.exe!main(int argc, const char * const * argv) Line 702 C

This does not result in a call to my_CloseHandle().

Continuing, it then hits the breakpoint on the CloseHandle_orig(h) call ten times, and the lands on the apr breakpoint again, again with this call stack:

libapr-1.dll!apr_file_dup2(apr_file_t * new_file, apr_file_t * old_file, apr_pool_t * p) Line 132 C
libhttpd.dll!winnt_pre_config(apr_pool_t * pconf_, apr_pool_t * plog, apr_pool_t * ptemp) Line 1412 C
libhttpd.dll!ap_run_pre_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp) Line 88 C
httpd.exe!main(int argc, const char * const * argv) Line 797 C

However, stepping over the _dup2() call this time results in my_CloseHandle() getting called:

perl538.dll!my_CloseHandle(void * h) Line 5304 C
[External Code]
libapr-1.dll!apr_file_dup2(apr_file_t * new_file, apr_file_t * old_file, apr_pool_t * p) Line 133 C
libhttpd.dll!winnt_pre_config(apr_pool_t * pconf_, apr_pool_t * plog, apr_pool_t * ptemp) Line 1412 C
libhttpd.dll!ap_run_pre_config(apr_pool_t * pconf, apr_pool_t * plog, apr_pool_t * ptemp) Line 88 C
httpd.exe!main(int argc, const char * const * argv) Line 797 C

The crash occurs because this time CloseHandle_orig is 0x0000000000000000, which it hadn't been on the ten previous hits on this breakpoint.

At no point did the line 5327 breakpoint get hit, which could have explained why CloseHandle_orig is 0x0000000000000000 so I don't know why CloseHandle_orig has become 0x0000000000000000.

I also didn't necessarily expect perl's my_CloseHandle() function to be getting called from other (non-perl) code like this. Is that intentional?

Repeating the same debugging (same command-line and same breakpoints) with the build in which the problem disappeared (i.e. perl is still the DebugSymbols configuration, but everything else is a debug build rather than default (release) builds), I again get one hit on the apr breakpoint (not followed by a call to my_CloseHandle()), followed by ten hits on the CloseHandle_orig(h) call, followed by another hit on the apr breakpoint and this time that is NOT followed by a call to my_CloseHandle(), which is what caused the crash above.

I'm struggling to understand this. Why is code in apr_file_dup2() sometimes resulting in perl's my_CloseHandle() function getting called? And why does that only seem to happen when using release builds of httpd et al?

I've uploaded builds of everything in both flavours here: https://people.apache.org/~stevehay/.private/

The libapreq2-release-builds.zip file contains default (release) builds of everything, except perl - which is the DebugSymbols mode.
The libapreq2-debug-builds.zip file contains debug builds of everything (with perl in the DebugSymbols mode again).

xenu added a commit to xenu/perl5 that referenced this issue Jun 28, 2023
In some embedded Perl scenarios, such as mod_perl, the Perl DLL
may be unloaded, causing the hook to become invalid.

Fixes: Perl#21179
@xenu
Copy link
Member

xenu commented Jun 28, 2023

I also didn't necessarily expect perl's my_CloseHandle() function to be getting called from other (non-perl) code like this. Is that intentional?

Yes, we patch CRT in-memory to redirect all calls to CloseHandle() inside CRT to my_CloseHandle().

Anyway, I think I have a fix: #21182.

Basically, the problem was that Apache does some shenanigans with loading and unloading the Perl DLL and our hooking code wasn't prepared to handle this.

@steve-m-hay
Copy link
Contributor Author

Anyway, I think I have a fix: #21182.

Basically, the problem was that Apache does some shenanigans with loading and unloading the Perl DLL and our hooking code wasn't prepared to handle this.

Excellent! Thanks for this. I can confirm that it fixes the problem for me: With this patch I have perl, mod_perl and libapreq2 all running their tests as usual.

@tonycoz
Copy link
Contributor

tonycoz commented Jun 29, 2023

Attached.
modperl_error.txt

Thanks, it is importing correctly:

extern __declspec(dllimport) const _Bool PL_valid_types_IVX[];
extern __declspec(dllimport) const _Bool PL_valid_types_NVX[];
extern __declspec(dllimport) const _Bool PL_valid_types_PVX[];
extern __declspec(dllimport) const _Bool PL_valid_types_RV[];
extern __declspec(dllimport) const _Bool PL_valid_types_IV_set[];
extern __declspec(dllimport) const _Bool PL_valid_types_NV_set[];

The call making all the references here is the call to newRV_noinc() which is now inlined and its call to newSV_type(), which is also inlined.

Can you show the failing linker command-line?

@tonycoz
Copy link
Contributor

tonycoz commented Jun 29, 2023

Just to check, please ensure lib\CORE\perl538.lib is being rebuilt when you rebuild with CFG=Debug.

@steve-m-hay
Copy link
Contributor Author

perl538.lib is rebuilt, yes. I've been deleting and rebuilding from scratch the perl folder each time I change configuration to avoid any possible mix-ups with things not getting rebuilt.

Here are the compiler and linker commands for the APR::Brigade module, which is the first XS module that the build process fails on:

cl -c -ID:/Dev/Temp/mod_perl-2.0.12/src/modules/perl -ID:/Dev/Temp/mod_perl-2.0.12/xs -ID:\Dev\Temp\apache\include -I"D:\Dev\Temp\apache\include" -ID:\Dev\Temp\apache\include -ID:/Dev/Temp/mod_perl-2.0.12/src/modules/perl -ID:/Dev/Temp/mod_perl-2.0.12/xs -ID:\Dev\Temp\apache\include -ID:\Dev\Temp\apache\include -ID:\Dev\Temp\apache\include -ID:/Dev/Temp/mod_perl-2.0.12/src/modules/perl -ID:/Dev/Temp/mod_perl-2.0.12/xs -ID:\Dev\Temp\apache\include -ID:\Dev\Temp\apache\include -ID:\Dev\Temp\apache\include -ID:/Dev/Temp/mod_perl-2.0.12/src/modules/perl -ID:/Dev/Temp/mod_perl-2.0.12/xs -ID:\Dev\Temp\apache\include -I"D:\Dev\Temp\apache\include" -ID:\Dev\Temp\apache\include -nologo -GF -W3 -MD -DWIN32 -D_CONSOLE -DNO_STRICT -DDEBUGGING -DWIN64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DMOD_PERL -DMP_COMPAT_1X -Od -Zi -fp:precise -DVERSION="0.009000" -DXS_VERSION="0.009000" "-ID:\Dev\Temp\perl\lib\CORE" -DMP_HAVE_APR_LIBS -DMP_HAVE_APR_LIBS -DMP_HAVE_APR_LIBS -DMP_HAVE_APR_LIBS -FdBrigade.pdb Brigade.c
Brigade.c
D:\Dev\Temp\perl\lib\CORE\inline.h(2815): warning C4244: '=': conversion from '__int64' to 'I32', possible loss of data
D:\Dev\Temp\perl\lib\CORE\inline.h(2890): warning C4244: '=': conversion from '__int64' to 'I32', possible loss of data
D:\Dev\Temp\perl\lib\CORE\inline.h(2951): warning C4244: '=': conversion from '__int64' to 'I32', possible loss of data
"D:\Dev\Temp\perl\bin\perl.exe" -MExtUtils::Mksymlists -e "Mksymlists('NAME'=>"APR::Brigade", 'DLBASE' => 'Brigade', 'DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);"
link -out:......\blib\arch\auto\APR\Brigade\Brigade.dll -dll -nologo -nodefaultlib -debug -libpath:"D:\Dev\Temp\perl\lib\CORE" -machine:AMD64 -subsystem:console,"5.02" Brigade.obj -nologo -nodefaultlib -debug -libpath:"D:\Dev\Temp\perl\lib\CORE" -machine:AMD64 -subsystem:console,"5.02" "D:\Dev\Temp\perl\lib\CORE\perl538.lib" "D:\Dev\Temp\mod_perl-2.0.12\blib\arch\auto\libaprext\libaprext.lib" "D:\Dev\Temp\apache\lib\libapr-1.lib" "D:\Dev\Temp\apache\lib\libaprutil-1.lib" "D:\Dev\Temp\apache\lib\libhttpd.lib" "C:\Program Files\Microsoft Visual Studio\2022 17.4\Professional\VC\Tools\MSVC\14.34.31933\lib\x64\oldnames.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\kernel32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\user32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\gdi32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\winspool.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\comdlg32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\advapi32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\shell32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\ole32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\oleaut32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\netapi32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\uuid.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\ws2_32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\mpr.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\winmm.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\version.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\odbc32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\odbccp32.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\um\x64\comctl32.lib" "C:\Program Files\Microsoft Visual Studio\2022 17.4\Professional\VC\Tools\MSVC\14.34.31933\lib\x64\msvcrt.lib" "C:\Program Files\Microsoft Visual Studio\2022 17.4\Professional\VC\Tools\MSVC\14.34.31933\lib\x64\vcruntime.lib" "C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64\ucrt.lib" -def:Brigade.def
Creating library ......\blib\arch\auto\APR\Brigade\Brigade.lib and object ......\blib\arch\auto\APR\Brigade\Brigade.exp
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_RV
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_IV_set
libaprext.lib(modperl_error.obj) : error LNK2001: unresolved external symbol PL_valid_types_NV_set
......\blib\arch\auto\APR\Brigade\Brigade.dll : fatal error LNK1120: 3 unresolved externals

That was with a standard CFG=Debug configuration build of perl, for which perl -V is:

Summary of my perl5 (revision 5 version 38 subversion 0) configuration:

Platform:
osname=MSWin32
osvers=10.0.19045.3086
archname=MSWin32-x64-multi-thread
uname=''
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cl'
ccflags ='-nologo -GF -W3 -MD -DWIN32 -D_CONSOLE -DNO_STRICT -DDEBUGGING -DWIN64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS'
optimize='-Od -Zi -fp:precise'
cppflags='-DWIN32'
ccversion='19.34.31946'
gccversion=''
gccosandvers=''
intsize=4
longsize=4
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=undef
longlongsize=8
d_longdbl=define
longdblsize=8
longdblkind=0
ivtype='__int64'
ivsize=8
nvtype='double'
nvsize=8
Off_t='__int64'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='link'
ldflags ='-nologo -nodefaultlib -debug -libpath:"D:\Dev\Temp\perl\lib\CORE" -machine:AMD64 -subsystem:console,"5.02"'
libpth="C:\Program Files\Microsoft Visual Studio\2022 17.4\Professional\VC\Tools\MSVC\14.34.31933\lib\x64"
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 comctl32.lib msvcrt.lib vcruntime.lib ucrt.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 comctl32.lib msvcrt.lib vcruntime.lib ucrt.lib
libc=ucrt.lib
so=dll
useshrplib=true
libperl=perl538.lib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_win32.xs
dlext=dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-dll -nologo -nodefaultlib -debug -libpath:"D:\Dev\Temp\perl\lib\CORE" -machine:AMD64 -subsystem:console,"5.02"'

Characteristics of this binary (from libperl):
Compile-time options:
DEBUGGING
HAS_LONG_DOUBLE
HAS_TIMES
HAVE_INTERP_INTERN
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_TRACK_MEMPOOL
PERL_USE_SAFE_PUTENV
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
USE_THREAD_SAFE_LOCALE
Locally applied patches:
RC2
Built under MSWin32
Compiled at Jun 29 2023 08:50:56
@inc:
D:/Dev/Temp/perl/site/lib
D:/Dev/Temp/perl/lib

@tonycoz
Copy link
Contributor

tonycoz commented Jun 29, 2023

Does the installed perl538.dll have the needed exports?

C:\Users\Tony\dev\perl\git\perl\win32>dumpbin /exports ..\perl538.dll | find "valid_types"
        115   72 00813B78 PL_valid_types_IVX = PL_valid_types_IVX
        116   73 00815000 PL_valid_types_IV_set = PL_valid_types_IV_set
        117   74 00814298 PL_valid_types_NVX = PL_valid_types_NVX
        118   75 00815018 PL_valid_types_NV_set = PL_valid_types_NV_set
        119   76 00814448 PL_valid_types_PVX = PL_valid_types_PVX
        120   77 008144C8 PL_valid_types_RV = PL_valid_types_RV

Does the installed library include the needed exports?

C:\Users\Tony\dev\perl\git\perl\win32>dumpbin /exports ..\lib\CORE\perl538.lib | find "valid_types"
                  PL_valid_types_IVX
                  PL_valid_types_IV_set
                  PL_valid_types_NVX
                  PL_valid_types_NV_set
                  PL_valid_types_PVX
                  PL_valid_types_RV

Does the perlldll.def file in the build directory include the needed exports?

C:\Users\Tony\dev\perl\git\perl\win32>find "valid_types" perldll.def

---------- PERLDLL.DEF
        PL_valid_types_IVX DATA
        PL_valid_types_IV_set DATA
        PL_valid_types_NVX DATA
        PL_valid_types_NV_set DATA
        PL_valid_types_PVX DATA
        PL_valid_types_RV DATA

Given the paths in your build log you probably want:

dumpbin /exports D:\Dev\Temp\perl\bin\perl538.dll | find "valid_types"
dumpbin /exports D:\Dev\Temp\perl\lib\CORE\perl538.lib | find "valid_types"

If any of those is missing the symbols, please try building from a fresh tree (git clean -dxfq .. from the win32/ directory in a git clone is fine).

@steve-m-hay
Copy link
Contributor Author

None of those are missing the symbols:

D:\Dev\Temp\mod_perl-2.0.12>dumpbin /exports D:\Dev\Temp\perl\bin\perl538.dll | find "valid_types"
115 72 004E9028 PL_valid_types_IVX = PL_valid_types_IVX
116 73 004EA4B0 PL_valid_types_IV_set = PL_valid_types_IV_set
117 74 004E9748 PL_valid_types_NVX = PL_valid_types_NVX
118 75 004EA4C8 PL_valid_types_NV_set = PL_valid_types_NV_set
119 76 004E98F8 PL_valid_types_PVX = PL_valid_types_PVX
120 77 004E9978 PL_valid_types_RV = PL_valid_types_RV

D:\Dev\Temp\mod_perl-2.0.12>dumpbin /exports D:\Dev\Temp\perl\lib\CORE\perl538.lib | find "valid_types"
PL_valid_types_IVX
PL_valid_types_IV_set
PL_valid_types_NVX
PL_valid_types_NV_set
PL_valid_types_PVX
PL_valid_types_RV

D:\Dev\Temp\mod_perl-2.0.12>cd ..\perl-5.38.0-RC2\win32

D:\Dev\Temp\perl-5.38.0-RC2\win32>find "valid_types" perldll.def

---------- PERLDLL.DEF
PL_valid_types_IVX DATA
PL_valid_types_IV_set DATA
PL_valid_types_NVX DATA
PL_valid_types_NV_set DATA
PL_valid_types_PVX DATA
PL_valid_types_RV DATA

All of the build folders (perl, mod_perl, httpd etc.) are freshly extracted from their respective .tar.gz files, and have been installed into fresh locations (i.e. not over the top of any existing installations).

rjbs pushed a commit that referenced this issue Jun 30, 2023
In some embedded Perl scenarios, such as mod_perl, the Perl DLL
may be unloaded, causing the hook to become invalid.

Fixes: #21179
khwilliamson pushed a commit to khwilliamson/perl5 that referenced this issue Jul 10, 2023
In some embedded Perl scenarios, such as mod_perl, the Perl DLL
may be unloaded, causing the hook to become invalid.

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

Successfully merging a pull request may close this issue.

3 participants