Presentation is loading. Please wait.

Presentation is loading. Please wait.

Debugging Memory Issues

Similar presentations


Presentation on theme: "Debugging Memory Issues"— Presentation transcript:

1 Debugging Memory Issues
William Cohen NCSU CSC 591W February 20, 2008

2 Memory Problems: Uninitialized memory Memory leaks Double frees
Out of bound array accesses Null pointers Memory corruption FOSS Tools/Solutions: Valgrind Mudflap

3 Valgrind Introduction
Provides a number of tools to analyze programs: Memory error checkers Heap profiler (catch excessive memory use) Cache profiler (also give coverage information) Works code using shared libraries and threads Available for i386 and x86_64 Linux

4 Valgrind Concepts Instruments executables with binary rewrites
Works with existing executables and shared libs Avoids recompiling code Tools instrument particular operations and functions (e.g. Memory reads/writes and malloc) Space and time overheads introduced by instrumentation and binary rewrites Can write custom instrumentation

5 Valgrind Memory Error Detection (memcheck)
Tracks memory allocated and freed Detects reads/writes to uninitialized and freed memory Detects memory leaks

6 Valgrind Heap Profiler (massif)
Provides information on: Number of heap blocks Amount of memory used Stack sizes Tool output includes summaries for each process.

7 Valgrind Cache Profiler (cachegrind)
Simulates processors caches Can provide code coverage information

8 Valgrind Demonstrations

9 Mudflap Introduction Compile-time instrumentation
Shared libraries are not instrumented Includes array bounds checking Built into recent versions of gcc

10 Mudflap Demonstrations

11 Further Reading Steve Best, Linux Debugging and Performance Tuning: Tips and Techniques, Prentice Hall, 2006.


Download ppt "Debugging Memory Issues"

Similar presentations


Ads by Google