Dynamic Analysis of Multithreaded Java Programs Dr. Abhik Roychoudhury National University of Singapore.

Slides:



Advertisements
Similar presentations
Dataflow Analysis for Datarace-Free Programs (ESOP 11) Arnab De Joint work with Deepak DSouza and Rupesh Nasre Indian Institute of Science, Bangalore.
Advertisements

Bounded Model Checking of Concurrent Data Types on Relaxed Memory Models: A Case Study Sebastian Burckhardt Rajeev Alur Milo M. K. Martin Department of.
CS 267: Automated Verification Lecture 8: Automata Theoretic Model Checking Instructor: Tevfik Bultan.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
ECE 720T5 Fall 2011 Cyber-Physical Systems Rodolfo Pellizzoni.
Testing Concurrent/Distributed Systems Review of Final CEN 5076 Class 14 – 12/05.
Model Checker In-The-Loop Flavio Lerda, Edmund M. Clarke Computer Science Department Jim Kapinski, Bruce H. Krogh Electrical & Computer Engineering MURI.
Background for “KISS: Keep It Simple and Sequential” cs264 Ras Bodik spring 2005.
1 Temporal Claims A temporal claim is defined in Promela by the syntax: never { … body … } never is a keyword, like proctype. The body is the same as for.
ECE 720T5 Fall 2012 Cyber-Physical Systems Rodolfo Pellizzoni.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Atomicity in Multi-Threaded Programs Prachi Tiwari University of California, Santa Cruz CMPS 203 Programming Languages, Fall 2004.
1 Tuesday, November 07, 2006 “If anything can go wrong, it will.” -Murphy’s Law.
DISTRIBUTED AND HIGH-PERFORMANCE COMPUTING CHAPTER 7: SHARED MEMORY PARALLEL PROGRAMMING.
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
Model Checking. Used in studying behaviors of reactive systems Typically involves three steps: Create a finite state model (FSM) of the system design.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
November 18, 2004 Embedded System Design Flow Arkadeb Ghosal Alessandro Pinto Daniele Gasperini Alberto Sangiovanni-Vincentelli
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Formal Engineering of Reliable Software LASER 2004 school Tutorial, Lecture1 Natasha Sharygina Carnegie Mellon University.
Formal verification Marco A. Peña Universitat Politècnica de Catalunya.
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
[ §6 : 1 ] 6. Basic Methods II Overview 6.1 Models 6.2 Taxonomy 6.3 Finite State Model 6.4 State Transition Model 6.5 Dataflow Model 6.6 User Manual.
Thread-modular Abstraction Refinement Thomas A. Henzinger, et al. CAV 2003 Seonggun Kim KAIST CS750b.
Deterministic Replay of Java Multithreaded Applications Jong-Deok Choi and Harini Srinivasan slides made by Qing Zhang.
Cheng/Dillon-Software Engineering: Formal Methods Model Checking.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering.
Course Outline DayContents Day 1 Introduction Motivation, definitions, properties of embedded systems, outline of the current course How to specify embedded.
Timed UML State Machines Ognyana Hristova Tutor: Priv.-Doz. Dr. Thomas Noll June, 2007.
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
ECE 720T5 Winter 2014 Cyber-Physical Systems Rodolfo Pellizzoni.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
Using Model-Checking to Debug Device Firmware Sanjeev Kumar Microprocessor Research Labs, Intel Kai Li Princeton University.
1 A Static Analysis Approach for Automatically Generating Test Cases for Web Applications Presented by: Beverly Leung Fahim Rahman.
Runtime Refinement Checking of Concurrent Data Structures (the VYRD project) Serdar Tasiran Koç University, Istanbul, Turkey Shaz Qadeer Microsoft Research,
Scientific Computing By: Fatima Hallak To: Dr. Guy Tel-Zur.
Reliable Design of Safety Critical Systems Dr. Abhik Roychoudhury School of Computing
CS6133 Software Specification and Verification
1 Causal-Consistent Reversible Debugging Ivan Lanese Focus research group Computer Science and Engineering Department University of Bologna/INRIA Bologna,
Compactly Representing Parallel Program Executions Ankit Goel Abhik Roychoudhury Tulika Mitra National University of Singapore.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CSE 425: Data Types I Data and Data Types Data may be more abstract than their representation –E.g., integer (unbounded) vs. 64-bit int (bounded) A language.
COMP 111 Threads and concurrency Sept 28, Tufts University Computer Science2 Who is this guy? I am not Prof. Couch Obvious? Sam Guyer New assistant.
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
1 Qualitative Reasoning of Distributed Object Design Nima Kaveh & Wolfgang Emmerich Software Systems Engineering Dept. Computer Science University College.
Internal Talk, Oct Executable Specifications using Message Sequence Charts Abhik Roychoudhury School of Computing National University of Singapore.
Conformance Test Experiments for Distributed Real-Time Systems Rachel Cardell-Oliver Complex Systems Group Department of Computer Science & Software Engineering.
Debugging parallel programs. Breakpoint debugging Probably the most widely familiar method of debugging programs is breakpoint debugging. In this method,
Shared Memory Consistency Models. SMP systems support shared memory abstraction: all processors see the whole memory and can perform memory operations.
1. 2 Preface In the time since the 1986 edition of this book, the world of compiler design has changed significantly 3.
Memory Consistency Models. Outline Review of multi-threaded program execution on uniprocessor Need for memory consistency models Sequential consistency.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
ICFEM 2002, Shanghai Reasoning about Hardware and Software Memory Models Abhik Roychoudhury School of Computing National University of Singapore.
Using Symbolic PathFinder at NASA Corina Pãsãreanu Carnegie Mellon/NASA Ames.
Grigore Rosu Founder, President and CEO Professor of Computer Science, University of Illinois
Static Techniques for V&V. Hierarchy of V&V techniques Static Analysis V&V Dynamic Techniques Model Checking Simulation Symbolic Execution Testing Informal.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Execution Replay and Debugging. Contents Introduction Parallel program: set of co-operating processes Co-operation using –shared variables –message passing.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
Winter 2007SEG2101 Chapter 121 Chapter 12 Verification and Validation.
October 24, 2003 SEESCOASEESCOA STWW - Programma Debugging Components Koen De Bosschere RUG-ELIS.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
Agenda  Quick Review  Finish Introduction  Java Threads.
Reachability Testing of Concurrent Programs1 Reachability Testing of Concurrent Programs Richard Carver, GMU Yu Lei, UTA.
Advanced Computer Systems
Specifying Multithreaded Java semantics for Program Verification
Presentation transcript:

