Automatically Diagnosing and Repairing Error Handling Bugs in C

Slides:



Advertisements
Similar presentations
Native x86 Decompilation Using Semantics-Preserving Structural Analysis and Iterative Control-Flow Structuring Edward J. Schwartz *, JongHyup Lee ✝, Maverick.
Advertisements

1/20 Generalized Symbolic Execution for Model Checking and Testing Charngki PSWLAB Generalized Symbolic Execution for Model Checking and Testing.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
Software Testing and Quality Assurance
SIM5102 Software Evaluation
Parameterizing Random Test Data According to Equivalence Classes Chris Murphy, Gail Kaiser, Marta Arias Columbia University.
Testing an individual module
1 Software Testing and Quality Assurance Lecture 5 - Software Testing Techniques.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Language Evaluation Criteria
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Verification and Validation Overview References: Shach, Object Oriented and Classical Software Engineering Pressman, Software Engineering: a Practitioner’s.
Department of Computer Science A Static Program Analyzer to increase software reuse Ramakrishnan Venkitaraman and Gopal Gupta.
Mining and Analysis of Control Structure Variant Clones Guo Qiao.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Testing Techniques Software Testing Module ( ) Dr. Samer Hanna.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Automated Patch Generation Adapted from Tevfik Bultan’s Lecture.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
/ PSWLAB Evidence-Based Analysis and Inferring Preconditions for Bug Detection By D. Brand, M. Buss, V. C. Sreedhar published in ICSM 2007.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Automatically Detecting Error Handling Bugs using Error Specifications Suman Jana 1, Yuan Kang 1, Samuel Roth 2, Baishakhi Ray 3 1 Columbia University.
A Review of Software Testing - P. David Coward
SOFTWARE TESTING Date: 29-Dec-2016 By: Ram Karthick.
Compiler Design (40-414) Main Text Book:
Chapter 7: User-Defined Functions II
Software Testing.
Design by Contract Jim Fawcett CSE784 – Software Studio
Control Flow Testing Handouts
Handouts Software Testing and Quality Assurance Theory and Practice Chapter 4 Control Flow Testing
Introduction to Parsing (adapted from CS 164 at Berkeley)
Input Space Partition Testing CS 4501 / 6501 Software Testing
Chapter 8 – Software Testing
APEx: Automated Inference of Error Specifications for C APIs
Verification and Validation Overview
Outline of the Chapter Basic Idea Outline of Control Flow Testing
CBCD: Cloned Buggy Code Detector
Some Simple Definitions for Testing
CS416 Compiler Design lec00-outline September 19, 2018
CHAPTER 4 Test Design Techniques
Testing UW CSE 160 Spring 2018.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
High Coverage Detection of Input-Related Security Faults
Introduction CI612 Compiler Design CI612 Compiler Design.
Human Complexity of Software
Software testing.
[jws13] Evaluation of instance matching tools: The experience of OAEI
Chapter 10 – Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Review Session Biggest discrepancy questions
CS416 Compiler Design lec00-outline February 23, 2019
CSE403 Software Engineering Autumn 2000 More Testing
Institute of Computing Tech.
Regression Testing.
Software Testing “If you can’t test it, you can’t design it”
Chapter 10: Compilers and Language Translation
Precise Condition Synthesis for Program Repair
Lec00-outline May 18, 2019 Compiler Design CS416 Compiler Design.
Bug Localization with Combination of Deep Learning and Information Retrieval A. N. Lam et al. International Conference on Program Comprehension 2017.
CHAPTER 6 Testing and Debugging.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing and QA Theory and Practice (Chapter 5: Data Flow Testing) © Naik & Tripathy 1 Software Testing and Quality Assurance Theory and Practice.
Presentation transcript:

Automatically Diagnosing and Repairing Error Handling Bugs in C Yuchi tian, Baishakhi ray University of virginia G201892008 처그

Context Abstract Introduction Manual Study Overview Study Result Conclusion

Abstract Correct error handling is essentials for building reliable and secure systems. However, developers often make mistake while writing error handling code. Therefore, it is crucial to develop tool supports for automatically detecting and fixing error handling bugs. ErrDoc (Error Doctor) a tool that can detects and characterizes different types of error handling bugs and fixing them automatically.

Introduction Low - level language like C don’t have native error handling primitives. Therefore, developers should create their own error handling conventions. Error handling code is repetitive and tedious to write correctly, resulting error handling bug. Manually creating test cases to cover all possible error path is not scalable for large real – world programs.

Introduction We design ErrDoc, a tool automatically detect, categorize, and fix error handling bugs. We present, first classification of error handling bugs into four different categories. Incorrect/Missing Error Propagation Incorrect/Missing Error Checks, Incorrect/Missing Error Outputs, Incorrect/Missing Resource Release We present an extensive evaluation of ErrDoc on five large open source software. (OpenSSL, GnuTLS, WolfSSL, Curl, Httpd)

Manual Study Study Object. 13M LOC, 30K commits, 8 years

Manual Study Study Method. Begin with extracting all the changes committed within the studied time period. First, from the commit messages remove stopwords, punctuations, and other program – identified – related informations, and the commit message using standart NLP techniques.

