Error in finding leak caused by array deleted by non-array delete

Jan 22, 2013 at 1:44 PM

I just installed vld and tried few test before using this in a product.  

The flowing leak is failing to be reported

int* ptrLeak1 = new int[5];

memset(ptrLeak1, 0xF1, 5*sizeof(int));

delete ptrLeak1;

Visual Leak Detector Version 2.2.3 installed.
No memory leaks detected.
Visual Leak Detector is now exiting.

However, the flowing leak is reported correctly

int* ptrLeak1 = new int[5];

memset(ptrLeak1, 0xF1, 5*sizeof(int));

//delete ptrLeak1;

 

Visual Leak Detector Version 2.2.3 installed.
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x00000000012F6660: 20 bytes ----------
  Call Stack:
    d:\mycpp\consoleapplication3\consoleapplication3\consoleapplication3.cpp (9): ConsoleApplication3.exe!wmain + 0xA bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crtexe.c (552): ConsoleApplication3.exe!__tmainCRTStartup + 0x19 bytes
    f:\dd\vctools\crt_bld\self_64_amd64\crt\src\crtexe.c (371): ConsoleApplication3.exe!wmainCRTStartup
    0x0000000076E9652D (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0xD bytes
    0x00000000770CC521 (File and line number not available): ntdll.dll!RtlUserThreadStart + 0x21 bytes
  Data:
    F1 F1 F1 F1    F1 F1 F1 F1    F1 F1 F1 F1    F1 F1 F1 F1     ........ ........
    F1 F1 F1 F1                                                  ........ ........


Visual Leak Detector detected 1 memory leak (72 bytes).
Largest number used: 72 bytes.
Total allocations: 72 bytes.
Visual Leak Detector is now exiting.

This case is not supported ?

Coordinator
Jan 22, 2013 at 8:04 PM

You can set option VLD_OPT_VALIDATE_HEAPFREE for that (check "corruption" test)

Jan 23, 2013 at 7:35 AM
Edited Jan 23, 2013 at 7:47 AM

I have enabled VLD_OPT_VALIDATE_HEAPFREE  by adding "ValidateHeapAllocs = yes" to vld.ini file but there is no change.