Subject: | CRYPT_SSLEAY_free() may call the wrong free() function on Windows. |
Date: | Thu, 14 Oct 2010 13:30:32 -0700 |
To: | <bug-Crypt-SSLeay [...] rt.cpan.org> |
From: | "Jan Dubois" <jand [...] activestate.com> |
On Windows Perl is built with the -DPERL_IMPLICIT_SYS compile option,
which redirects many C runtime functions through an additional
abstraction layer. Amon other things it points malloc/free to an
internal version that maintains heaps per Perl interpreter (for
embedding purposes).
That means when you call free() in XS code you won't get the C runtime
version, but the wrapper from the Perl layer. Using it to free memory
that hasn't been allocated by the corresponding malloc() will generate a
fatal error (free to wrong pool):
t/00-basic.t .... ok
t/01-connect.t .. ok
# config on MSWin32
# ssl in ..\openssl
# lib -L..\openssl\out32 -lssleay32 -llibeay32 -lRSAglue -lrsaref
# inc -I..\openssl\inc32 -I..\openssl\inc32
# cc cl
Free to wrong pool 35e60 not 30c01a6 at C:/tmp/perl/lib/LWP/Protocol/https.pm line 36.
t/02-live.t .....
Dubious, test returned 5 (wstat 1280, 0x500)
Failed 1/4 subtests
(less 1 skipped subtest: 2 okay)
Test Summary Report
-------------------
t/02-live.t (Wstat: 1280 Tests: 3 Failed: 0)
Non-zero exit status: 5
Parse errors: Bad plan. You planned 4 tests but ran 3.
Files=3, Tests=23, 14 wallclock secs ( 0.04 usr + 0.00 sys = 0.04 CPU)
Result: FAIL
A simple way to avoid the redirection is to define the NO_XSLOCKS
preprocessor symbol before including XSUB.h.
I've attached a patch that does exactly that.
Cheers,
-Jan
Message body is not shown because sender requested not to inline it.