Zing: A Systematic State Explorer for Concurrent Software Tony Andrews Shaz Qadeer Sriram K. Rajamani Jakob Rehof Microsoft Research.

Slides:



Advertisements
Similar presentations
Summarizing Procedures in Concurrent Programs Shaz Qadeer Sriram K. Rajamani Jakob Rehof Microsoft Research.
Advertisements

Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Zing: Exploiting Program Structure for Model Checking Concurrent Software Tony Andrews Shaz Qadeer Sriram K. Rajamani Jakob Rehof Microsoft Research Yichen.
Modeling Software Systems Lecture 2 Book: Chapter 4.
Model Checking and Testing combined
Automatic Verification Book: Chapter 6. How can we check the model? The model is a graph. The specification should refer the the graph representation.
.NET Technology. Introduction Overview of.NET What.NET means for Developers, Users and Businesses Two.NET Research Projects:.NET Generics AsmL.
Introduction to Concurrency
QED: A Simplifier for Concurrent Programs Shaz Qadeer Microsoft Research Joint work with Tayfun ElmasAli SezginSerdar Tasiran.
Global States.
1 Model checking. 2 And now... the system How do we model a reactive system with an automaton ? It is convenient to model systems with Transition systems.
Automatic Verification Book: Chapter 6. What is verification? Traditionally, verification means proof of correctness automatic: model checking deductive:
Compilation 2011 Static Analysis Johnni Winther Michael I. Schwartzbach Aarhus University.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Reduction, abstraction, and atomicity: How much can we prove about concurrent programs using them? Serdar Tasiran Koç University Istanbul, Turkey Tayfun.
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Chapter 6: Process Synchronization
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 6: Process Synchronization.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Iterative Context Bounding for Systematic Testing of Multithreaded Programs Madan Musuvathi Shaz Qadeer Microsoft Research.
Department of Software Engineering Faculty of Mathematics and Physics CHARLES UNIVERSITY IN PRAGUE Czech Republic Extracting Zing Models from C Source.
1 Spin Model Checker Samaneh Navabpour Electrical and Computer Engineering Department University of Waterloo SE-464 Summer 2011.
ZING Systematic State Space Exploration of Concurrent Software Jakob Rehof Microsoft Research
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.
/ PSWLAB Atomizer: A Dynamic Atomicity Checker For Multithreaded Programs By Cormac Flanagan, Stephen N. Freund 24 th April, 2008 Hong,Shin.
Summarizing Procedures in Concurrent Programs Shaz Qadeer Sriram K. Rajamani Jakob Rehof Microsoft Research.
Developing Verifiable Concurrent Software Tevfik Bultan Department of Computer Science University of California, Santa Barbara
Modular Verification of Multithreaded Software Shaz Qadeer Compaq Systems Research Center Shaz Qadeer Compaq Systems Research Center Joint work with Cormac.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
Partial Order Reduction for Scalable Testing of SystemC TLM Designs Sudipta Kundu, University of California, San Diego Malay Ganai, NEC Laboratories America.
1 A Modular Checker for Multithreaded Programs Cormac Flanagan HP Systems Research Center Joint work with Shaz Qadeer Sanjit A. Seshia.
Overview of program analysis Mooly Sagiv html://
Semantics with Applications Mooly Sagiv Schrirber html:// Textbooks:Winskel The.
Part II: Atomicity for Software Model Checking. Class Account { int balance; static int MIN = 0, MAX = 100; bool synchronized deposit(int n) { int t =
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
. Memory Management. Memory Organization u During run time, variables can be stored in one of three “pools”  Stack  Static heap  Dynamic heap.
Overview of program analysis Mooly Sagiv html://
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
Towards Scalable Modular Checking of User-defined Properties Thomas Ball, MSR Brian Hackett, Mozilla Shuvendu Lahiri, MSR Shaz Qadeer, MSR Julien Vanegue,
1 VeriSoft A Tool for the Automatic Analysis of Concurrent Reactive Software Represents By Miller Ofer.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Runtime Refinement Checking of Concurrent Data Structures (the VYRD project) Serdar Tasiran Koç University, Istanbul, Turkey Shaz Qadeer Microsoft Research,
Lifecycle Verification of the NASA Ames K9 Rover Executive Dimitra Giannakopoulou Mike Lowry Corina Păsăreanu Rich Washington.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
Inferring Specifications to Detect Errors in Code Mana Taghdiri Presented by: Robert Seater MIT Computer Science & AI Lab.
1 Causal-Consistent Reversible Debugging Ivan Lanese Focus research group Computer Science and Engineering Department University of Bologna/INRIA Bologna,
Model construction and verification for dynamic programming languages Radu Iosif
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
An Undergraduate Course on Software Bug Detection Tools and Techniques Eric Larson Seattle University March 3, 2006.
1 Model Checking of Robotic Control Systems Presenting: Sebastian Scherer Authors: Sebastian Scherer, Flavio Lerda, and Edmund M. Clarke.
Principles of programming languages 10: Object oriented languages Isao Sasano Department of Information Science and Engineering.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
/ PSWLAB Thread Modular Model Checking by Cormac Flanagan and Shaz Qadeer (published in Spin’03) Hong,Shin Thread Modular Model.
Specifying Multithreaded Java semantics for Program Verification Abhik Roychoudhury National University of Singapore (Joint work with Tulika Mitra)
A Calculus of Atomic Actions Serdar Tasiran Koc University, Istanbul, Turkey Tayfun ElmasShaz Qadeer Koc University Microsoft Research.
Formal methods: Lecture
ZING Systematic State Space Exploration of Concurrent Software
Java Programming: Guided Learning with Early Objects
C# and the .NET Framework
runtime verification Brief Overview Grigore Rosu
State your reasons or how to keep proofs while optimizing code
Over-Approximating Boolean Programs with Unbounded Thread Creation
Process Description and Control
Operating Systems : Overview
An explicit state model checker
Operating Systems : Overview
CSE 153 Design of Operating Systems Winter 19
Presentation transcript:

Zing: A Systematic State Explorer for Concurrent Software Tony Andrews Shaz Qadeer Sriram K. Rajamani Jakob Rehof Microsoft Research

Model Checking Finding bugs by systematically exploring all possible states of a model Works for control-dominated hardware and protocols Model is written manually by someone who understands the system Typical models are FSMs

Model Checking at MSR Check source code in common programming languages Model can be extracted automatically from the code Good models are not necessarily FSMs

Characteristics of Software Primitive values are more complicated –Pointers –Objects Control flow (transition relation) is more complicated –Functions –Function pointers –Exceptions States are more complicated –Unbounded graphs over values Variables are scoped –Locals –Shared scopes Much richer modularity constructs –Functions –Classes

What is Zing? Zing is a framework for software model-checking –Language, compiler, runtime, tools Supports key programming language constructs –Objects, functions, threads, channels, dynamic allocation Enables easier extraction of models from code Supports research in exploring large state spaces –New techniques implemented compositional model checking summarizing procedures with concurrency Supports conformance checking

Applications of Zing Check for errors in sets of web services whose behavior is described by BPEL4WS Check web services for conformance with behavioral contracts Check behavior of Windows device drivers under concurrent execution Find errors in complex application protocols

What can we check for? Assertion violations –Zing has assert(…) statement –Assertion violations are flagged as errors Stuck states –Deadlock: a process is waiting for message that is never sent or condition that is never satisfied Conformance –Does a communicating process conform to a specification (contract) ?

Outline Overview Zing show and tell Architecture State-space reduction algorithms Conformance Checker

Bluetooth driver

BPEL4WS checking Zing Model Zing State Explorer BuyerSeller AuctionHouse RegService BPEL Processes

Zing features –processes –simple data types –structures –arrays –enums –communication message queues shared memory –blocking –non-determinism –atomic blocks –objects –functions (methods) –dynamic memory allocation –exceptions –range type –sets –variable-size arrays

Outline Overview Zing show and tell Architecture State-space reduction algorithms Conformance Checker

Zings eco-system Visual Studio.NET visualization (UML activity) visualization (call graph) … event trace model extraction user source Zing runtime library User Product Groups MSR Legend Zing Compiler Zing Source Code Zing object code (MSIL) Domain- specific tools Model-checker State browser Debugger Conformance Checker

Zing Object Model State Zing Application StateImpl Checkers, Simulators, etc. State: contains state of the entire model Can query how many processes are in the state Can execute a particular process in the state for one atomic step and return the resulting state Can compare if two states are equal

State Heap: complex types … Process … Processes Zing State Internals Globals: simple types & refs Stack IP Locals Params IP Locals Params …

State explosion 5 components, 100 states/component 5 components, 100 states/component Worst case: 10 billion states Worst case: 10 billion states

Outline Overview Zing show and tell Architecture State-space reduction algorithms Conformance Checker

Saving storage Only states on the checkers stack are stored For states not on the stack only a fingerprint is stored In progress: –Store only deltas from previous states

State reduction Abstract notion of equality between states Avoid exploring similar states several times Exploit structure and do this fully automatically while computing the fingerprint: s1 s2 f(s1) = f(s2) Heap1 a 100 b0 200 Heap2 b0 150 a 300 ptr

Interleaving reduction Do not explore all interleavings between threads –Interleave only at transaction boundaries Combine atomicity with summarization –Two level model checking algorithm

Transactions In a well synchronized concurrent program –A threads computation can be viewed as a sequence of transactions –While analyzing a transaction, interleavings with other threads need not be considered –Furthermore: summarize transactions, leading to reuse and efficiency

How do you identify transactions? Liptons theory of reduction

B: both right + left movers –variable access holding lock N : non-movers –access unprotected variable Four atomicities R : right movers –lock acquire S0S0 S1S1 S2S2 acq(this)x S0S0 T1T1 S2S2 x S7S7 T6T6 S5S5 rel(this)z S7S7 S6S6 S5S5 z L: left movers –lock release S2S2 S3S3 S4S4 r=baly S2S2 T3T3 S4S4 y S2S2 T3T3 S4S4 x S2S2 S3S3 S4S4 x

Transaction Any sequence of actions whose atomicities are in R*(N+ )L* is a transaction S0S0 S1S1 S2S2 RR S5S5 S6S6 L S3S3 S4S4 RN L S7S7 R Precommit Transaction Postcommit

Transactions and summaries Corollary of Liptons theorem: No need to schedule other threads in the middle of a transaction If a procedure body occurs in a transaction, we can summarize it!

Resource allocator (1) bool available[N]; mutex m; int getResource() { int i = 0; L0: acquire(m); L1: while (i < N) { L2: if (available[i]) { L3: available[i] = false; L4: release(m); L5: return i; } L6: i++; } L7: release(m); L8: return i; } Choose N = 2 Summaries:

Resource allocator (2) bool available[N]; mutex m[N]; int getResource() { int i = 0; L0: while (i < N) { L1: acquire(m[i]); L2: if (available[i]) { L3: available[i] = false; L4: release(m[i]); L5: return i; } else { L6: release(m[i]); } L7: i++; } L8: return i; } Choose N = 2 Summaries:

Abstraction Represent only aspects of the program relevant to property being checked Automatic iterative refinement of abstractions Use regions to construct conservative abstractions of the heap

Composition Divide and conquer Check one component of the model at a time Requires behavioral contracts

Outline Overview Zing show and tell Architecture State-space reduction algorithms Conformance Checker

Contract checking A CA CBCC Does each implementation conform to its contract? Example: Does A conform to CA? Use only CB and CC (and not B and C during this check)

Contract checking A CA CBCC Spec (Zing) Impl (Zing) Zing Conformance Checker

Conformance and Zing Conformance was originally defined syntactically for CCS Tony Hoare helped us generalize definition to make it purely semantic –makes no assumptions about the syntactic structure of the processes –can work for any system where we can observe externally visible behavior for processes –we have implemented exactly this on top of Zing!

Conformance Checker void doDfs(State initImpl, State initSpec) { addState(initImpl, initSpec); while(dfsStack.Count > 0) { StatePair pair = dfsStack.Peek(); State I = pair.first(); State S = pair.second(); State newI = I.GetNextSuccessor(); // lookup the events on the transition from I to newI if (newI == null) { if (isStable(I)){ // first get all the events we executed from I Event[][] IEvents = I.AccumulateEvents; if (!checkRefusals(S, IEvents)) { Console.WriteLine(Contract over-promises); generateError(I, S); return; } dfsStack.Pop(); continue; } Event[] events = newI.Events; State newS = executeWithTrace (S, events); if (newS == null){ Console.WriteLine(Implementation has unspecified behavior); continue; } addState (newI, newS); } Stack dfsStack; Hashtable stateHash; void addState(State i, State s) { StatePair combinedState = new StatePair(i,s); if(!stateHash.contains(combinedState)){ stateHash.add(combinedState); dfsStack.push(combinedState); } State executeWithTrace(State s, Event[] l ) { S: S l S, if such S exists null: otherwise } Bool checkRefusals(State s, Event[][] L){ true: exists stable S such that S * S, and for all l, if S l then l L false: otherwise }