Wednesday, October 19, 2011
11:00 AM

Tool for Detecting Memory Management Problems in Programs - Valgrind

Valgrind is a powerful tool for detecting memory management problems in programs. The kinds of problems it can detect are often very difficult to find by other means and often cause difficult to diagnose crashes. Valgrind can be used with existing executables without recompiling or relinking, although the output it produces will be much more useful if you have compiled with the -g flag.

Valgrind Capabilities
Valgrind is basically an x86 emulator that checks all reads and writes of memory, intercepts all calls to allocate and deallocate memory. The memcheck tool of valgrind (which is the main tool and the only one covered in this chapter) can detect the following:

 * Use of uninitialized memory
 * Reading/writing memory after it has been free'd
 * Reading/writing off the end of malloc'd blocks
 * Reading/writing inappropriate areas below the stack.
 * Memory leaks
 * Mismatched use of malloc/new/new[] vs free/delete/delete[]
 * Overlapping src and dst pointers in memcpy() and related functions
 * Doubly freed memory
 * Passing unaddressable bytes to a system call

Continue Reading...

0 comments:

Post a Comment