Quantcast
Channel: Visual Leak Detector for Visual C++ 2008-2015
Viewing all articles
Browse latest Browse all 704

Commented Issue: Visual Leak Detector Crashes after loading [9099]

$
0
0
<p>Hello,</p>
<p>I am new on VLD and I have started to use it (version 2.2) on Windows XP Service Pack 2.</p>
<p>&nbsp;</p>
<p>We develop third part application to a CAD software (AutoCAD) from AutoDESK company (acad.exe built using VS2008)</p>
<p>It means that we create applications to customize AutoCAD and these applications are dll&#39;s loaded on AutoCAD memory space.</p>
<p>&nbsp;</p>
<p>But, during the loading of our library, I get a crash in the application (stack overflow) and in the Visual Studio output debug I get the following information:</p>
<p>&#39;acad.exe&#39;: Loaded &#39;C:\Data\ITLPlus\Win32\Debug\ITLPlusHDesk.arx&#39;, Symbols loaded.</p>
<p>&#39;acad.exe&#39;: Loaded &#39;C:\Data\ITLPlus\Win32\Debug\GDCLibrary.dll&#39;, Symbols loaded.</p>
<p>&#39;acad.exe&#39;: Loaded &#39;C:\Program Files\Visual Leak Detector\bin\Win32\vld_x86.dll&#39;, Binary was not built with debug information.</p>
<p>&#39;acad.exe&#39;: Loaded &#39;C:\Program Files\Autodesk\AutoCAD Map 3D 2012\dbghelp.dll&#39;</p>
<p>Visual Leak Detector Version 2.2 installed.</p>
<p>First-chance exception at 0x7c90e8ee in acad.exe: 0xC00000FD: Stack overflow.</p>
<p>Unhandled exception at 0x7c90e8ee in acad.exe: 0xC00000FD: Stack overflow.</p>
<p>First-chance exception at 0x7c90e8e5 in acad.exe: 0xC0000005: Access violation writing location 0x0f4f0ff0.</p>
<p>Unhandled exception at 0x7c90e8e5 in acad.exe: 0xC0000005: Access violation writing location 0x0f4f0ff0.</p>
<p>The program &#39;[6020] acad.exe: Native&#39; has exited with code 0 (0x0).</p>
<p>&nbsp;</p>
<p>After that I have compiled VLD on Visual Studio 2008, but still the same problem.</p>
<p>I have debugged my application and I noticed that I get crash in the function void* vldnew (size_t size, const char *file, int line) present in vldheap.cpp.</p>
<p>This crash is during the call of the function RtlAllocateHeap(). (see image attached for information on the &quot;Call Stack&quot; windows in VStudio</p>

Comments: I found a workaround for this infinite loop to just add KernelBase.dll as a non-hooked (non-patched) DLL. In the function attachToLoadedModules, after: ``` if (_wcsicmp(TEXT(VLDDLL), modulename) == 0) { // What happens when a module goes through it's own portal? Bad things. // Like infinite recursion. And ugly bald men wearing dresses. VLD // should not, therefore, attach to itself. continue; } ``` I added: ``` if (_wcsicmp(TEXT("KernelBase.dll"), modulename) == 0) { continue; } ``` In fact, _TlsSetValue actually calls HeapAlloc that is mapped to our function that calls again _TlsSetValue - and this will result in stack overflow error. This workaround seems to solve infinite loop. Seems that this error happens only when EXE is not compiled to use VLD and one of its loaded modules does. This is not an ideal solution because we don't catch anymore KernelBase.dll leaks, but anyway, provide a way to still use VLD in that case. Another solution would be to patch KernelBase.dll after call of TlsSetValue:

Viewing all articles
Browse latest Browse all 704

Trending Articles