This project has moved. For the latest updates, please go here.

Crash after endless loop in Release

Apr 2, 2013 at 8:32 PM
This may be related to http://vld.codeplex.com/discussions/249158

Using v2.2.3

My project links to the release crt dll (even in debug mode), and after adding vld to one DLL, I get a crash from this endless loop:

vld_x64.dll!VisualLeakDetector::getTls() Line 960 C++
vld_x64.dll!VisualLeakDetector::enabled() Line 883 + 0xa bytes C++
vld_x64.dll!VisualLeakDetector::_HeapAlloc(void * heap, unsigned long flags, unsigned __int64 size) Line 1544 + 0x14 bytes C++
KernelBase.dll!000007fefd739734()
vld_x64.dll!VisualLeakDetector::getTls() Line 960 C++
vld_x64.dll!VisualLeakDetector::enabled() Line 883 + 0xa bytes C++
vld_x64.dll!VisualLeakDetector::_HeapAlloc(void * heap, unsigned long flags, unsigned __int64 size) Line 1544 + 0x14 bytes C++
KernelBase.dll!000007fefd739734()   
Basically, g_vld.enabled() calls getTls() which calls new, which calls whatever triggers _HeapAlloc()

It seems that this should not happen since VLD links to the static CRT.
Apr 2, 2013 at 9:25 PM
Looks like its TlsSetValue() (and not new) that triggers _HeapAlloc()

g_vld.enabled() calls getTls() which calls TlsSetValue(), which triggers _HeapAlloc()

Here is the initial entry point in my example:
    vld_x64.dll!VisualLeakDetector::getTls()  Line 961  C++
    vld_x64.dll!VisualLeakDetector::enabled()  Line 884 + 0xa bytes C++
    vld_x64.dll!VisualLeakDetector::_HeapAlloc(void * heap, unsigned long flags, unsigned __int64 size)  Line 1544 + 0x14 bytes C++
    KernelBase.dll!000007fefd739734()   
    vld_x64.dll!VisualLeakDetector::getTls()  Line 961  C++
    vld_x64.dll!VisualLeakDetector::enabled()  Line 884 + 0xa bytes C++
    vld_x64.dll!VisualLeakDetector::_HeapAlloc(void * heap, unsigned long flags, unsigned __int64 size)  Line 1544 + 0x14 bytes C++
    msvcr100.dll!_calloc_impl(unsigned __int64 num, unsigned __int64 size, int * errno_tmp)  Line 47    C
    msvcr100.dll!_calloc_crt(unsigned __int64 count, unsigned __int64 size)  Line 61 + 0xe bytes    C
    msvcr100.dll!__CRTDLL_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 375 + 0xd bytes  C
    ntdll.dll!0000000076f9c76c()    
    ntdll.dll!0000000076f9c42f()    
    ntdll.dll!0000000076f9c32e() 
My project makes use of many threads.