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

Visual Leak Detector: Detected a memory leak internal to Visual Leak Detector

Nov 26, 2011 at 11:21 AM

Hi,

while using VLD I have detected this error message in my output window.

No memory leaks detected.
Visual Leak Detector is now exiting.
ERROR: Visual Leak Detector: Detected a memory leak internal to Visual Leak Detector!!
---------- Block 189682 at 0x065EBB88: 24 bytes ----------
  Call Stack:
    vld.cpp (947): Full call stack not available.
  Data:
    00 00 00 00    04 00 00 00    00 00 00 00    01 00 00 00     ........ ........
    58 15 00 00    00 00 00 00                                   X....... ........

 

I am using the latest version 2.2 in Visual Studio 2010.

My project is a mix of managed/unmanged code.

Thanks,

Ferhat

Dec 11, 2011 at 2:04 AM
Edited Dec 17, 2011 at 11:52 PM

Mixed code not supported at the moment. We will appreciate for patch :-).

Dec 29, 2011 at 2:07 AM

I have the same problem. yet not using managed code. It happens when I create the maximum amount of threads possible in an application. I am stresstesting some of my API's to see if my exception handling is working correctly in any rare circumstance :)

Feb 13, 2012 at 8:28 PM
ferhat wrote:

Hi,

while using VLD I have detected this error message in my output window.

No memory leaks detected.
Visual Leak Detector is now exiting.
ERROR: Visual Leak Detector: Detected a memory leak internal to Visual Leak Detector!!
---------- Block 189682 at 0x065EBB88: 24 bytes ----------
  Call Stack:
    vld.cpp (947): Full call stack not available.
  Data:
    00 00 00 00    04 00 00 00    00 00 00 00    01 00 00 00     ........ ........
    58 15 00 00    00 00 00 00                                   X....... ........

 

I am using the latest version 2.2 in Visual Studio 2010.

My project is a mix of managed/unmanged code.

Thanks,

Ferhat

You should use deleaker or similar debugger ...

Feb 14, 2012 at 10:10 PM
d1kkop wrote:

I have the same problem. yet not using managed code. It happens when I create the maximum amount of threads possible in an application. I am stresstesting some of my API's to see if my exception handling is working correctly in any rare circumstance :)

Can you try with VLD 2.2.3

Apr 23, 2012 at 9:47 PM
Edited Apr 23, 2012 at 9:58 PM

Hi,

I have the same problem (using VLD 2.2.3) and I think it is caused by a bug in VLD. (But I'm not experienced programmer and it's possible that I'm wrong)

I don't know if it is relevant but I'm using Visual Studio 2010 Ultimate, Windows 7 Professional 64bit and boost::thread.

The bug occurs when you repeatedly create and destroy threads. It looks like this:

No memory leaks detected.
Visual Leak Detector is now exiting.
ERROR: Visual Leak Detector: Detected a memory leak internal to Visual Leak Detector!!
---------- Block 1642 at 0x004A3A80: 24 bytes ----------
  Call Stack:
    vld.cpp (958): Full call stack not available.
  Data:
    00 00 00 00    04 00 00 00    00 00 00 00    01 00 00 00     ........ ........
    4C 04 00 00    00 00 00 00                                   L....... ........

The program '[4300] Server.exe: Native' has exited with code 0 (0x0).

The number of leaks changes. But I found out that it is the same number as the number of windows threads with the same ID. It can be seen in VS Debug output:

The thread 'Win32 Thread' (0xe04) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1798) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1148) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x80) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x2e8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x14c0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x74) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xecc) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe54) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1718) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x44c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x161c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1304) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x44c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x12f0) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1488) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xe64) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x4d8) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0xb9c) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x1030) has exited with code 0 (0x0).
The thread 'Win32 Thread' (0x16ec) has exited with code 0 (0x0).

So the leak occurs every time a new thread is created with an ID that has already appeared once. The leak is reported on line 958 of 'vld.cpp':

if (tls == NULL) {
    // This thread's thread local storage structure has not been allocated.
    tls = new tls_t; // <<< LEAK ORIGINATED HERE
    TlsSetValue(m_tlsIndex, tls);
    ZeroMemory(&tls->context, sizeof(tls->context));
    tls->flags = 0x0;
    tls->oldFlags = 0x0;
    tls->threadId = GetCurrentThreadId();
    tls->ppCallStack = NULL;

    // Add this thread's TLS to the TlsSet.
    CriticalSectionLocker cs(m_tlsLock);
    m_tlsMap->insert(tls->threadId,tls); // <<< PROBLEM HERE
}

I think problem occurs at the last line, where the tls should be inserted in the list. But if the thread has the same ID as one of the threads before, it is not inserted (at least thats what I understand from VLD's files map.cpp and tree.cpp). Therefore the 'tls pointer' is not stored anywhere and goes out of scope causing memory leak.

I would expect that when the thread is not inserted, it is not checked for memory leaks either. But I did a little test with threads that have an intentional memory leak and eventhough I still got the VLD 'thread leaks', all the intentional memory leaks are reported also.

Fixing the leak shouldnt be a problem e.g. replacing the last line with:

    if (m_tlsMap->insert(tls->threadId,tls) == m_tlsMap->end()) {
        delete tls;
    }

But I think there will be some more work to do in background...

I've also created short sample for that causes the error:

#include <boost/thread.hpp>
#include <vld.h>

void noop(void) {}

int main(void)
{
    for (int i = 0; i < 500; ++i)
    {
        boost::thread t = boost::thread(noop);
} return 0; }

The error occurence increases with increasing number of loops, but with 500 I got multiple errors every time.

 

Otherwise thanks VLD team! VLD is very helpful tool!

Petr

Jul 19, 2012 at 4:42 AM

I have the same issue (VLD 2.2.3) that is not appear on VLD 2.2.2 (on the same app):

ERROR: Visual Leak Detector: Detected a memory leak internal to Visual Leak Detector!!
---------- Block 16818 at 0x0A0562D0: 24 bytes ----------
  Call Stack:
    vld.cpp (958): Full call stack not available.
  Data:
    00 00 00 00    04 00 00 00    00 00 00 00    01 00 00 00     ........ ........
    A0 91 00 00    00 00 00 00                                   ........ ........

Apr 29, 2013 at 9:19 PM
This problem should be resolved as of v2.3.