Tracking Bad Apples: Reporting the Origin of Null & Undefined Value Errors Michael D. Bond UT Austin Nicholas Nethercote National ICT Australia Stephen.

Slides:



Advertisements
Similar presentations
Department of Computer Sciences Dynamic Shape Analysis via Degree Metrics Maria Jump & Kathryn S. McKinley Department of Computer Sciences The University.
Advertisements

Eclipse TPTP TPTP Heap and Thread Profilers High-level Design Rev 1.0 Asaf Yaffe July, 2006.
Identity and Equality Based on material by Michael Ernst, University of Washington.
Names and Bindings.
Michael Bond Kathryn McKinley The University of Texas at Austin Presented by Na Meng Most of the slides are from Mike’s original talk. Many thanks go to.
Chapter 7:: Data Types Programming Language Pragmatics
Various languages….  Could affect performance  Could affect reliability  Could affect language choice.
Probabilistic Calling Context Michael D. Bond Kathryn S. McKinley University of Texas at Austin.
Precise Detection of Memory Leaks Jonas Maebe, Michiel Ronsse, Koen De Bosschere WODA May 2004 Dammit, Jim. I’m an Eiffel Tower, not a Star Trek.
Hastings Purify: Fast Detection of Memory Leaks and Access Errors.
CORK: DYNAMIC MEMORY LEAK DETECTION FOR GARBAGE- COLLECTED LANGUAGES A TRADEOFF BETWEEN EFFICIENCY AND ACCURATE, USEFUL RESULTS.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
LeakChaser: Helping Programmers Narrow Down Causes of Memory Leaks Guoqing Xu, Michael D. Bond, Feng Qin, Atanas Rountev Ohio State University.
Dynamic Tainting for Deployed Java Programs Du Li Advisor: Witawas Srisa-an University of Nebraska-Lincoln 1.
Approaches to Typing Programming Languages Robert Dewar.
MemTracker Efficient and Programmable Support for Memory Access Monitoring and Debugging Guru Venkataramani, Brandyn Roemer, Yan Solihin, Milos Prvulovic.
Bell: Bit-Encoding Online Memory Leak Detection Michael D. Bond Kathryn S. McKinley University of Texas at Austin.
Introduction to Java.
Shallow Versus Deep Copy and Pointers Shallow copy: when two or more pointers of the same types point to the same memory – They point to the same data.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Tolerating Memory Leaks Michael D. Bond Kathryn S. McKinley.
Chapter 1 Algorithm Analysis
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
P ath & E dge P rofiling Michael Bond, UT Austin Kathryn McKinley, UT Austin Continuous Presented by: Yingyi Bu.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Fast Conservative Garbage Collection Rifat Shahriyar Stephen M. Blackburn Australian National University Kathryn S. M cKinley Microsoft Research.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
1 Fast and Efficient Partial Code Reordering Xianglong Huang (UT Austin, Adverplex) Stephen M. Blackburn (Intel) David Grove (IBM) Kathryn McKinley (UT.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Use of Coverity & Valgrind in Geant4 Gabriele Cosmo.
Dynamic Object Sampling for Pretenuring Maria Jump Department of Computer Sciences The University of Texas at Austin Stephen M. Blackburn.
Constructors CMSC 202. Object Creation Objects are created by using the operator new in statements such as… The following expression invokes a special.
Breadcrumbs: Efficient Context Sensitivity for Dynamic Bug Detection Analyses Michael D. Bond University of Texas at Austin Graham Z. Baker Tufts / MIT.
User-defined type checkers for error detection and prevention in Java Michael D. Ernst MIT Computer Science & AI Lab
Aritra Sengupta, Swarnendu Biswas, Minjia Zhang, Michael D. Bond and Milind Kulkarni ASPLOS 2015, ISTANBUL, TURKEY Hybrid Static-Dynamic Analysis for Statically.
Types(1). Lecture 52 Type(1)  A type is a collection of values and operations on those values. Integer type  values..., -2, -1, 0, 1, 2,...  operations.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
380C lecture 19 Where are we & where we are going –Managed languages Dynamic compilation Inlining Garbage collection –Opportunity to improve data locality.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
 Asserting Expectations. Introduction -Observation alone is not enough for debugging as it can be a burden for a programmer. -One must compare observed.
1 Garbage Collection Advantage: Improving Program Locality Xianglong Huang (UT) Stephen M Blackburn (ANU), Kathryn S McKinley (UT) J Eliot B Moss (UMass),
Dynamic Analysis and Visualizing of Data Structures in Java Programs Presented by Sokhom Pheng (Supervisor: Clark Verbrugge) McGill University February.
Protecting C Programs from Attacks via Invalid Pointer Dereferences Suan Hsi Yong, Susan Horwitz University of Wisconsin – Madison.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
CMSC 202 Advanced Section Classes and Objects: Object Creation and Constructors.
Software Development Introduction
Vertical Profiling : Understanding the Behavior of Object-Oriented Applications Sookmyung Women’s Univ. PsLab Sewon,Moon.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Preventing bugs with pluggable type-checking Michael Ernst MIT
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/11/2006 Lecture 7 – Introduction to C.
GC Assertions: Using the Garbage Collector To Check Heap Properties Samuel Z. Guyer Tufts University Edward Aftandilian Tufts University.
Findbugs Tin Bui-Huy September, Content What is bug? What is bug? What is Findbugs? What is Findbugs? How to use Findbugs? How to use Findbugs?
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Dynamic Bug Detection & Tolerance Kathryn S McKinley The University of Texas at Austin.
Code improvement: Coverity static analysis Valgrind dynamic analysis GABRIELE COSMO CERN, EP/SFT.
Object Lifetime and Pointers
Debugging Memory Issues
Type Checking Generalizes the concept of operands and operators to include subprograms and assignments Type checking is the activity of ensuring that the.
Cork: Dynamic Memory Leak Detection with Garbage Collection
CSE 374 Programming Concepts & Tools
Accessible Formal Methods A Study of the Java Modeling Language
C Basics.
Java Virtual Machine Complete subject details are available at:
High Coverage Detection of Input-Related Security Faults
Classes and Objects Object Creation
JIT Compiler Design Maxine Virtual Machine Dhwani Pandya
CMSC 202 Constructors Version 9/10.
Presentation transcript:

Tracking Bad Apples: Reporting the Origin of Null & Undefined Value Errors Michael D. Bond UT Austin Nicholas Nethercote National ICT Australia Stephen W. Kent UT Austin Samuel Z. Guyer Tufts University Kathryn S. McKinley UT Austin

Example Code User code: float[][] data = {{1.0f, 2.0f}, {3.0f, 4.0f}}; ScatterPlot plot = new ScatterPlot(data, null);... plot.draw(...);

Example Code float[][] data = {{1.0f, 2.0f}, {3.0f, 4.0f}}; ScatterPlot plot = new ScatterPlot(data, null);... NullPointerException at ScatterPlot.draw():315 at Test.doStuff():124 User code: plot.draw(...);

Example Code User code: Library code: NullPointerException at ScatterPlot.draw():315 at Test.doStuff():124 ScatterPlot { draw(...) {... xaxis.draw();... } plot.draw(...); float[][] data = {{1.0f, 2.0f}, {3.0f, 4.0f}}; ScatterPlot plot = new ScatterPlot(data, null);...

Unusable Value Null is unusable value  Use causes error How/why did it become null?  Null’s origin? ScatterPlot { draw(...) {... xaxis.draw();... } plot.draw(...); NullPointerException at ScatterPlot.draw():315 at Test.doStuff():124

Origin of Unusable Value ScatterPlot { draw(...) {... xaxis.draw();... } plot.draw(...); float[][] data = {{1.0f, 2.0f}, {3.0f, 4.0f}}; ScatterPlot plot = new ScatterPlot(data, null);... Origin: Test.init():37

Origin of Unusable Value ScatterPlot { ScatterPlot(data, xaxis) { this.data = data; this.xaxis = xaxis; }... draw(...) {... xaxis.draw();... } Origin: Test.init():37 plot.draw(...); float[][] data = {{1.0f, 2.0f}, {3.0f, 4.0f}}; ScatterPlot plot = new ScatterPlot(data, null);... Origin: Test.init():37

Origin Tracking ScatterPlot { ScatterPlot(data, xaxis) { this.data = data; this.xaxis = xaxis; }... draw(...) {... xaxis.draw();... } Origin: Test.init():37 plot.draw(...); float[][] data = {{1.0f, 2.0f}, {3.0f, 4.0f}}; ScatterPlot plot = new ScatterPlot(data, null);... Origin: Test.init():37 Track every unusable value’s origin for 4% overhead Key: store origin in place of unusable value

Outline Introduction Unusable values Instances of origin tracking  Null pointer exceptions (Java)  Undefined value errors (C/C++) Redefining program operations Evaluation  Performance  Usefulness Related Work

Unusable Values Using value causes error Examples:  Null values  Undefined values Tough bugs: no info Why is value unusable?  Where did unusable value originate?

Unusable Values Using value causes error Examples:  Null values  Undefined values Tough bugs: no info Why is value unusable?  Where did unusable value originate? Opportunity: Store info in place of value

Origin Tracking Implementations Null pointers (Java)  Jikes RVM Undefined values (native code)  Valgrind’s MemCheck

Origin Tracking Implementations Null pointers (Java)  Jikes RVM Undefined values (native code)  Valgrind’s MemCheck Jikes RVM Research Archive Valgrind Source Code Repository

Origin Tracking Implementations Null pointers (Java)  Jikes RVM Undefined values (native code)  Valgrind’s MemCheck  Identifies origin for 32-bit values 47 of 147 are 32-bit For 32-bit: 34 of 47 identified  Adds negligible overhead (28X  28X) Jikes RVM Research Archive Valgrind Source Code Repository

Storing Origins in Null Values Requirements  Need bits in null values  multiple null values  Program operations support null values  Recover origin at exception

Storing Origins in Null Values Requirements  Need bits in null values  multiple null values  Program operations support null values  Recover origin at exception Null  high 5 bits are zero (27 bits available) Reserve & protect address range: 0x –0x07ffffff Bytecode indexMethod ID bits14 bits13 bits

Implementing Java Operations Java semanticsStandard VMOrigin tracking Assignment of null constant obj = null;obj = 0;obj = this_location; Object allocation obj = new Object(); foreach ref slot i obj[i] = 0; foreach ref slot i obj[i] = this_location; Null reference comparison if (obj == null) {if (obj == 0) {if ((obj & 0xf ) == 0) { General reference comparison if (obj1 == obj2) { if (((obj1 & 0xf ) == 0) ? ((obj2 & 0xf ) == 0) : (obj1 == obj2)) {

Implementing Java Operations Java semanticsStandard VMOrigin tracking Assignment of null constant obj = null;obj = 0;obj = this_location; Object allocation obj = new Object(); foreach ref slot i obj[i] = 0; foreach ref slot i obj[i] = this_location; Null reference comparison if (obj == null) {if (obj == 0) {if ((obj & 0xf ) == 0) { General reference comparison if (obj1 == obj2) { if (((obj1 & 0xf ) == 0) ? ((obj2 & 0xf ) == 0) : (obj1 == obj2)) {

Implementing Java Operations Java semanticsStandard VMOrigin tracking Assignment of null constant obj = null;obj = 0;obj = this_location; Object allocation obj = new Object(); foreach ref slot i obj[i] = 0; foreach ref slot i obj[i] = this_location; Null reference comparison if (obj == null) {if (obj == 0) {if ((obj & 0xf ) == 0) { General reference comparison if (obj1 == obj2) { if (((obj1 & 0xf ) == 0) ? ((obj2 & 0xf ) == 0) : (obj1 == obj2)) {

Implementing Java Operations Java semanticsStandard VMOrigin tracking Assignment of null constant obj = null;obj = 0;obj = this_location; Object allocation obj = new Object(); foreach ref slot i obj[i] = 0; foreach ref slot i obj[i] = this_location; Null reference comparison if (obj == null) {if (obj == 0) {if ((obj & 0xf ) == 0) { General reference comparison if (obj1 == obj2) { if (((obj1 & 0xf ) == 0) ? ((obj2 & 0xf ) == 0) : (obj1 == obj2)) {

Implementing Java Operations Java semanticsStandard VMOrigin tracking Assignment of null constant obj = null;obj = 0;obj = this_location; Object allocation obj = new Object(); foreach ref slot i obj[i] = 0; foreach ref slot i obj[i] = this_location; Null reference comparison if (obj == null) {if (obj == 0) {if ((obj & 0xf ) == 0) { General reference comparison if (obj1 == obj2) { if (((obj1 & 0xf ) == 0) ? ((obj2 & 0xf ) == 0) : (obj1 == obj2)) {

Implementing Java Operations Java semanticsStandard VMOrigin tracking Assignment of null constant obj = null;obj = 0;obj = this_location; Object allocation obj = new Object(); foreach ref slot i obj[i] = 0; foreach ref slot i obj[i] = this_location; Null reference comparison if (obj == null) {if (obj == 0) {if ((obj & 0xf ) == 0) { General reference comparison if (obj1 == obj2) { if (((obj1 & 0xf ) == 0) ? ((obj2 & 0xf ) == 0) : (obj1 == obj2)) { General assignment obj1 = obj2;

Outline Introduction Unusable values Instances of origin tracking  Null pointer exceptions (Java)  Undefined value errors (C/C++) Redefining program operations Evaluation  Performance  Usefulness Related Work

Adaptive methodology  Mix of application & compilation time  Single iteration; 25 trials DaCapo, SPEC JBB2000, SPEC JVM GHz Pentium 4 w/Linux Methodology

Performance of Java Implementation

Finding and Fixing Bugs 12 real NPEs from SourceForge Origin: identified by origin tracking? Triviality: origin obvious by inspection? Usefulness: origin useful for fixing bug?

Null Pointer Exceptions ProgramLinesException descriptionOrigin?Trivial?Useful? Mckoi SQL DB94,681Access closed connectionYesNontrivialDefinitely useful FreeMarker64,442JUnit test crashes unexpectedlyYesNontrivialDefinitely useful JFreeChart223,869Plot without x-axisYesNontrivialDefinitely useful JRefactory231,338Invalid class nameYesNontrivialDefinitely useful Eclipse2,425,709Malformed XML documentYesNontrivialMost likely useful Checkstyle47,871Empty default caseYesNontrivialMost likely useful JODE44,937Exception decompiling classYesNontrivialMost likely useful Jython144,739Use built-in class as variableYesNontrivialPotentially useful JFreeChart223,869Stacked XY plot with linesYes Somewhat nontrivial Marginally useful Jython144,739Problem accessing __doc__Yes Somewhat nontrivial Marginally useful JRefactory231,338Package and import on same lineYesTrivialNot useful Eclipse2,425,709Close Eclipse while deleting projectYesTrivialNot useful

Null Pointer Exceptions ProgramLinesException descriptionOrigin?Trivial?Useful? Mckoi SQL DB94,681Access closed connectionYesNontrivialDefinitely useful FreeMarker64,442JUnit test crashes unexpectedlyYesNontrivialDefinitely useful JFreeChart223,869Plot without x-axisYesNontrivialDefinitely useful JRefactory231,338Invalid class nameYesNontrivialDefinitely useful Eclipse2,425,709Malformed XML documentYesNontrivialMost likely useful Checkstyle47,871Empty default caseYesNontrivialMost likely useful JODE44,937Exception decompiling classYesNontrivialMost likely useful Jython144,739Use built-in class as variableYesNontrivialPotentially useful JFreeChart223,869Stacked XY plot with linesYes Somewhat nontrivial Marginally useful Jython144,739Problem accessing __doc__Yes Somewhat nontrivial Marginally useful JRefactory231,338Package and import on same lineYesTrivialNot useful Eclipse2,425,709Close Eclipse while deleting projectYesTrivialNot useful

Null Pointer Exceptions ProgramLinesException descriptionOrigin?Trivial?Useful? Mckoi SQL DB94,681Access closed connectionYesNontrivialDefinitely useful FreeMarker64,442JUnit test crashes unexpectedlyYesNontrivialDefinitely useful JFreeChart223,869Plot without x-axisYesNontrivialDefinitely useful JRefactory231,338Invalid class nameYesNontrivialDefinitely useful Eclipse2,425,709Malformed XML documentYesNontrivialMost likely useful Checkstyle47,871Empty default caseYesNontrivialMost likely useful JODE44,937Exception decompiling classYesNontrivialMost likely useful Jython144,739Use built-in class as variableYesNontrivialPotentially useful JFreeChart223,869Stacked XY plot with linesYes Somewhat nontrivial Marginally useful Jython144,739Problem accessing __doc__Yes Somewhat nontrivial Marginally useful JRefactory231,338Package and import on same lineYesTrivialNot useful Eclipse2,425,709Close Eclipse while deleting projectYesTrivialNot useful

Null Pointer Exceptions ProgramLinesException descriptionOrigin?Trivial?Useful? Mckoi SQL DB94,681Access closed connectionYesNontrivialDefinitely useful FreeMarker64,442JUnit test crashes unexpectedlyYesNontrivialDefinitely useful JFreeChart223,869Plot without x-axisYesNontrivialDefinitely useful JRefactory231,338Invalid class nameYesNontrivialDefinitely useful Eclipse2,425,709Malformed XML documentYesNontrivialMost likely useful Checkstyle47,871Empty default caseYesNontrivialMost likely useful JODE44,937Exception decompiling classYesNontrivialMost likely useful Jython144,739Use built-in class as variableYesNontrivialPotentially useful JFreeChart223,869Stacked XY plot with linesYes Somewhat nontrivial Marginally useful Jython144,739Problem accessing __doc__Yes Somewhat nontrivial Marginally useful JRefactory231,338Package and import on same lineYesTrivialNot useful Eclipse2,425,709Close Eclipse while deleting projectYesTrivialNot useful

Null Pointer Exceptions ProgramLinesException descriptionOrigin?Trivial?Useful? Mckoi SQL DB94,681Access closed connectionYesNontrivialDefinitely useful FreeMarker64,442JUnit test crashes unexpectedlyYesNontrivialDefinitely useful JFreeChart223,869Plot without x-axisYesNontrivialDefinitely useful JRefactory231,338Invalid class nameYesNontrivialDefinitely useful Eclipse2,425,709Malformed XML documentYesNontrivialMost likely useful Checkstyle47,871Empty default caseYesNontrivialMost likely useful JODE44,937Exception decompiling classYesNontrivialMost likely useful Jython144,739Use built-in class as variableYesNontrivialPotentially useful JFreeChart223,869Stacked XY plot with linesYes Somewhat nontrivial Marginally useful Jython144,739Problem accessing __doc__Yes Somewhat nontrivial Marginally useful JRefactory231,338Package and import on same lineYesTrivialNot useful Eclipse2,425,709Close Eclipse while deleting projectYesTrivialNot useful

Debugging Timeline Early Late Language design Static analysis Testing Deployment

Debugging Timeline Prevent bugs Memory bugs [Java & C#] Null pointer exceptions [Chalin & James ‘06]  Add “never null” types to Java  Programmer effort  Exceptions still possible Functional languages Early Late Language design Static analysis Testing Deployment

Debugging Timeline Detect errors in any execution [FindBugs] [PMD] [ESC/Java] [JLint] [Metal] Dataflow analysis & pattern matching Program complexity  conservative (false positives) Some intentionally unsound (false negatives) Language design Static analysis Testing Deployment Early Late

Debugging Timeline Catch errors in real executions Assertions Checking tools [Valgrind] [Purify] Dynamic slicing [Agrawal & Horgan ’90] [Zhang et al. ‘07 ] Powerful but high overhead Language design Static analysis Testing Deployment Early Late

Debugging Timeline Ideal environment for debugging? Stack/dump reporting Invariant-based bug detection [Liblit et al. ’05]  Many executions Limited dynamic slicing [TaintCheck] [Chilimbi & Hauswirth ’04] [Origin tracking]  Single execution  Narrow focus Language design Static analysis Testing Deployment Early Late

Summary Unusable values: tough bugs  Error stack trace not enough  Opportunity: store origin in place of unusable value  Managed and native implementations Java null origins: fast, useful, silent Add it to your VM today!

Summary Unusable values: tough bugs  Error stack trace not enough  Opportunity: store origin in place of unusable value  Managed and native implementations Java null origins: fast, useful, silent Add it to your VM today! Thank you!

Extra slides

Runtime Overhead (origin tracking)