I used VLD in the library, which is dynamically loaded and unloaded from process.
What is happening when library is unloaded by calling UnloadLIbrary()?
I have an impression that it locks main thread for a while, because when unloads library, the method VisualLeakDetector::waitForAllVLDThreads() is called from destructor of g_vld object. Then I'm getting application crash caused by VLD, because m_heapMapLock
object does not exist anymore. Here is call stack during crash:
vld.dll!CriticalSectionLocker::CriticalSectionLocker(CriticalSection & cs) Line 54
vld.dll!VisualLeakDetector::unmapBlock(void * heap, const void * mem, const context_t & context) Line 1122
vld.dll!VisualLeakDetector::_HeapFree(void * heap, unsigned long flags, void * mem) Line 1637
Is there any suggestion how to avoid this crash having VLD only in the library, which is dynamically loaded / unloaded?