NAME

leakers - Detect memory allocation errors.


SYNOPSIS

leakers [--columns=NUM] [--help] [--logfile=FILE] [--type=TYPE] -- [COMMAND [ARG1 [ARG2 [...]]]]


DESCRIPTION

leakers runs an executable specified by COMMAND which has been linked against libleakers.a, then examines the resulting log for memory leaks and for attempts to free memory multiple times. If COMMAND is not given, then leakers will only examine the log file. For each potential error leakers finds, one sentence will be printed, the sentence will start with a short description of the error (see OUTPUT for more), then the filename and line number the error occurred, and then the memory address of the pointer being being operated on is printed in parenthesis. Becuase libleakers is not sophisticated (an understatement!), there is always the chance that some memory was sneakily allocated or deallocated behind its back, thus causing a erroneous error message.


OPTIONS

--columns=NUM

leakers tries to make output more readable by wrapping lines. By default it uses the COLUMNS environment variable or 80 if that variable is not set. Use --columns=NUM to force leakers to try to display rows no wider than NUM characters. Use ``--columns=inf'' to disable wrapping.

--help

Print a short usage message.

--logfile=FILE

Write output to FILE. If --logfile is not used, then the environment variable LEAKER_LOG is used, leakers falls back to the filename ``LEAKER_LOG'' if neither environment variable of command line switch is available.

--type=TYPE

Controls what is output. TYPE can be any of: twiceseen, unknownfree, freestream, unknownclose, closeheap, memoryleak, fileleak, error. See OUTPUT for descriptions of these. The default is to output warnings for all. If more than one --type argument is given, then the union of all arguments is used. Can give multiple types with one --type switch if they are comma-seperated (for example: --type=memoryleak,fileleak,error).

COMMAND

The C program linked against libleakers.a to run, including command line arguments to the program. COMMAND is passed all arguments ARG1, ARG2, etc.

The -- preceding COMMAND is only needed if any of the arguments to COMMAND are preceded by a dash. There must be whitespace between -- and COMMAND.


OUTPUT

These are all the different possible errors that leakers prints out, this also describes what the different arguments to --type mean.

Close heap

fclose() was called on memory allocated by malloc/alloc/realloc().

ERROR

Indicates a function returned an error indication.

Free stream

free() was called on a file stream.

Memory leak

A piece of memory returned by an allocation function was never passed to a free function.

File leak

A file stream was opened but not closed.

Twice seen

A neurotic one. Probably means that lkr_register() and lkr_free() are not being used correctly. Or libleakers could be broken.

Unknown close

Possibly trying to fclose() a NULL value? or it could be that you forgot to call lkr_register() and then called fclose() or lkr_free().

Unknown free

Same as ``Unknown close'', but with free() instead.


EXAMPLE

Supposing leaker.h and libleaker.a are installed in /usr/local/include and /usr/local/lib respectively, this links test.c against libleakers, makes the COLUMNS environment variable accessible to leakers, and runs leakers. leakers will first run test with the arguments -hi mom, and then leakers will examine the log which was written to /tmp/leakers.out.

 $ gcc -I/usr/local/include -L/usr/local/lib -o test test.c -lleakers
 $ export COLUMNS
 $ leakers --logfile=/tmp/leakers.out --type=memoryleak,fileleak \
   -- ./test -hi mom


AUTHOR

gabriel m deal <gmd@yellowleaf.org>