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

Edited Issue: DLL CRT initialization leaks [10421]

$
0
0
When VLD is linked with a DLL, it reports quite some leaks in initialization routines. After some exploration, it seems that CRT allocates some memory to hold environment variables, argv etc. and does not bother to free them (since it is not needed as they live through whole lifetime of a module).

The problem is that these leak reports pollute debug output window possibly hiding any actual leaks in a library. Is it possible to hide them somehow? I tried to use VLDMarkAllLeaksAsReported at the beginning of DllMain function but it also hides all executable leaks before that (using LoadLibrary). I build against static CRT in VS 2008.

I leave this issue to a discussion as this behavior is technically correct (CRT actually leaks memory) but there should be a way to ignore these leaks as well as they are "by design".

Example output:

WARNING: Visual Leak Detector detected memory leaks!
Visual Leak Detector detected 54 memory leaks in heap 0x00D10000

---------- Block 62 at 0x00D10A30: 164 bytes ----------
Call Stack:
f:\dd\vctools\crt_bld\self_x86\crt\src\onexit.c (208): InstUp.dll!__onexitinit + 0x15 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c (953): InstUp.dll!_initterm_e + 0x7 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\crt0dat.c (297): InstUp.dll!_cinit + 0xF bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dllcrt0.c (132): InstUp.dll!_CRT_INIT + 0x19 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dllcrt0.c (312): InstUp.dll!__DllMainCRTStartup + 0x11 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dllcrt0.c (281): InstUp.dll!_DllMainCRTStartup + 0x11 bytes
0x77329950 (File and line number not available): ntdll.dll!RtlQueryEnvironmentVariable + 0x241 bytes
0x7732D8C9 (File and line number not available): ntdll.dll!LdrResSearchResource + 0xB4D bytes
0x7733681C (File and line number not available): ntdll.dll!RtlGetNtVersionNumbers + 0x9B bytes
0x773352D6 (File and line number not available): ntdll.dll!RtlSetUnhandledExceptionFilter + 0x50 bytes
0x77329E79 (File and line number not available): ntdll.dll!LdrInitializeThunk + 0x10 bytes
Data:
D8 32 D1 00 00 00 00 00 2C 3D 52 50 D0 00 00 00 .2...... ,=RP....
80 00 00 00 02 00 00 00 3E 00 00 00 FD FD FD FD ........ >.......
10 3E E0 45 10 3E E0 45 10 3E E0 45 10 3E E0 45 .>.E.>.E .>.E.>.E
10 3E E0 45 10 3E E0 45 10 3E E0 45 10 3E E0 45 .>.E.>.E .>.E.>.E
10 3E E0 45 10 3E E0 45 10 3E E0 45 10 3E E0 45 .>.E.>.E .>.E.>.E
10 3E E0 45 00 00 00 00 00 00 00 00 00 00 00 00 .>.E.... ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ........ ........
FD FD FD FD ........ ........

---------- Block 12 at 0x00D11F80: 67 bytes ----------
Call Stack:
f:\dd\vctools\crt_bld\self_x86\crt\src\stdenvp.c (127): InstUp.dll!_setenvp + 0x14 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dllcrt0.c (132): InstUp.dll!_CRT_INIT + 0xE bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dllcrt0.c (312): InstUp.dll!__DllMainCRTStartup + 0x11 bytes
f:\dd\vctools\crt_bld\self_x86\crt\src\dllcrt0.c (281): InstUp.dll!_DllMainCRTStartup + 0x11 bytes
0x77329950 (File and line number not available): ntdll.dll!RtlQueryEnvironmentVariable + 0x241 bytes
0x7732D8C9 (File and line number not available): ntdll.dll!LdrResSearchResource + 0xB4D bytes
0x7733681C (File and line number not available): ntdll.dll!RtlGetNtVersionNumbers + 0x9B bytes
0x773352D6 (File and line number not available): ntdll.dll!RtlSetUnhandledExceptionFilter + 0x50 bytes
0x77329E79 (File and line number not available): ntdll.dll!LdrInitializeThunk + 0x10 bytes
Data:
78 1E D1 00 E0 1F D1 00 B0 71 52 50 7E 00 00 00 x....... .qRP~...
1F 00 00 00 02 00 00 00 0C 00 00 00 FD FD FD FD ........ ........
41 4C 4C 55 53 45 52 53 50 52 4F 46 49 4C 45 3D ALLUSERS PROFILE=
43 3A 5C 50 72 6F 67 72 61 6D 44 61 74 61 00 FD C:\Progr amData..
FD FD FD ........ ........


Viewing all articles
Browse latest Browse all 704

Trending Articles