Modular Verification of Multithreaded Software Shaz Qadeer Compaq Systems Research Center Shaz Qadeer Compaq Systems Research Center Joint work with Cormac.

Slides:



Advertisements
Similar presentations
Verification of architectural memory models by model checking Shaz Qadeer Compaq Systems Research Center
Advertisements

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.
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
A simple sequential reasoning approach for sound modular verification of mainstream multithreaded programs Wolfram Schulte & Bart Jacobs Microsoft Research.
Chapter 6: Process Synchronization
5.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 5: CPU Scheduling.
Transaction Based Modeling and Verification of Hardware Protocols Xiaofang Chen, Steven M. German and Ganesh Gopalakrishnan Supported in part by SRC Contract.
Transaction Based Modeling and Verification of Hardware Protocols Xiaofang Chen, Steven M. German and Ganesh Gopalakrishnan Supported in part by Intel.
Model Checking : Making Automatic Formal Verification Scale Shaz Qadeer EECS Department University of California at Berkeley.
ESP: A Language for Programmable Devices Sanjeev Kumar, Yitzhak Mandelbaum, Xiang Yu, Kai Li Princeton University.
6/14/991 Symbolic verification of systems with state machines David L. Dill Jeffrey Su Jens Skakkebaek Computer System Laboratory Stanford University.
Background information Formal verification methods based on theorem proving techniques and model­checking –to prove the absence of errors (in the formal.
1 Concurrency Specification. 2 Outline 4 Issues in concurrent systems 4 Programming language support for concurrency 4 Concurrency analysis - A specification.
Types for Atomicity in Multithreaded Software Shaz Qadeer Microsoft Research (Joint work with Cormac Flanagan)
/ PSWLAB Atomizer: A Dynamic Atomicity Checker For Multithreaded Programs By Cormac Flanagan, Stephen N. Freund 24 th April, 2008 Hong,Shin.
CS 263 Course Project1 Survey: Type Systems for Race Detection and Atomicity Feng Zhou, 12/3/2003.
Summarizing Procedures in Concurrent Programs Shaz Qadeer Sriram K. Rajamani Jakob Rehof Microsoft Research.
C. FlanaganTypes for Race Freedom1 Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College Shaz Qadeer Microsoft Research Analysis of Concurrent.
C. FlanaganSAS’04: Type Inference Against Races1 Type Inference Against Races Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College.
Software Engineering: Where are we? And where do we go from here? V Software Engineering Lecture 23 Clark Barrett New York University 4/17/2006.
1 Thread Modular Model Checking Cormac Flanagan Systems Research Center HP Labs Joint work with Shaz Qadeer (Microsoft Research)
VIDE Integrated Environment for Development and Verification of Programs.
Thread-modular Abstraction Refinement Tom Henzinger Ranjit Jhala Rupak Majumdar [UC Berkeley] Shaz Qadeer [Microsoft Research]
Developing Verifiable Concurrent Software Tevfik Bultan Department of Computer Science University of California, Santa Barbara
Verification of Hierarchical Cache Coherence Protocols for Future Processors Student: Xiaofang Chen Advisor: Ganesh Gopalakrishnan.
On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.
Houdini: An Annotation Assistant for ESC/Java Cormac Flanagan and K. Rustan M. Leino Compaq Systems Research Center.
Predicate Abstraction for Software Verification Shaz Qadeer Compaq Systems Research Center (joint work with Cormac Flanagan)
1 A Modular Checker for Multithreaded Programs Cormac Flanagan HP Systems Research Center Joint work with Shaz Qadeer Sanjit A. Seshia.
Thread-Modular Verification Shaz Qadeer Joint work with Cormac Flanagan Stephen Freund Shaz Qadeer Joint work with Cormac Flanagan Stephen Freund.
Verifying Commit-Atomicity Using Model Checking Cormac Flanagan University of California, Santa Cruz.
CS510 Concurrent Systems Class 5 Threads Cannot Be Implemented As a Library.
Transaction Based Modeling and Verification of Hardware Protocols Xiaofang Chen, Steven M. German and Ganesh Gopalakrishnan Supported in part by SRC Contract.
/ PSWLAB Eraser: A Dynamic Data Race Detector for Multithreaded Programs By Stefan Savage et al 5 th Mar 2008 presented by Hong,Shin Eraser:
K. Rustan M. Leino RiSE, Microsoft Research, Redmond joint work with Peter Müller and Jan Smans Lecture 0 1 September 2009 FOSAD 2009, Bertinoro, Italy.
Thread-modular Abstraction Refinement Thomas A. Henzinger, et al. CAV 2003 Seonggun Kim KAIST CS750b.
C. FlanaganType Systems for Multithreaded Software1 Cormac Flanagan UC Santa Cruz Stephen N. Freund Williams College Shaz Qadeer Microsoft Research.
Compositional Verification of Termination-Preserving Refinement of Concurrent Programs Hongjin Liang Univ. of Science and Technology of China (USTC) Joint.
Towards Scalable Modular Checking of User-defined Properties Thomas Ball, MSR Brian Hackett, Mozilla Shuvendu Lahiri, MSR Shaz Qadeer, MSR Julien Vanegue,
Software Engineering Prof. Dr. Bertrand Meyer March 2007 – June 2007 Chair of Software Engineering Static program checking and verification Slides: Based.
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.
Cosc 4740 Chapter 6, Part 3 Process Synchronization.
Eraser: A Dynamic Data Race Detector for Multithreaded Programs STEFAN SAVAGE, MICHAEL BURROWS, GREG NELSON, PATRICK SOBALVARRO, and THOMAS ANDERSON Ethan.
/ PSWLAB Type-Based Race Detection for J AVA by Cormac Flanagan, Stephen N. Freund 22 nd Feb 2008 presented by Hong,Shin Type-Based.
Aditya V. Nori, Sriram K. Rajamani Microsoft Research India.
Race Checking by Context Inference Tom Henzinger Ranjit Jhala Rupak Majumdar UC Berkeley.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
Applications of extended static checking K. Rustan M. Leino Compaq SRC K. Rustan M. Leino Compaq SRC Systems Research Center Invited talk, SAS’01, Paris,
Memory Consistency Models. Outline Review of multi-threaded program execution on uniprocessor Need for memory consistency models Sequential consistency.
Automated and Modular Refinement Reasoning for Concurrent Programs Shaz Qadeer.
Extended Static Checking for Java Cormac Flanagan Joint work with: Rustan Leino, Mark Lillibridge, Greg Nelson, Jim Saxe, and Raymie Stata.
ICFEM 2002, Shanghai Reasoning about Hardware and Software Memory Models Abhik Roychoudhury School of Computing National University of Singapore.
Formal Verification. Background Information Formal verification methods based on theorem proving techniques and model­checking –To prove the absence of.
Extended Static Checking for Java Cormac Flanagan Joint work with: Rustan Leino, Mark Lillibridge, Greg Nelson, Jim Saxe, and Raymie Stata Compaq Systems.
/ 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 Tayfun Elmas, Shaz Qadeer and Serdar Tasiran POPL ‘ – Seminar in Distributed Algorithms Cynthia Disenfeld 27/05/2013.
Simplifying Linearizability Proofs Using Reduction and Abstraction Serdar Tasiran Koc University, Istanbul, Turkey Tayfun Elmas, Ali Sezgin, Omer Subasi.
A Calculus of Atomic Actions Serdar Tasiran Koc University, Istanbul, Turkey Tayfun ElmasShaz Qadeer Koc University Microsoft Research.
Formal methods: Lecture
Specifying Multithreaded Java semantics for Program Verification
Concurrency Specification
Logical architecture refinement
Atomicity in Multithreaded Software
Hoare-style program verification
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 451: Operating Systems Winter 2003 Lecture 7 Synchronization
Presentation transcript:

Modular Verification of Multithreaded Software Shaz Qadeer Compaq Systems Research Center Shaz Qadeer Compaq Systems Research Center Joint work with Cormac Flanagan, Stephen Freund, Sanjit Seshia

Multithreaded software  Examples: operating systems, databases, web servers, Java libraries  Verification problem –for all inputs and interleavings, program satisfies specification  Verifying multithreaded programs is difficult –large and complex

Modular verification of multithreaded programs  thread: verify each thread separately using specifications of other threads  procedure: in each thread, verify each procedure separately using specifications of called procedures

Method  Reduce verification of multithreaded programs to verification of sequential programs  Analysis of sequential programs well-studied –dataflow analysis –abstract interpretation –theorem proving with verification conditions

Action  predicate on unprimed and primed variables –(x’ = y+1  y’ = y)  x := y+1 –(p  x’ = x)  p y –true   skip

Atomic operation  actions p and q  p  q : all transitions allowed by p must also be allowed by q  (x’ = y+1  y’ = y)  x’  y’ succeeds  (x’ = y+1  y’ = y)  x’ = y’ fails  skip  p  assert p  p abbreviates p  true

Outline  modular verification –without procedure calls –with procedure calls  verification of Mercator

Simple multithreaded program Thread1 acq; x := x+1; assert x > 0; rel; Thread2 acq; x := 0; rel; m = i, if held by thread i 0, if unheld Init: x = 0

Simple multithreaded program Thread1 ( m=0  m’=1) m ; x := x+1; assert x > 0; ( m’=0) m ; Thread2 ( m=0  m’=2) m ; x := 0; ( m’=0) m ; Init: x = 0

Owicki-Gries-Lamport method Thread1 L1: m=0  x  0 (m=0  m’=1) m ; L2: m=1  x  0 x := x+1; L3: m=1  x  1 assert x > 0; L4: m=1  x  1 (m’=0) m ; L5: m=0  x  0 Thread2 M1: m=0  x  0 (m=0  m’=2) m ; M2: m=2  x  0 x := 0; M3: m=2  x  0 (m’=0) m ; M4: m=0  x  0  Sequential correctness  Non-interference

Why is Thread 1 correct? Thread 1 view ( m=0  m’=1) m ; ** x := x+1; * assert x > 0; * ( m’=0) m ; 1-abstraction A 1  ; ( m=0  m’=1) m  A 2 ; A 1  ; x := x+1  A 2 ; A 1  ; assert x > 0  A 2 ; A 1  ; ( m’=0) m  A 2 ;  (m’=0  x’  0)  (m = i  m’ = i)  (m = i  x’ = x) Ai Ai  Jones 83

Why is Thread 1 correct? Thread 1 view ( m=0  m’=1) m ; ** x := x+1; * assert x > 0; * ( m’=0) m ; 1-abstraction A 1 reflexive- transitive ! Can replace A 1  by A 1 !  A 1 ; (m=0  m’=1) m  A 2 ; A 1 ; x := x+1  A 2 ; A 1 ; assert x > 0  A 2 ; A 1 ; (m’=0) m  A 2 ;  (m’=0  x’  0)  (m = i  m’ = i)  (m = i  x’ = x) Ai Ai  Jones 83

Sequential checker Summary of method Thread 1 Thread 2 Thread n 1-abs 2-abs n-abs Sequential checker Sequential checker... yes

Assume-guarantee decomposition  Misra-Chandy 81 –processes communicating over channels  Jones 83 –parallel shared-memory programs  Abadi-Lamport 85 –temporal logic  Alur-Henzinger 96, McMillan 97 –Mealy machines (hardware) ...

Outline  modular verification –without procedure calls –with procedure calls  verification of Mercator

Simple multithreaded program Thread1 acq( ); x := x+1; assert x > 0; rel( ); Thread2 acq( ); x := 0; rel( ); Init: x = 0

Mutex implementation is not atomic ! acq( ) { t := i; while (t  0) ACS(m,0,t) ; } ACS(m,v,t)  if (m=v) then m,t := t,m rel( ) { m := 0; } What is the specification of acq( ) and rel( )?

Modular verification of sequential programs  verify each procedure separately using specifications of called procedures requires x > 0 modifies x ensures x’ = x+1 inc( ) { x := x+1; }. assert x > 0; (x’ = x+1) ;. assume x > 0; x_pre := x; y_pre := y; x := x+1; assert x = x_pre+1; assert y = y_pre;

Pre/post-conditions not enough ! Thread1 acq( ); x := x+1; assert x > 0; rel( ); acq( ) { t := 1; while (t  0) ACS(m,0,t) ; } modifies x, m ensures m=1  x  0 abstraction boundary A 1 ; t := 1  A 2 ; while (t  0) { A 1 ; ACS(m,0,t)  A 2 ; } A 1 ; assert m=1  x  0 ;  (m’=0  x’  0)  (m = i  m’ = i)  (m = i  x’ = x) Ai Ai 

Specification of acq() for Thread i Impl: acq( ) { t := i; while (t  0) ACS(m,0,t) ; } Spec: skip * ; ( m=0  m’=i) m skip ( m=0  m’=i) m m0m0 m=0 Often, witness can be guessed automatically ! Need witness to synchronize spec actions with impl actions !

Verification of acq() for Thread 1 true ; t := 1  skip; true ; while (t  0) { true ; ACS(m,0,t)  } Spec: skip * ; ( m=0  m’=1) m  m  0  skip  m=0  (m=0  m’=1) m ; In general, assumption could involve variables in scope.

Specification of rel() for Thread i Impl: rel( ) { m := 0; } Spec: ( m’=0) m

Generalization of pre/post-conditions requires p modifies U ensures q f( ) {... } assert p ; true U  ; assume q f( ) {... }

Why is Thread 1 correct? Thread1 skip * ; ( m=0  m’=1) m ; x := x+1; assert x > 0; ( m’=0) m ; Thread1 acq( ); x := x+1; assert x > 0; rel( ); A 1 ; { skip  A 2 ; A 1 ; }  ; (m=0  m’=1) m  A 2 ; A 1 ; x := x+1  A 2 ; A 1 ; assert x > 0  A 2 ; A 1 ; (m’=0) m  A 2 ;  (m’=0  x’  0)  (m = i  m’ = i)  (m = i  x’ = x) Ai Ai 

Summary  for each thread i –write assumption –write specifications for procedures –check each specification by inlining specifications of called procedures –check assumptions of other threads

Outline  modular verification –without procedure calls –with procedure calls  verification of Mercator

Implementation  Extended Static Checker for Java (Detlefs- Leino-Nelson-Saxe 98)  verification conditions proved by Simplify (Nelson 81)

More details  atomic operation is read/write of a heap variable  optimizations for reducing assumptions between atomic operations  assume sequential consistency  witness guessed automatically

Mercator (Heydon-Najork 99)  multithreaded web crawler written in Java  in production use at Altavista  synchronization based on Java monitors and reader-writer locks

Mercator architecture RAMDISK... TCTC T1T1 T NUM Checkpointing Thread Worker Threads URL set URL queue

Reader-writer locks  lock L 1 : –checkpointing thread acquires in write mode –worker threads acquire in read mode  lock L 2 : –protects data structure on disk –worker thread acquires in write mode to write and in read mode to read

Race detection  checkpointing thread –must hold L 1 in write mode  worker thread –must hold L 1 in read mode –reading: must hold L 2 in read mode –writing: must hold L 2 in write mode

Verification  analyzed ~1500 LOC  Mercator’s reader-writer locks implement specification –acq_read( ), acq_write( ), rel_read(), rel_write( )  absence of races –threads obey protocol for accessing shared data  found bug introduced by us

Annotation cost  55 annotations  Scales with complexity of synchronization patterns, not size of program

Verification of java.util.vector  synchronization with Java monitors  ~450 LOC  4 annotations  found known race (Flanagan-Freund 00)

Annotation overhead CategoryFraction of Total Read/Write Constraints & Data Invariants 6/55 Specification of Readers-Writer Locks 21/55 Other Interface Specifications 16/55 Environment Assumptions 12/55

File system Web server Disk Buffer cache Mutex module Mutex { /* Data */ boolean b; int m; /* Code */ acq() { } rel() { } } create() {. acq();. }

module Mutex { /* Data */ boolean b; int m; invariant  b  m = 0; /* Code */ spec …… acq() {. assert b;. } spec …… rel() { } }

Programs S  SeqProg ::=  atomic operation | S 1 ; S 2 composition | S 1  S 2 choice | S 1  iteration | call p procedure call P  ParProg ::= S 1 ||... || S n

Modular verification of multithreaded programs  one procedure active for each thread  interleaving of atomic actions of active procedures  atomic action is unit of induction  pre/post-conditions not enough  need abstraction of each atomic action of a procedure  specification is an abstract program