Dynamic Analysis of Multithreaded Java Programs Dr. Abhik Roychoudhury National University of Singapore

Program Debugging Age-old activity Age-old activity Simple bug checks handled by compiler – type errors Simple bug checks handled by compiler – type errors Compiler does not detect violation of behavioral invariants Compiler does not detect violation of behavioral invariants –At control location L1, the value of x cannot be 0 Other errors for diff. classes of programs Other errors for diff. classes of programs –Multithreaded (Concurrent or Parallel) –Real-time

Real-time Constraints Example: Example: –Data is arriving as a burst every 10 ms –Every burst is a set of records with a primary key –Sort the primary keys before next dataset arrives Need to guarantee that our sorting program always completes before 10 ms Need to guarantee that our sorting program always completes before 10 ms –Worst Case Execution Time  10 ms Worst Case Execution Time should consider all possible inputs Worst Case Execution Time should consider all possible inputs –Exponentially many inputs based on permutations. –Need an efficient analysis technique.

Real-time Constraints Worst Case Execution Time estimation is a static analysis technique. Worst Case Execution Time estimation is a static analysis technique. –Performed at compile-time by analyzing the control flow graph of the program –No data is collected/analyzed during run-time. We are trying to prove a property about all possible runs of the program. We are trying to prove a property about all possible runs of the program. Currently working with Li Xianfeng (Ph.D. student) Currently working with Li Xianfeng (Ph.D. student)

