Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Pointer checker feature - Buffer overrun not detected on aligned heap

$
0
0

 

Hi,
I am using the pointer checker feature as documented (including chkp.h and compiling with flag /Qcheck-pointers:rw, also refer to https://software.intel.com/en-us/node/522704) in a C++ application on Win 8.1.
The pointer checker works perfectly fine and reports a buffer overrun if I use stack memory or unaligned heap memory (using malloc).
The pointer checker however does not report any overrun if I use aligned heap memory (using mkl_malloc or _aligned_malloc)

Sample code:

int _tmain(int argc, _TCHAR* argv[])
{
     __chkp_report_control(__CHKP_REPORT_LOG, 0);

    //char buf[5];                                        // OK, reports buffer overrun
    // __declspec(align(32)) char buf[5];                // OK, reports buffer overrun
    //char *buf = (char *) malloc(5);                    // OK, reports buffer overrun
    char *buf = (char *) mkl_malloc(5, 32);                // NOK, does not report buffer overrun
    //char *buf = (char *) _aligned_malloc(5, 32);        // NOK, does not report buffer overrun
    for (int i=0; i<=5;i++) {
        buf[i] = 'A' + i;
    } 
}

How can I enable pointer checking for aligned memory?

Thanks,

Lars


Viewing all articles
Browse latest Browse all 1616

Trending Articles