coldguy has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to build Crypt::SSLeay 0.51 on Windows. Everything compiles fine but the tests crash horribly. I'm using MSVC 7 (from the full Visual Studio 2003), along with a Perl 5.8.8 and an OpenSSL 0.9.8b that I built myself.

UPDATE: Solution inside, check randyk's comment below for details. The XS code is suffering from a touch of bitrot and needs a one line patch.

First off, I'm not using ActiveState's Perl because my eventual objective is to build Apache 2.0.x and mod_perl for it from source, and I'd like everything to be built with the same compiler. Is that a good reason or am I just being superstitious? ActivePerl's perl -V reports an earlier ccversion than the one I built myself, and I don't have any earlier versions of MSVC available.

I built Perl 5.8.8 using the C compiler that comes with Visual Studio 2003 (v7 I think). Perl built fine and passed all the tests it didn't skip. Output of `perl -V` is attached below.

I built OpenSSL 0.9.8b using the same compiler. It also built fine, and it also passed all its tests.

I downloaded Crypt::SSLeay 0.51 from CPAN. After providing it with the path to my OpenSSL directory, it builds without error. However, when I try to run the tests (with "nmake test"), it crashes with what appears to be the Windows equivalent of a segmentation fault (I'm really more of a Linux guy). Here's the exact error message I get:

The instruction at "0x01d977b7" referenced memory at "0x000000a4". Th +e memory could not be "read".

Windows helpfully gave me the option to fire up the debugger at this point, so I did. It appears that the crash is occurring at the call to SSL_ctx_default_verify_paths in SSL_ctx_new in SSLeay.xs. I don't know enough about C, Windows, or the internals of Perl to debug any further. I pushed the code around a bit but didn't get anywhere. From what I do know, it looks to me like some pointer variable is being improperly initialized to 0 somewhere, but that's just wild conjecture on my part. My theory is that something has changed in Perl or in OpenSSL that breaks the XS code...

Here is the output of perl -V:

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 usemulti +plicity=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 -DPERL_IMPLICIT_CONTEXT -DPER +L_IMPLICIT_SYS -DUSE_ PERLIO -DPERL_MSVCRT_READFIX', optimize='-MD -Zi -DNDEBUG -O1', cppflags='-DWIN32' ccversion='13.10.3077', 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 -l +ibpath:"c:\Perl\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.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netap +i32.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 n +etapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvc +rt.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' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PL_OP_SLAB_ALLOC USE_ITHREADS USE_LARGE_FILES USE_PERLIO Built under MSWin32 Compiled at Jun 7 2006 14:57:17 @INC: C:/Perl/lib C:/Perl/site/lib .

Here is what happens at the command line when I try to run the module's tests (aside from the Windows error that pops up in a dialog):

Microsoft (R) Program Maintenance Utility Version 7.10.3077 Copyright (C) Microsoft Corporation. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harn +ess(0, 'blib\lib', 'blib\arch')" t/*.t t/net_ssl........dubious Test returned status 5 (wstat 1280, 0x500) t/ssl_context....dubious Test returned status 5 (wstat 1280, 0x500) FAILED--2 test scripts could be run, alas--no output ever seen NMAKE : fatal error U1077: 'C:\Perl\bin\perl.exe' : return code '0x5' Stop.

Any help would be greatly appreciated. Thanks for looking!

UPDATE: Net::SSLeay builds without errors on my machine and tests without crashing (there is one error about an "ssl read failed" and it seems to hang after finishing all the tests, but I think it's fine), so I don't think it's my Perl or my OpenSSL installation that's gone hairy. I'm not sure at this point if I'm even going to need Crypt::SSLeay, although I would still be happy to have it.

Replies are listed 'Best First'.
Re: Building Crypt::SSLeay on Win32
by syphilis (Archbishop) on Jun 08, 2006 at 08:49 UTC
    Although version 0.51 is the latest, you'll note that it's quite old (June 2003). My guess is that some change in the recent release(s) of OpenSSL doesn't get along with the XS code - as you, yourself, more or less suggested. But that's just a guess. It could also be some code in the OpenSSL library that's posing a problem with VC7 only - ie some code that didn't actually get run until you came to run the Crypt::SSLeay test suite.

    There's a ppm of Crypt-SSLeay-0.51 at http://theoryx5.uwinnipeg.ca/ppms/ if that helps. It should work fine with your build of perl (I think ... but no guarantee) despite the different compiler version. I don't know which version of OpenSSL it was built against - I suspect an older version.

    Then again, if you built perl yourself you probably don't have the ppm utility - though you can get a serviceable version of it from CPAN. Nearly all ppm's that you find will work with your build of perl - so it's a handy tool to have for when problems arise.

    I think it's a sound policy to be using the same compiler for everything - but don't let the principle stand in the way of progress - you'll often find it doesn't matter which windows compiler was used.

    Cheers,
    Rob
      Thanks for the tip on the compiler stuff! If I end up needing the module I'll give the PPM a try. It does kind of bum me out that the solution to any problem with his module on Win32 is always "use the PPM"... It's even in the doc for the module. I don't know anything about XS but the C bits that call into OpenSSL look sane compared to various "how to use OpenSSL" things I've found. Perhaps I can convince the builders of the PPM to betray their secrets. It looks like the OpenSSL 0.9.7 is still getting security fixes, maybe I'll try building against that.
Re: Building Crypt::SSLeay on Win32
by randyk (Parson) on Jun 09, 2006 at 00:14 UTC
      Success! Changed line 110 of SSLeay.xs to call SSL_add_ssl_algorithms() (instead of add_all_algorithms), and now the module tests OK. Thanks again!
      Ah, that looks like it exactly. I don't have access to my build environment at the moment (at home away from those mean old Windows machines), but I'll try it tomorrow. Thanks! I had known at some point in the hazy past that rt existed but forgot about it when I was looking for a solution.