Multithreaded Programs Threads do computation AND communication Threads do computation AND communication –e.g. Update of shared resources in a critical section Communication among threads Communication among threads –By reading/writing shared variables/objects Java programming language Java programming language –By explicitly sending/receiving messages Message Passing Interface (MPI) Message Passing Interface (MPI) Multithreaded Program Execution Platform Multithreaded Program Execution Platform –Concurrent (Several threads run on single processor with a scheduler) –Parallel (threads run on different processors).

Static Analysis and Verification Verification of behavioral properties involves Verification of behavioral properties involves –Constructing a transition system to show the state changes as the program executes –Traversing the transition to check all behaviors. –Roughly corresponds to an efficient version of exhaustive program simulation for all possible inputs. More complicated if sys. is unbounded in size More complicated if sys. is unbounded in size –E.g. the number of threads in a program may be unbounded, but always finite. Currently working with Irina Mariuca Gheorghita (Ph.D. student) Currently working with Irina Mariuca Gheorghita (Ph.D. student)

Dynamic Analysis Given an exec. trace of a multi-threaded program Given an exec. trace of a multi-threaded program –Analyze the behavior shown in that trace. Corresponds to natural notion of debugging Corresponds to natural notion of debugging –Debug a program based on a “test case” (the execution trace) Lower complexity than verif. techniques Lower complexity than verif. techniques –No need to Explore a large state space graph But need to collect/store/analyze huge traces  But need to collect/store/analyze huge traces 

Cyclic debugging Normal debugging activity is cyclic Normal debugging activity is cyclic 1.Try a test case 2.Encounter a “bug” 3.Run the program again with the test case 4.Use breakpoints etc. and try to locate bug. 5.If not successful, go to 3. Multi-threaded programs are non-deterministic Multi-threaded programs are non-deterministic How to re-generate trace ?? How to re-generate trace ??

Simple Example Initially: x= y= 0 Initially: x= y= 0 Lock Lock Lock Lock x = 1 if (x == 1) x = 1 if (x == 1) Unlock y = 1 Unlock y = 1 else y = 2 else y = 2 Unlock Unlock Threads communicating via shared variables Threads communicating via shared variables All shared variable accesses are protected All shared variable accesses are protected

Execution trace 1 User executes as follows: User executes as follows: –Thread 1 selected by scheduler. –Lock x = 1 unlock executed by Thread 1. –Thread 2 selected by scheduler –Thread 2 executes and y is set to 1 User suspects the result y =1 User suspects the result y =1 Tries to run the program again with x = y = 0 Tries to run the program again with x = y = 0

Execution Trace 2 Program executes again Program executes again –Scheduler now selects Thread 2 first –If ( x== 1) y = 1 else y = 2 results in y = 2 –Thread 1 is executed now and x is set to 1 User tries to debug based on this trace User tries to debug based on this trace But this is a diff. trace with diff. results. But this is a diff. trace with diff. results. Results from the non-determinism of the scheduler. Results from the non-determinism of the scheduler. Non-deterministic exec. in parallel platforms also Non-deterministic exec. in parallel platforms also –Relative processor speeds

Problems with Dynamic Analysis Multithreaded programs need to store the trace (or a portion of it) for future analysis. Multithreaded programs need to store the trace (or a portion of it) for future analysis. –In sequential programs it is enough to store the inputs (test-case) generating the trace. Dynamic Analysis is w.r.t. a specific trace Dynamic Analysis is w.r.t. a specific trace –How to generate “representative” traces ? (How to find “good” test cases ? ) –How to compactly store traces for offline analysis? –How to regenerate partially stored traces ? –Offline/ Post-mortem analysis techniques

