Situation:
- Win32 [release or] debug build (yep, I use MSVC2005 project files, NOT
the makefile, but that does not make any real difference here)
- link to the DLL version of the OpenSSL library (0.9.9 tested, will
VERY probably happen with other versions too, as long as you use OpenSSL
DLLs!)
The crash is caused because the termination code for the OpenSSL DLLs
will call the lock callback again AFTER the pSslMtxs[] array has been
free()d already and thus invalidated.
A double fix is in order: NULL the free()d pointer AND make sure the
lock callback only accesses that data when it IS initialized. No harm
done as the exit code is single threaded anyway.
Fix supplied below.
Take care,
Ger
PS: the '[i_a]' in there is just a historic marker I use to tag my
changes in projects which I track remotely. No other significance.
--- ../../1original/xmail/SSLBind.cpp 2007-11-02 01:34:32.000000000 +0100
+++ ./SSLBind.cpp 2007-11-16 14:50:26.000000000 +0100
@@ -72,17 +75,29 @@
-static SYS_MUTEX *pSslMtxs;
+static SYS_MUTEX *pSslMtxs = NULL; /* [i_a] - without it, the app will crash
when run without args and compiled in debug mode */
static void BSslLockingCB(int iMode, int iType, const char *pszFile, int iLine)
{
+ if (pSslMtxs != NULL) /* [i_a] */
+ {
if (iMode & CRYPTO_LOCK)
+ {
SysLockMutex(pSslMtxs[iType], SYS_INFINITE_TIMEOUT);
+ }
else
+ {
+ ASSERT(iMode & CRYPTO_UNLOCK);
SysUnlockMutex(pSslMtxs[iType]);
}
+ }
+ else
+ {
+ printf("called SSL locking callback after market!\n");
+ }
+}
static void BSslThreadExit(void *pPrivate, SYS_THREAD ThreadID, int iMode)
{
@@ -123,6 +138,7 @@
for (i--; i >= 0; i--)
SysCloseMutex(pSslMtxs[i]);
SysFree(pSslMtxs);
+ pSslMtxs = NULL; /* [i_a] */
return ErrorPop();
}
}
@@ -158,6 +174,7 @@
for (i = 0; i < iNumLocks; i++)
SysCloseMutex(pSslMtxs[i]);
SysFree(pSslMtxs);
+ pSslMtxs = NULL; /* [i_a] */
}
static int BSslHandleAsync(SslBindCtx *pCtx, int iCode, int iDefError, int
iTimeo)
-
To unsubscribe from this list: send the line "unsubscribe xmail" in
the body of a message to [EMAIL PROTECTED]
For general help: send the line "help" in the body of a message to
[EMAIL PROTECTED]