Manual Study We mark the corresponding commit to be bug – fix –related if the process messages contain at least one of the following key words. “bug”, “fix”, “check”, “issue”, “mistake”, “incorrect”, “fault”, “defect”, “leak” Among the identified bug-fix commits, we further search for some combinations of error handling bug-related keywords: “error path”, “memory leak”, “unchecked return”, “error handl”, “error check”, “check return”

Manual Study For example: we identify an OpenSSL commit (sha: 0a618df) with commit message :“Fix a mem leak on an error path" as a error handling bug-fix commit. To evaluate the precision of the above classification, we randomly choose 120 commits (20 from each project) that are marked as error handling bug-fix. Out of 120 commits, 115 are classified correctly. thus, giving a precision of 95.83%.

Manual Study Characterization of the bug & fixes

Manual Study EC: Incorrect/Missing Error Check.

Manual Study EC: Incorrect/Missing Error Check.

Manual Study EP: Incorrect/Missing Error Propagation.

Manual Study EO: Incorrect/Missing Error Outputs.

Manual Study RR: Incorrect/Missing Resource Release.

Manual Study Other error handling bugs. 17 out of 145 (11.72%) bugs arise due some other issues in error handling code, which may not be directly related error handling bugs.

Overview (f) – The signature of fallible function (fcaller) – Caller functions (ferrSpec) – (f)’s error specification (GlobalnerrSpec) – Global non error specification (Loggers) – List of logging functions

Overview (f) – Given function under the test. (fcaller) – Caller function (ferrSpec) – Error specification ErrDoc symbolically executes f and checks its return value (fret) at the call site along all the possible value. If fret ^ ferrSpec is satisfiable marked as an error path.

Overview Phase I. Explore error paths. I - a. Identify error paths. Given each caller and callee pair, ErrDoc detects all possible error paths. I - b. Identifies error handling code along each error path. I – c. Looks for function pairs that often occur together along error paths.

Overview Phase II. Detect & Categorize Error Handling Bugs this phase outputs buggy program location and corresponding bug category. Incorrect/Missing Error Propagation (EP): ErrDoc finds a return statement in fcaller ErrDoc checks whether the return value at fcaller can contain non-error values according to GlobalnerrSpec If it can contain only non – error values ErrDoc marks the corresponding return localation as a source of EP bug If return statement contain error and non error values ErrDoc marks location as maybe EP bug asdasda

Overview ErrDoc further checks whether the return statement is part of an error handling code; If true it marks a maybe bug to EP bug For example:

Overview Incorrect/Missing Error Checks (EC). If for functions f and its caller fcaller , an EP bug is diagnosed in the previous step and along the corresponding buggy error path in fcaller no error handling code for f is found, ErrDoc reports it as a potential missing EC bug. Incorrect/Missing Error Outputs (EO): An exit statement encountered, ErrDoc makes sure the error situation is logged before exiting. ErrDoc then checks whether a logging function is called before exiting. ErrDoc also checks the constraints on the symbolic argument of the exit function to ensure they can have error values.

Overview Incorrect/Missing Resource Release (RR). ErrDoc checks whether there is any corresponding paired functions from FP list. If it found, ErrDoc then looks for those paired functions along this error paths and checks the corresponding signatures along error path in fcaller’s CFG. If none of the paired functions are found or none of the found paired functions satisfies any of the dependency specified in the functions pairs signatures ErrDoc reports a potential RR bug.

Overview

Overview Phase III. Fix Error handling Bugs ErrDoc detected and reported error. To fix the bug, ErrDoc takes three inputs: (buggy program locations, source code line number, the bug category) First, ErrDoc traverses fcaller ‘s AST (Abstract Syntax Tree) and locates the AST nodes and its associated subtree that match the buggy program locations. Next, depending on the bug category ErrDoc constructs an AST subtree to fix bug. Finally ErrDoc applies the fix to the original buggy AST by dleting and adding existing AST nodes and edges.

Overview

Study Result How accurately ErrDoc detects error handling bugs?

Study Result How accurately ErrDoc detects function pairs?

Study Result f - target function, provides an automatic divider between resource allocation and deallocation fuctions (used as partitioning function). data-dep – data dependency, analysis between arguments and return values to the function pairs. Errorpapaths reduce search space and thus introduce less noise in function ir analysis. Top 1 – Recall is lower than top2 and 3 as we disregard some valid pairs (two-to-one or one-to-two function pairs).

Study Result How accurately ErrDoc categorizes error handling bugs?

Study Result False positive: False negative: The caller doesn’t follow the global error/non-error values. Different logging function is used. False negative: The caller doesn’t follow the non-error values. Function pairs don’t have any data-dependency.

Study Result How accurately Errdoc fixes error handling bugs?

Study Result Semantic equivalence – Declaration that two data elements from different vocabularies contain data that has similar meaning

Study Result Example:

Study Result Manually injected bug: Real bug: Different logging messages between the patches generated by ErrDoc and the original code. Real bug: Developers use different logging messages. For some EP bug, Developers return a specific meaningful error value instead of a global error returned by ErrDoc. For some RR bug, Developers put all the deallocation routine calls at the end of the caller function, and insert goto statement to the EH code.

Conclusion We design, implement and evaluate ErrDoc that automatically detects, diagnose, and fixes error handling bugs. Evaluating ErrDoc on five open-source code bases. ErrDoc can detect error handling bugs with high accuracy. It outperforms the precision of existing tool EPEx up to 5 percentage points and recall up to 44 percentage points.