I’m trying to compile the _ssl module on Windows for Python 2.6 using the MSVC compiler, because the Python runtime embedded into the host application is built with this compiler and of this version. The runtime does not come with native ssl-support on Windows however, not because it is not supported, but because (among an official statement) licenses have not yet been checked to be compatible with the closed-source application.
I’ve downloaded the CPython 2.6.8 source from the Python homepage and extracted _ssl.c and socketmodule.h (required include by the ssl module source) into a separate folder. I’ve also downloaded the openssl-for-windows win32 builds in order to linke it with the ssl module source.
My build-commands are the following:
cl /I"C:\path\to\host\python\runtime\include" /I"include/" _ssl.c /Fo"_ssl.obj" /c
link _ssl.obj /DLL "C:\path\to\host\python\runtime\libs\python26.lib" lib/libeay32.lib lib/ssleay32.lib Ws2_32.lib /OUT:_ssl.pyd
libeay32.lib and ssleay32.lib are from the openssl-for-windows distribution. The module compiles fine and outputs an 88KB shared library.
Problem
When I start the host application and run a command invoking the Python runtime running code importing and using the recently compiled _ssl module, the application crashes. The host application has its own kind of exception handler writing a bugreport when crashing.
Exception
{
ExceptionNumber = 0xC0000005
ExceptionText = "ACCESS_VIOLATION"
Address = 0x01A27058
Thread = 4776
Last_Error = 0x00000000
}
The call-stack at the point of the exception does not end in any Python related procedures. I assume that something incorrect happened before that triggers the error at this place.
Weirdness
When I run the application from the Win32 Debugger (WinDbg), this error does not happen and everything runs fine.
Question
What am I doing wrong with compiling the _ssl module, or what could trigger this exception?
Additional Information
- The embedded Python runtime is the following:
2.6.4 (r264:75706, Mar 6 2012, 02:32:04) [MSC v.1600 32 bit (Intel)]
The crash finally was due to a bug in the host application. This bug could however only occure, when data was fetched from the web, which was only possible with the ssl module.