Developer Guide and Reference

Contents

Working with Enabled and Non-Enabled Modules

The pointer checker is not supported on
macOS*
systems.
An enabled module is a module compiled with the pointer checker option enabled, while a non-enabled module is a module compiled with this compiler option disabled.
If you write a pointer to memory or return a pointer from a non-enabled module, the pointer may get incorrect bounds information. If you use this pointer with the incorrect bounds information in an enabled module, the pointer checker will report an incorrect out-of-bounds error because the bounds do not correspond to the pointer.
To minimize this issue, the pointer checker stores a copy of the pointer along with the bounds information. When the pointer is loaded into memory, the value of the pointer is compared with the value of the pointer copy. If these two values match, the bounds information is assumed to be correct and is then used. However, if the two values do not match, the bounds are set to allow access to any memory.
The pointer checker can still report an out-of-bounds error if a pointer from a non-enabled module matches the pointer copy stored with the bounds information.
For example, consider the case where you create the following pointer by using a run-time library function from a non-enabled module:
Example: Pointer Created with RTL Function
p = my_realloc(p, old_size + 100);
If the memory allocator can simply extend the memory allocated to
p
, and then returns the same pointer, an enabled module could use this pointer with the old bounds information. The pointer checker then reports an out-of-bounds error because this feature does not know about the extension created by the
realloc()
function.
To prevent incorrect out-of-bounds errors when you have both enabled and non-enabled modules, do one of the following:
  • Remove the bounds information from the pointer by using the
    __chkp_kill_bounds()
    intrinsic function
  • Set the correct bounds information by using the
    __chkp_make_bounds()
    intrinsic function in an enabled module.

Removing the Bounds Information

When you remove the bounds information, you disable pointer checking on this pointer. You can remove the bounds information by using the
__chkp_kill_bounds()
intrinsic function.