HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
intersection between the candidate lockset and incoming lockset is empty, the checker
reports the locking discipline violation. The candidate lockset and incoming lockset
members are specified in terms of the source file and line number pointing to the
pthread_mutex_lock call associated with that lock. For further details on detecting
lock discipline violations, refer to the above-referenced Eraser article.
False positives are possible in certain cases, as mentioned in the Eraser article. Multiple
locks can be used to protect the same shared variable. For example, a linked list can be
protected by an overall lock and an individual entry lock. This can result in the tool
reporting a false positive. False positives might also be reported as a result of memory
getting recycled in certain cases because of deallocations (which the lock checker is not
able to detect).
+check=malloc
The +check=malloc option enables memory leak and heap corruption checks at
runtime. It will cause the user program to abort for writes beyond boundaries of heap
objects, free or realloc calls for a pointer that is not a valid heap object, and
out-of-memory conditions. Memory leak information is captured and written out to a log
file when the program exits. The name of the logfile is printed out before program
termination.
The +check=malloc option works by intercepting all heap allocation and deallocation
calls. This is done by the use of a debug malloc library, librtc.so. The option works
for programs that use the system malloc or for user provided malloc routines in a
shared library. The librtc.so library is also used by the HP WDB debugger to provide
heap memory checking features in the debugger. Please refer to the HP WDB debugger
documentation for more information about heap memory checking. The librtc.so
library is shipped as part of the wdb product. Please install the HP WDB bundled with
the compiler or a more recent version of wdb to get full functionality.
The default behavior of the +check=malloc option can be changed by users providing
their own rtcconfig file. The user specified rtcconfig file can be in the current
directory or in a directory specified by the GDBRTC_CONFIG environment variable. The
default configuration used by the +check=malloc option is:
check_bounds=1;check_free=1;scramble_block=1;
abort_on_bounds=1;abort_on_bad_free=1;abort_on_nomem=1;
check_leaks=1;min_leak_size=0;check_heap=0;
frame_count=4;output_dir=.;
When +check=bounds:pointer is also turned on, it can check freed memory
read/write. But the check needs to retain freed memory which is not turned on by default.
To turn on the feature, set the following environment variable at runtime:
RTC_MALLOC_CONFIG="retain_freed_blocks=1"
Or add "retain_freed_blocks=1" to the rtcconfig file. When malloc failes to allocate
specified memory, the runtime system will free the retained freed memory and try to
allocate memory.
Runtime Checking Options 97