Here is some info on this subject

In crypto/rand/rand_win.c 

RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", ...

is called. This call lock registry access (_PredefinedHandleTableCriticalSection) and 
than load perfomance dll using LoadLibraryEx and GetProcessAddress (requires 
_LoadCriticalSection).

If another thread in this time is calling ODBC initialization, the process became 
deadlocked.

This happen due to DllMain of ODBCCP32.DLL, which calls 
ReQueryValueEx(HKEY_LOCAL_MACHINE, ..

In deadlock situation the DllMain of ODBCCP32.DLL has lock on _LoadCriticalSection, 
and is waiting on _PredefinedHandleTableCriticalSection.  But call from rand_win.c has 
lock on _PredefinedHandleTableCriticalSection and is waiting on critical section 
_LoadCriticalSection.

_LoadCriticalSection is in this place (is probably same object in all threads)
mov         eax,fs:[00000018]
mov         eax,dword ptr [eax+30h]
push        dword ptr [eax+0A0h] - ptr to CriticalSectionObject 

I dont know if this is problem of calling RegQueryValueEx in DllMain or 
RegQueryValueEx holding lock on registry during Perfomance Dll initialization. This 
must be solve by Microsoft.

Here are some comments about this in crypto/rand/rand_win.c from 0.9.7 snapshot
 
/ * It appears like this can cause an exception deep within ADVAPI32.DLL
  * at random times on Windows 2000.  Reported by Jeffrey Altman.  
  * Only use it on NT.
  */
 /* Wolfgang Marczy <[EMAIL PROTECTED]> reports that
  * the RegQueryValueEx call below can hang on NT4.0 (SP6).
  * So we don't use this at all for now. */
#if 0
        if ( osverinfo.dwPlatformId == VER_PLATFORM_WIN32_NT &&

This #if 0 must be used in 0.9.6 to use openssl in multithreaded ODBC apllication. 
Without this my apllication became deadlocked every time I reboot computer (every 
computer with NT4.0 SP6 MDAC2.6 I tried) and sometimes during heavy disk usage.

Please make some FAQ of this (calls to RAND_poll must be serialized) or don't use 
RegQueryValueEx(HKEY_PERFORMANCE_DATA) at all.

Milan Dadok
e-mail: [EMAIL PROTECTED]

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to