This project has moved and is read-only. For the latest updates, please go here.

infinite loop initializing vld, trying to check leaks in a Maya plugin

Mar 27, 2014 at 10:41 AM
Edited Mar 27, 2014 at 10:41 AM
Hello,

I'm trying to leak-check a Plugin dll I wrote. The issue I get looks a lot like discussion:224047 and discussion:266691.

I'm using: 2.3, compiled in Release Mode, using dbghlp.dll that comes with windows 8.1. VLD is directly added as a subproject in my solution, it gets build as a static lib and linked directly into my dll.

After a few first troubles of google::protocolbuffers being initialized first (and by that using new-operators from vld with vld not even being initialized), I inserted #pragma init_seg (compiler) into Line #60 of vld.cpp - then it works: the vld instance is initialized first.

Now comes the infinite loop: the call attachToLoadedModules(newmodules); in vld's cTor, indirectly calls _HeapAlloc. Inside _HeapAlloc the first line of code
LPVOID block = HeapAlloc(heap, flags, size);
creates the infinite loop, as somehow this call produces another call to _HeapAlloc.

Any idea how to fix this? Any more information I should provide?

Cheers,
Stefan
Mar 27, 2014 at 12:05 PM
I think, I found something that may cause this behaviour and it looks like it's my own fault:

in vld.cpp, around line 590:
        if (!FindImport((HMODULE)modulebase, m_vldBase, VLDDLL, "?g_vld@@3VVisualLeakDetector@@A"))
        {
            // This module does not import VLD. This means that none of the module's
            // sources #included vld.h.
I'm not really sure about it. What happens if VLD doesn't find a module that loads it? I mean that is what happens after directly linking it into my dll.

However, I'll try to supply it as a dll.
Mar 31, 2014 at 6:30 PM
What happens if VLD doesn't find a module that loads it? I mean that is what happens after directly linking it into my dll.
I don't know. VLD designed to work as DLL.