Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

False positive in Pointer Checker when parts of code are not instrumented

kcc
Beginner
277 Views

One more false positive in the Intel Pointer Checker.

If some code is not instrumented by the tool, instructions that copy pointers will not update the pointer metadata and thus the metadata will become stale. As a consiquence, if some pointer is freed and then malloc returns the same pointer again, the stale (and incorrect) metadata may be used causing false reports. In this short example, the un-instrumented pointer copy is done via an intrinsic, but this could also be inline assembly or a non-instrumented module. My conslusion: Pointer Checker can not be used on part of the code -- it absolutely must instrument the whole program. If I am wrong, please comment. I used composer_xe_2013.5.192 on Linux.

% cat pointer_checker_fp.cc

[cpp]
#include <iostream>
int *p;
int main() {
int *a = new int [7];
p = a;
delete p;
int *b = new int [8];
std::cout << a << " " << b << std::endl;
__sync_lock_test_and_set(&p, b);
return p[7];
}

[/cpp]
% icpc -g -O2 -std=c++0x -check-pointers=rw pointer_checker_fp.cc; ./a.out
0x8e1010 0x8e1010
CHKP: Bounds check error
lb: 0x8e1010
ub: 0x8e102b
addr: 0x8e102c
end: 0x8e102f
size: 4
Traceback:
at address 0x4013c4 in function main
in file /tmp/pointer_checker_fp.cc line 10

0 Kudos
0 Replies
Reply