Debugging Memory Issues

Slides:



Advertisements
Similar presentations
1 Memory Allocation Professor Jennifer Rexford COS 217.
Advertisements

Week 7 - Friday.  What did we talk about last time?  Allocating 2D arrays.
Tools for applications improvement George Bosilca.
CPSC 388 – Compiler Design and Construction
Traffic Server Debugging using ASAN / TSAN Brian Geffon.
Adapted from Prof. Necula CS 169, Berkeley1 Memory Management and Debugging V Software Engineering Lecture 20.
Memory Arrangement Memory is arrange in a sequence of addressable units (usually bytes) –sizeof( ) return the number of units it takes to store a type.
C and Data Structures Baojian Hua
. Memory Management. Memory Organization u During run time, variables can be stored in one of three “pools”  Stack  Static heap  Dynamic heap.
Memory Layout C and Data Structures Baojian Hua
1 1 Profiling & Optimization David Geldreich (DREAM)
Debugging Print And Imaging Drivers. Print driver team philosophy on driver quality There are tools to detect violations Wrongful development assumptions.
CIS*2450 Seminar I Makefiles Debugging/Design Approaches Exception Handling Library Revision Control Designed by: Terry Moreland Updated by: Tom Crabtree.
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
Analyzing parallel programs with Pin Moshe Bach, Mark Charney, Robert Cohn, Elena Demikhovsky, Tevi Devor, Kim Hazelwood, Aamer Jaleel, Chi- Keung Luk,
Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Sessions of Interest 2.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
Martin Schulz Center for Applied Scientific Computing Lawrence Livermore National Laboratory Lawrence Livermore National Laboratory, P. O. Box 808, Livermore,
RPROM , 2002 Lassi A. Tuura, Northeastern University Using Valgrind Lassi A. Tuura Northeastern University,
1 C++ Classes and Data Structures Jeffrey S. Childs Chapter 4 Pointers and Dynamic Arrays Jeffrey S. Childs Clarion University of PA © 2008, Prentice Hall.
® IBM Software Group © 2006 IBM Corporation PurifyPlus on Linux / Unix Vinay Kumar H S.
Agenda Attack Lab C Exercises C Conventions C Debugging
CSCI Rational Purify 1 Rational Purify Overview Michel Izygon - Jim Helm.
Measuring Memory using valgrind CSCE 221H Parasol Lab, Texas A&M University.
 Asserting Expectations. Introduction -Observation alone is not enough for debugging as it can be a burden for a programmer. -One must compare observed.
Protecting C Programs from Attacks via Invalid Pointer Dereferences Suan Hsi Yong, Susan Horwitz University of Wisconsin – Madison.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Pointers.
Virtual Application Profiler (VAPP) Problem – Increasing hardware complexity – Programmers need to understand interactions between architecture and their.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 10 – C: the heap and manual memory management.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science The University of Arizona, Tucson
1 Debugging (Part 2). “Programming in the Large” Steps Design & Implement Program & programming style (done) Common data structures and algorithms Modularity.
1 C Basics Monday, August 30, 2010 CS 241. Announcements MP1, a short machine problem, will be released today. Due: Tuesday, Sept. 7 th at 11:59pm via.
Presented by Ted Higgins, SQL Server DBA C Programming - Pointers.
CSE 333 – SECTION 2 Memory Management. Questions, Comments, Concerns Do you have any? Exercises going ok? Lectures make sense? Homework 1 – START EARLY!
Improve Embedded System Stability and Performance through Memory Analysis Tools Bill Graham, Product Line Manager Development Tools November 14, 2006.
HP-SEE Valgrind Usage Josip Jakić Scientific Computing Laboratory Institute of Physics Belgrade The HP-SEE initiative.
Qin Zhao1, Joon Edward Sim2, WengFai Wong1,2 1SingaporeMIT Alliance 2Department of Computer Science National University of Singapore
Tools and Techniques for Higher Reliability Software FOSDEM 2013 – Ada Developer Room Philippe Waroquiers Eurocontrol/DNM
Dynamic Instrumentation - Valgrind  Developed by Julian Seward at/around Cambridge University,UK  Google-O'Reilly Open Source Award for "Best Toolmaker"
Memory-Related Perils and Pitfalls in C
a.k.a how we test Your code
Optimistic Hybrid Analysis
Content Coverity Static Analysis Use cases of Coverity Examples
Marian Ivanov, Anar Manafov
Data Watch Presenter Information Jason Puncher and François Tétreault
YAHMD - Yet Another Heap Memory Debugger
CSE 374 Programming Concepts & Tools
Recitation 6: C Review 30 Sept 2016.
Valgrind Overview What is Valgrind?
Advanced course of C/C++
Workshop in Nihzny Novgorod State University Activity Report
Checking Memory Management
Dynamic Instrumentation - Valgrind
High Coverage Detection of Input-Related Security Faults
Jihyun Park, Changsun Park, Byoungju Choi, Gihun Chang
Memory Management III: Perils and pitfalls Mar 13, 2001
Memory Allocation CS 217.
CSc 352 Debugging Tools Saumya Debray Dept. of Computer Science
DPDK: Prevention & Detection of DP/CP memory corruption
Introduction to Static Analyzer
a.k.a how we test Your code
CETS: Compiler-Enforced Temporal Safety for C
TUTORIAL 7 CS 137 F18 October 30th.
Dynamic Memory A whole heap of fun….
Valgrind Overview What is Valgrind?
Dynamic Memory – A Review
Makefiles, GDB, Valgrind
Dynamic Binary Translators and Instrumenters
Week 7 - Friday CS222.
SPL – PS2 C++ Memory Handling.
Presentation transcript:

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

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

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

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

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

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

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

Valgrind Demonstrations

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

Mudflap Demonstrations

Further Reading Steve Best, Linux Debugging and Performance Tuning: Tips and Techniques, Prentice Hall, 2006. http://www.valgrind.org/ http://www.valgrind.org/docs/manual/QuickStart.html http://www.valgrind.org/docs/manual/manual.html http://gcc.fyxm.net/summit/2003/mudflap.pdf