Hi, OpenSSL Version: 0.9.8o OS : Windows Server 2008 R2 SP1
I am seeing a deadlock in a windows application between two threads, one thread calling Heap32First from OpenSSL's RAND_poll and the other that allocates memory over the heap. Here is the relevant stack trace from both the threads involved in deadlock. Thread 523 ---------------- ntdll!ZwWaitForSingleObject+a ntdll!RtlpWaitOnCriticalSection+e8 ntdll!RtlEnterCriticalSection+d1 ntdll!RtlpAllocateHeap+18a6 ntdll!RtlAllocateHeap+16c ntdll!RtlpAllocateUserBlock+145 ntdll!RtlpLowFragHeapAllocFromContext+4e7 ntdll!RtlAllocateHeap+e4 ntdll!RtlInitializeCriticalSectionEx+d2 ntdll!RtlpActivateLowFragmentationHeap+181 ntdll!RtlpPerformHeapMaintenance+27 ntdll!RtlpAllocateHeap+1819 ntdll!RtlAllocateHeap+16c Thread 454 ----------------- ntdll!NtWaitForSingleObject+0xa ntdll!RtlpWaitOnCriticalSection+0xe8 ntdll!RtlEnterCriticalSection+0xd1 ntdll!RtlLockHeap+0x3b ntdll!RtlpQueryExtendedHeapInformation+0xf4 ntdll!RtlQueryHeapInformation+0x3c ntdll!RtlQueryProcessHeapInformation+0x3ad ntdll!RtlQueryProcessDebugInformation+0x3b0 kernel32!Heap32First+0x71 WinDBG reports that thread 523 and 454 both hold locks and are waiting for each other locks thereby resulting in a deadlock. On searching, I have found a couple instances where such an issue has been reported with Heap32Next on Windows 7 but haven't found anything that helps me solve the problem. Most of the references I found conclude that this could be because of a possible bug in heap traversal APIs. If someone has faced a similar problem, can you guide me to possible workarounds by which I can avoid the deadlock? Can I remove the heap traversal routines and find some other sources of entropy? Thanks for your help. Regards Sandeep