Download MalCheck v18.104.22.168 [21k Zip file]
Note Any and all comments are welcome. Please tell me about your experiences, wishes and gripes concerning MalCheck. See the address below and in the package
These usually manifest themselves as unpredictable crashes at locations in the program that look perfectly correct. The damage was done at an earlier point, but only shows itself later.
A surefire pointer to such a problem is when the postmortem backtrace indicates that the last routine called was one of the above four functins.
This package keeps an eye on dynamically allocated blocks and tries to see if data was written outside the block or into free or dealloc blocks. (Free blocks are blocks released by free(), dealloc blocks are blocks left behind when realloc() needed to move data to a bigger block.)
Add the library 'MalCheck:o.malcheck' to the list given to the Link command in your Makefile. Note: If you use the (obsolete) ansilib, then put the malcheck library before C:o.ansilib.
Define the macro 'MALCHECK' by passing -DMALCHECK to the compile commands. Note: you can switch off MalCheck without changing the sources by compiling without this macro defined.
Make sure that the MalCheck$Path is set (e.g. by calling SetVars, which can be found in the package).
Make your software. When you run it, checks will be performed and output written to stderr.
Every time one of the above functions is called by the user program, the library runs though it's list of blocks and looks for suspicious things. For example: a change in m3 will show that probably the end of the allocated block was overwritten. This commenly happens when a string written to a block is too large for that block (maybe the terminating zero was forgotten in the count). Problems are reported on stderr, if their level is equal to or worse than the current report level.
If nothing desastrous has happened, the MalCheck function then performs the duty it was called for, checking whether nothing illegal is done (like calling free() with a pointer that does not point to an existing block). When no problems occured equal to or worse than the current quit level, the routine returns to the user program.
As an extra, atexit() is used to install a routine which produces a listing of all blocks when the program exits.
$Id: malcheck.html 1.3 2006-02-19 20:42:06+01 erikgrnh Exp $