Checker

 [image of the Head of a GNU] (jpeg 7k) (jpeg 21k) no gifs due to patent problems

Checker is a tool which finds memory errors at runtime.

Its primary function is to emit a warning when an uninitialized variable or memory area is read or when the program accesses to a protected memory area.

The malloc library of Checker is very robust, this makes it a bit slower than GNU Malloc. Checker issues warnings when:

Checker's malloc will refrain from reusing a freed block for some additional number of calls to free. It does this in order to catch accesses to the block after it has been freed.

Checker implements a garbage detector that can be called either in your program, by a debugger such as gdb, or upon program exit. The garbage detector displays all the memory leaks along with the functions that called malloc().

Example

Here's a bogus file example.c
  #include <stdlib.h>

  int
  main ()
  {
    char *zone = malloc (20);
    char *ptr = NULL;
    int i;
    char c;

    c = zone[1];     /* error: read an uninitialized char */
    c = zone[-2];    /* error: read before the zone */
    zone[25] = ' ';  /* error: write after the zone */
    *ptr = 2;	     /* error: use a NULL pointer,
                        must produce a core */
  }
This example can be easily compiled with Checker, simply use checkergcc instead of gcc:
  % checkergcc -o example example.c
    
And now, you can run it:
  % ./example
    
And during the executing, warnings are emitted:
Checker 0.9 (sparc-sun-solaris2.5.1) Copyright (C) 1998 Tristan Gingold.
Checker is a memory access detector.
Checker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
For more information, set CHECKEROPTS to `--help'
From Checker (pid:04713): `./example' is running (Sun Jan 18 14:56:49 1998)

From Checker (pid:04713): (ruh) read uninitialized byte(s) in a block.
When Reading 1 byte(s) at address 0x000398a1, inside the heap (sbrk).
1 bytes into a block (start: 0x398a0, length: 20, mdesc: 0x0).
The block was allocated from:
	pc=0x00022f1c in chkr_malloc() at ../stubs/stubs-malloc.c:51
	pc=0x0001339c in main() at ../example.c:7
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
Stack frames are:
	pc=0x000133f4 in main() at ../example.c:12
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
From Checker (pid:04713): (bvh) block bounds violation in the heap.
When Reading 1 byte(s) at address 0x0003989e, inside the heap (sbrk).
2 bytes before a block (start: 0x398a0, length: 20, mdesc: 0x0).
The block was allocated from:
	pc=0x00022f1c in chkr_malloc() at ../stubs/stubs-malloc.c:51
	pc=0x0001339c in main() at ../example.c:7
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
Stack frames are:
	pc=0x00013434 in main() at ../example.c:13
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
From Checker (pid:04713): (bvh) block bounds violation in the heap.
When Writing 1 byte(s) at address 0x000398b9, inside the heap (sbrk).
5 bytes after a block (start: 0x398a0, length: 20, mdesc: 0x0).
The block was allocated from:
	pc=0x00022f1c in chkr_malloc() at ../stubs/stubs-malloc.c:51
	pc=0x0001339c in main() at ../example.c:7
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
Stack frames are:
	pc=0x0001345c in main() at ../example.c:14
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
From Checker (pid:04713): (nza) null zone addressed.
When Writing 1 byte(s) at address 0x00000000, inside the NULL zone.
You probably deferenced a null pointer.
THIS SHOULD CAUSE A SEGMENTATION FAULT.
Stack frames are:
	pc=0x0001347c in main() at ../example.c:15
	pc=0x000155f0 in startup() at ../config/sparc/solaris2/startup.c:148
	pc=0x00013298 in *unknown*() at *unknown*:0
From Checker (pid:04713): (sig) signal.
Receive signal 11 (SEGV): (default action: terminate core ).

Segmentation fault
    

Current status

At this time, the current version, 0.9.4, is available on alpha.gnu.org/gnu/. It was ported to You need gcc-2.8.1 to use Checker. Feel free to send any comments, questions or remarks to bug-checker@gnu.org
Return to
GNU's home page.

Please send FSF & GNU inquiries & questions to gnu@prep.ai.mit.edu. There are also other ways to contact the FSF.

Please send comments on these web pages to webmasters@www.gnu.org, send other questions to gnu@prep.ai.mit.edu.

Copyright (C) 1997 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA

Verbatim copying and distribution is permitted in any medium, provided this notice is preserved.

Updated: 20 Aug 1997 rms