Detecting and reporting errors
The primary goal for detecting heap corruption problems is to correctly identify the source of errors and fix them to avoid getting faults in the allocator at some later time.
- the pointer given to it is valid
- the associated block's header is corrupt
- either of the neighboring blocks is corrupt
To detect heap corruption, we provide a replacement library for the standard allocator that can keep additional block information in the header of every heap buffer. You can use this replacement library, which is implemented by the librcheck.so shared object and referred to simply as librcheck, while testing an application to help isolate any heap corruption problems.
- the point at which the error was detected
- the program location that made the request
- information about the heap buffer that contained the problem
The library technique can be refined to also detect some sources of errors that may still elude detection, such as memory overruns or underruns, that occur before the corruption is detected by the allocator. This may be done when the standard libraries are the vehicle for the heap corruption, such as an errant call to memcpy(). In librcheck, the standard memory manipulation functions and string functions are replaced with versions that use the information in this library to determine if their arguments reside in the heap and if they would cause the bounds of the heap buffer to be exceeded. Under these conditions, the functions can then call the error-reporting functions to provide information about the source of the error.