visual-studiomemory-leaksvisual-leak-detector

Visual Leak Detector reporting strange leaks in CRT module of VC++


I've just now installed Visual Leak Detector (2.3) on Windows 8. I tested it with blank CRT program (in Visual Studio 2012) that does nothing.

#include <vld.h>

int main(int argc, char** argv) 
{
    return 0;
}

When I run it VLD reports strange leaks in vc++ crt module:

Visual Leak Detector Version 2.3 installed.
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 31 at 0x0000000052C07530: 70 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\stdenvp.c (127): my_application.exe!_setenvp + 0x27 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (223): my_application.exe!__tmainCRTStartup + 0x5 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (164): my_application.exe!mainCRTStartup
    0x00000000FAF8167E (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0x1A bytes
    0x00000000FD8CC3F1 (File and line number not available): ntdll.dll!RtlUserThreadStart + 0x21 bytes
  Data:
    20 B5 C0 52    50 00 00 00    50 92 C0 52    50 00 00 00     ...RP... P..RP...
    20 91 DD E1    F6 07 00 00    7E 00 00 00    02 00 00 00     ........ ~.......
    12 00 00 00    00 00 00 00    1F 00 00 00    FD FD FD FD     ........ ........
    50 52 4F 43    45 53 53 4F    52 5F 4C 45    56 45 4C 3D     PROCESSO R_LEVEL=
    36 00 FD FD    FD FD                                         6....... ........


---------- Block 40 at 0x0000000052C075D0: 72 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\stdenvp.c (127): my_application.exe!_setenvp + 0x27 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (223): my_application.exe!__tmainCRTStartup + 0x5 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (164): my_application.exe!mainCRTStartup
    0x00000000FAF8167E (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0x1A bytes
    0x00000000FD8CC3F1 (File and line number not available): ntdll.dll!RtlUserThreadStart + 0x21 bytes
  Data:
    F0 94 C0 52    50 00 00 00    20 76 C0 52    50 00 00 00     ...RP... .v.RP...
    20 91 DD E1    F6 07 00 00    7E 00 00 00    02 00 00 00     ........ ~.......
    14 00 00 00    00 00 00 00    28 00 00 00    FD FD FD FD     ........ (.......
    53 45 53 53    49 4F 4E 4E    41 4D 45 3D    43 6F 6E 73     SESSIONN AME=Cons
    6F 6C 65 00    FD FD FD FD                                   ole..... ........


---------- Block 41 at 0x0000000052C07620: 67 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\stdenvp.c (127): my_application.exe!_setenvp + 0x27 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (223): my_application.exe!__tmainCRTStartup + 0x5 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (164): my_application.exe!mainCRTStartup
    0x00000000FAF8167E (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0x1A bytes
    0x00000000FD8CC3F1 (File and line number not available): ntdll.dll!RtlUserThreadStart + 0x21 bytes
  Data:
    D0 75 C0 52    50 00 00 00    D0 96 C0 52    50 00 00 00     .u.RP... ...RP...
    20 91 DD E1    F6 07 00 00    7E 00 00 00    02 00 00 00     ........ ~.......
    0F 00 00 00    00 00 00 00    29 00 00 00    FD FD FD FD     ........ ).......
    53 79 73 74    65 6D 44 72    69 76 65 3D    43 3A 00 FD     SystemDr ive=C:..
    FD FD FD                                                     ........ ........


---------- Block 43 at 0x0000000052C07670: 65 bytes ----------
  Call Stack:
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\stdenvp.c (127): my_application.exe!_setenvp + 0x27 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (223): my_application.exe!__tmainCRTStartup + 0x5 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crt0.c (164): my_application.exe!mainCRTStartup
    0x00000000FAF8167E (File and line number not available): KERNEL32.DLL!BaseThreadInitThunk + 0x1A bytes
    0x00000000FD8CC3F1 (File and line number not available): ntdll.dll!RtlUserThreadStart + 0x21 bytes
  Data:
    D0 96 C0 52    50 00 00 00    C0 76 C0 52    50 00 00 00     ...RP... .v.RP...
    20 91 DD E1    F6 07 00 00    7E 00 00 00    02 00 00 00     ........ ~.......
    0D 00 00 00    00 00 00 00    2B 00 00 00    FD FD FD FD     ........ +.......
    54 45 4D 50    3D 46 3A 5C    54 45 4D 50    00 FD FD FD     TEMP=F:\ TEMP....
    FD                                                           ........ ........


Visual Leak Detector detected 48 memory leaks (6044 bytes).
Largest number used: 15094 bytes.
Total allocations: 25276 bytes.
Visual Leak Detector is now exiting.

There are not much details about this on net however in this msdn forum a comment says:

That's not really a 'leak' so much as 'preparing your environment for execution'. It's making a writable copy of the process's environment for programs which expect it, and they will be released when the process exits. You can safely ignore the report.

However, I want to suppress these lines from appearing it to report (If they genuinely are not leaks)

Has anyone experienced this and know how to sort out?


Solution

  • I found this was bug in VLD 2.3. Details of bug are here. I just downloaded v2.4rc2 (vld-2.4rc2-setup.exe) and this issue not seems appearing anymore. (I had downloaded v2.3 because it has been marked stable)