Finding representative traces Describe the invariant property you want to preserve Describe the invariant property you want to preserve –At program loc. L1, x should be greater than zero –At all locations, x should be not equal to zero Construct a state transition graph of the program automatically from the program Construct a state transition graph of the program automatically from the program Efficiently traverse the graph to find possible violations of the property. Efficiently traverse the graph to find possible violations of the property.

Finding representative traces If any violation exists, your search produces If any violation exists, your search produces –A counterexample trace –A trace at the end of which the invariant property/assertion is violated. Use the counterexample trace as a representative trace to guide debugging. Use the counterexample trace as a representative trace to guide debugging. Currently working with Daniel Hogberg (Ph.D. student) Currently working with Daniel Hogberg (Ph.D. student)

Compactly storing traces Treat the program trace as a string s over a pre- defined alphabet. Treat the program trace as a string s over a pre- defined alphabet. Create a hierarchical representation of the program trace which is more compact Create a hierarchical representation of the program trace which is more compact –(catches repetitions of chunks of code) The compact representation should be created online, as the program is executing The compact representation should be created online, as the program is executing We have developed a scheme for compressing Java bytecode for multi-threaded programs. We have developed a scheme for compressing Java bytecode for multi-threaded programs. Working with Wang Tao (Ph.D. student) and Ankit Goel (visiting student) Working with Wang Tao (Ph.D. student) and Ankit Goel (visiting student)

Compressed Path - Example Uncompressed Path Compressed Representation S  AA A  123 Control Flow Graph If-then statement

Post-mortem analysis of traces Compressed traces should be easy to navigate Compressed traces should be easy to navigate –Post-mortem analysis should not involve decompressing entire trace. –Useful to detect data races in multi-threaded Java programs –Data races  Unprotected shared variable accesses x = 1 x = 2 x = 1 x = 2 if (x == 1) then S1 if (x == 2) then S2 if (x == 1) then S1 if (x == 2) then S2 The programmer expects S1, S2 to be executed The programmer expects S1, S2 to be executed May not happen due to data races. May not happen due to data races.

Tracing strategy Too costly to track down all shared variable operations in a realistic Java program Too costly to track down all shared variable operations in a realistic Java program Even if the operations are stored compactly, the run-time overheads may be too high. Even if the operations are stored compactly, the run-time overheads may be too high. One possibility is to store only the synchronization operations during run-time. One possibility is to store only the synchronization operations during run-time. Regenerate and analyze possible orderings of the other communication operations – unsynchronized shared variable accesses. Regenerate and analyze possible orderings of the other communication operations – unsynchronized shared variable accesses. Looking for students in these topics. Looking for students in these topics.

Relevant Papers Compactly Representing Parallel Program Executions, (pdf) A. Goel, A. Roychoudhury and T. Mitra ACM Symposium on Principles and Practice of Parallel Programming (PPoPP) Compactly Representing Parallel Program Executions, (pdf) A. Goel, A. Roychoudhury and T. Mitra ACM Symposium on Principles and Practice of Parallel Programming (PPoPP) 2003.pdf Specifying Multithreaded Java Semantics for Program Verification, (ps, pdf) A. Roychoudhury and T. Mitra ACM/IEEE International Conference on Software Engineering (ICSE) 2002, pages Specifying Multithreaded Java Semantics for Program Verification, (ps, pdf) A. Roychoudhury and T. Mitra ACM/IEEE International Conference on Software Engineering (ICSE) 2002, pages pspdfICSEpspdfICSE Depiction and Playout of Multi-threaded Program Executions, A. Roychoudhury, Submitted for publication Depiction and Playout of Multi-threaded Program Executions, A. Roychoudhury, Submitted for publication Symbolic Simulation of Live Sequence Charts, S. Choudhary, A Roychoudhury and RHC Yap, Submitted for publication. Symbolic Simulation of Live Sequence Charts, S. Choudhary, A Roychoudhury and RHC Yap, Submitted for publication.

My Contact Information First two papers available from my web-page. First two papers available from my web-page If you are interested in the projects, send If you are interested in the projects, send