Developer Guide and Reference


Checking for Dangling Pointers

The pointer checker is not supported on
When dangling pointer checking or heap is enabled, the compiler uses a wrapper for the C runtime function
and the C++
operator. These wrappers find all pointers that point to the block being freed, and change their bounds so that any access through the pointer will cause a bound violation. The bounds of these dangling pointers are actually set to:
  • lower_bound(
    ) = 2;
  • upper_bound(
    ) = 0;
If your program gets a bound violation with these bounds, it is the result of a reference through a dangling pointer.
When dangling pointer checking is enabled for stack, the compiler finds all pointers that point to the locals of the function and changes their bounds in the same way as heap pointers above, just before the function exits.
If you have a custom memory allocator, you can enable it to do dangling pointer checking. The
function of your custom memory allocator should call this function in the pointer checker runtime code:
void __chkp_invalidate_dangling(void *ptr, size_t size);
This function is declared in the
You must include that header file to use this function because it uses a custom call interface.
#include <chkp.h> void my_free(void *ptr) { size_t size = my_get_size(ptr); // do the free __chkp_invalidate_dangling(ptr, size); }
You can also enabled dangling pointer checking in any function you use to override the C++

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804