Verifying Concurrent Programs by Memory Unwinding Ermenegildo Tomasco University of Southampton, UK Omar Inverso University of Southampton, UK Bernd Fischer.

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.
Ermenegildo Tomasco University of Southampton, UK Omar Inverso University of Southampton, UK Bernd Fischer Stellenbosch University, South Africa Salvatore.
Jeremy Morse, Mikhail Ramalho, Lucas Cordeiro, Denis Nicole, Bernd Fischer ESBMC 1.22 (Competition Contribution)
A Program Transformation For Faster Goal-Directed Search Akash Lal, Shaz Qadeer Microsoft Research.
Adapted from Scott, Chapter 6:: Control Flow Programming Language Pragmatics Michael L. Scott.
Abstraction and Modular Reasoning for the Verification of Software Corina Pasareanu NASA Ames Research Center.
Α ϒ ʎ …… Reachability Modulo Theories Akash Lal Shaz Qadeer, Shuvendu Lahiri Microsoft Research.
1 1 Regression Verification for Multi-Threaded Programs Sagar Chaki, SEI-Pittsburgh Arie Gurfinkel, SEI-Pittsburgh Ofer Strichman, Technion-Haifa Originally.
Reducing Context-bounded Concurrent Reachability to Sequential Reachability Gennaro Parlato University of Illinois at Urbana-Champaign Salvatore La Torre.
Iterative Context Bounding for Systematic Testing of Multithreaded Programs Madan Musuvathi Shaz Qadeer Microsoft Research.
Poirot – A Concurrency Sleuth Shaz Qadeer Research in Software Engineering Microsoft Research.
The Language Theory of Bounded Context-Switching Gennaro Parlato (U. of Illinois, U.S.A.) Joint work with: Salvatore La Torre (U. of Salerno, Italy) P.
Thread-modular Abstraction Refinement Tom Henzinger Ranjit Jhala Rupak Majumdar Shaz Qadeer.
On Sequentializing Concurrent Programs Ahmed Bouajjani LIAFA, University of Paris 7, France LIAFA, University of Paris 7, France Michael Emmi LIAFA, University.
Chapter 7Louden, Programming Languages1 Chapter 7 - Control I: Expressions and Statements "Control" is the general study of the semantics of execution.
Continuously Recording Program Execution for Deterministic Replay Debugging.
Lazy-CSeq A Lazy Sequentialization Tool for C Omar Inverso University of Southampton, UK Ermenegildo Tomasco University of Southampton, UK Bernd Fischer.
Thread-modular Abstraction Refinement Tom Henzinger Ranjit Jhala Rupak Majumdar [UC Berkeley] Shaz Qadeer [Microsoft Research]
Chapter 2: Algorithm Discovery and Design
1/25 Context-Bounded Analysis of Concurrent Queue Systems Gennaro Parlato University of Illinois at Urbana-Champaign Università degli Studi di Salerno.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
Chapter 7Louden, Programming Languages1 Chapter 7 - Control I: Expressions and Statements "Control" is the general study of the semantics of execution.
Formal Verification of SpecC Programs using Predicate Abstraction Himanshu Jain Daniel Kroening Edmund Clarke Carnegie Mellon University.
Chapter 2: Algorithm Discovery and Design
272: Software Engineering Fall 2012 Instructor: Tevfik Bultan Lecture 4: SMT-based Bounded Model Checking of Concurrent Software.
Thread-modular Abstraction Refinement Thomas A. Henzinger, et al. CAV 2003 Seonggun Kim KAIST CS750b.
CSE 486/586 CSE 486/586 Distributed Systems PA Best Practices Steve Ko Computer Sciences and Engineering University at Buffalo.
Scope-Bounded Pushdown Languages Salvatore La Torre Università degli Studi di Salerno joint work with Margherita Napoli Università degli Studi di Salerno.
Computer Architecture Computational Models Ola Flygt V ä xj ö University
Experience with Processes and Monitors in Mesa
CCA Common Component Architecture Manoj Krishnan Pacific Northwest National Laboratory MCMD Programming and Implementation Issues.
Runtime Refinement Checking of Concurrent Data Structures (the VYRD project) Serdar Tasiran Koç University, Istanbul, Turkey Shaz Qadeer Microsoft Research,
Scope-bounded Multistack Pushdown Systems: - fixed-point - sequentialization - tree-width 1 Salvatore La Torre Gennaro Parlato (U. Salerno, Italy) (U.
On Sequentializing Concurrent Programs Gennaro Parlato University of Southampton, UK UPMARC 7 th Summer School on Multicore Computing, June 8-10, 2015.
COT 4600 Operating Systems Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 3:00-4:00 PM.
On Sequentializing Concurrent Programs (Bounded Model Checking) Gennaro Parlato University of Southampton, UK UPMARC 7 th Summer School on Multicore Computing,
Motivation  Parallel programming is difficult  Culprit: Non-determinism Interleaving of parallel threads But required to harness parallelism  Sequential.
ICFEM 2002, Shanghai Reasoning about Hardware and Software Memory Models Abhik Roychoudhury School of Computing National University of Singapore.
Compositionality Entails Sequentializability Pranav Garg, P. Madhusudan University of Illinois at Urbana-Champaign.
Getting Rid of Store-Buffers in TSO Analysis Mohamed Faouzi Atig Uppsala University, Sweden Ahmed Bouajjani LIAFA, University of Paris 7, France LIAFA,
Bounded Model Checking of Multi-Threaded C Programs via Lazy Sequentialization Omar Inverso University of Southampton, UK Ermenegildo Tomasco University.
CSV 889: Concurrent Software Verification Subodh Sharma Indian Institute of Technology Delhi Relaxed Memory Effects and its Verification.
Software Systems Verification and Validation Laboratory Assignment 4 Model checking Assignment date: Lab 4 Delivery date: Lab 4, 5.
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.
Symbolic Model Checking of Software Nishant Sinha with Edmund Clarke, Flavio Lerda, Michael Theobald Carnegie Mellon University.
Bernd Fischer RW714: SAT/SMT-Based Bounded Model Checking of Software.
A Single Intermediate Language That Supports Multiple Implemtntation of Exceptions Delvin Defoe Washington University in Saint Louis Department of Computer.
On Sequentializing Concurrent Programs
Lazy Sequentialization via Shared Memory Abstractions
Verification for Concurrent Programs
Process concept.
Sequentializing Parameterized Programs
Sequentialization by Read-implicit Coarse-grained Memory Unwindings
Ermenegildo Tomasco1, Truc L
Specifying Multithreaded Java semantics for Program Verification
Amir Kamil and Katherine Yelick
Multithreaded Programming in Java
Threads and Memory Models Hal Perkins Autumn 2011
Model Checking for an Executable Subset of UML
Over-Approximating Boolean Programs with Unbounded Thread Creation
Threads and Memory Models Hal Perkins Autumn 2009
Lazy Sequentialization Unbounded Concurrent Programs
A Refinement Calculus for Promela
A Lazy Sequentialization Tool for Unbounded Context Switches
Amir Kamil and Katherine Yelick
CS561 Computer Architecture Hye Yeon Kim
Presentation transcript:

Verifying Concurrent Programs by Memory Unwinding Ermenegildo Tomasco University of Southampton, UK Omar Inverso University of Southampton, UK Bernd Fischer Stellenbosch University, South Africa Salvatore La Torre Università di Salerno, Italy Gennaro Parlato University of Southampton, UK

Concurrent programs multiple independent threads communication via reads / writes from / to shared memory SC memory model Shared-memory concurrency SHARED MEMORY T1T1 THREADS Read(x) Write(x,val) T2T2 TnTn...

Concurrent programs multiple independent threads communication via reads / writes from / to shared memory SC memory model Reachability problems error label (cf. SV-COMP) assertion failure out-of-bound array, division-by-zero,... Bounded analysis (bug hunting) Shared-memory concurrency verification SHARED MEMORY T1T1 THREADS Read(x) Write(x,val) T2T2 TnTn...

Memory Unwinding

T1T2 T3 Interleaving semantics rxwxrxwyrxwxrywyryrxwywx run

T1T2 T3 From interleavings to memory unwinding rxwxrxwyrxwxrywy run ryrxwy accesses to shared memory writes rxwxrxwyrxwxrywyryrxwy wx ⇒ Memory unwinding models thread interaction history by data MEMORY UNWINDING wx wywx wy wx wywx wy

Memory unwindings as thread interfaces T1T2 Assume-guarantee reasoning style decomposition of verification TASK 1 TASK 2 T1

Assume-guarantee reasoning T1T2 TASK 1 TASK 2 Thread T2 assumes: MU writes of other threads guarantees: its own MU writes  Task 1:Task 2: Thread T1 assumes: MU writes of other threads guarantees: its own MU writes

Verification using MU y=1 …. a=x x=1 …. for each write check: - right thread id - right variable - right value ensure all writes are matched for each read: - pick value from write in right range x=2 y=1 x=1 x=3 y=8 z=2 Checking assume-guarantee condition for each thread:

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Global variable write – check against current MU entry void write(uint t, uint v, int val) { mc[t] = th_nxt_wr[t][mc[t]]; assume(var[mc[t]] == v); assume(val[mc[t]] == val); } pc void write(uint t, uint v, int val) { mc[t] = th_nxt_wr[t][mc[t]]; } mc

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Local statement (no global variables) – update pc, keep mc pc

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Global variable read – “pick write position in range” int read(uint t, uint v) { if (thr_terminated()) return 0; if (var_fst_wr[v]==0) return 0; uint r_from = *; assume((r_from <= last_wr_pos) && (r_from < th_nxt_wr[t][mc[t]])); assume(var[r_from] == v); if (r_from < mc[t]) assume(var_nxt_wr[r_from] > mc[t]); else { if (r_from < var_fst_wr[v]) return 0; mc[t] = r_from; }; return value[r_from]; } non- deterministic assignment

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Global variable read – “pick write position in range” int read(uint t, uint v) { if (thr_terminated()) return 0; if (var_fst_wr[v]==0) return 0; uint r_from = *; assume((r_from <= last_wr_pos) && (r_from < th_nxt_wr[t][mc[t]])); assume(var[r_from] == v); if (r_from < mc[t]) assume(var_nxt_wr[r_from] > mc[t]); else { if (r_from < var_fst_wr[v]) return 0; mc[t] = r_from; }; return value[r_from]; }...before next write of thread... Check in unwinding...

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Global variable read – “pick write position in range” int read(uint t, uint v) { if (thr_terminated()) return 0; if (var_fst_wr[v]==0) return 0; uint r_from = *; assume((r_from <= last_wr_pos) && (r_from < th_nxt_wr[t][mc[t]])); assume(var[r_from] == v); if (r_from< mc[t]) assume(var_nxt_wr[nxt_mc] > mc[t]); else { if (r_from< var_fst_wr[v]) return 0; mc[t] = r_from; }; return value[r_from]; }...before next write of thread......right variable...

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Global variable read – “pick write position in range” int read(uint t, uint v) { if (thr_terminated()) return 0; if (var_fst_wr[v]==0) return 0; uint r_from = *; assume((r_from <= last_wr_pos) && (r_from < th_nxt_wr[t][mc[t]])); assume(var[r_from] == v); if (r_from < mc[t]) assume(var_nxt_wr[r_from] > mc[t]); else { if (r_from < var_fst_wr[v]) return 0; mc[t] = r_from; }; return value[r_from]; }...right variable......next write of variable in future...

Simulating a thread against an MU y=1 …. a=x x=1 …. x=2 y=1 x=1 x=3 y=8 z=2 pc mc Global variable read – “pick write position in range” int read(uint t, uint v) { if (thr_terminated()) return 0; if (var_fst_wr[v]==0) return 0; uint r_from = *; assume((r_from <= last_wr_pos) && (r_from < th_nxt_wr[t][mc[t]])); assume(var[r_from] == v); if (r_from < mc[t]) assume(var_nxt_wr[r_from] > mc[t]); else { if (r_from < var_fst_wr[v]) return 0; mc[t] = r_from; }; return value[r_from]; }...before next write of variable......else update mc. mc Return value. pc

Simulating a thread against an MU y=1 …. a=x x=1 …. assert(b); x=2 y=1 x=1 x=3 y=8 z=2 Handling errors – “flag that an error occurs” pc translates to if (! b) _error = 1; (computation might not be feasible) translates to if (! b) _error = 1; (computation might not be feasible)

MU based sequentialization

Our apporach: sequentialization by MU … T0T0 T1T1 TNTN … F0F0 F1F1 FNFN main() Concurrent program Sequential program Sequentialization (code-to-code translation) Simulation functions translates … MEMORY UNWINDING

Main Sequential Program void main(void){ memory_init(W); ct := mem_thread_create(); F 0 (); thread_terminate(ct); all_thread_simulated(); assert(_error == 0) } main instantiate memory unwinding error check all writes of the thread are executed simulation starts from main thread all writes of the MU are executed register main thread Thread creation

Implementation and evaluation

MU-based sequentialization implemented − for C programs with the Pthread library − optimized for sequential CBMC back-end − within the CSeq framework MU-CSeq sequential non-deterministic C program P'P' Pthread C program P true/false MU-CSeq sequential CBMC # writes

Evaluation: bug-hunting SVCOMP’15, Concurrency (UNSAFE instances) - competitive with other tools - Mu-CSeq won the silver medal in the Concurrency category of SVCOMP’15/14 ≤ 24 # writes  90

MU scheme discussed so far: − all the writes of the shared variables are exposed The size of the MU determines the amount of nondeterminism − impacts the performance MU compact representations We give also two more compact schemes: − only relevant writes of the shared variables are exposed − can handle larger number of writes x=2 y=1 x=1 x=3 y=8 z=2

Conclusions

Bounded analysis for shared-memory concurrency Bounded search is supported by empirical evaluations: most concurrency bugs exposed by few interactions [S. Lu, S. Park, E. Seo, Y. Zhou, SIGOPS 2008] many concurrency errors manifest themselves already after only a few context switches [S. Qadeer, D. Wu, PLDI 2007] sequentializations with bounded context-switches up to 2 context switches [ Qadeer, Wu – PLDI’04 ] eager, bounded context-switch, finite # threads [ Lal, Reps – CAV’08 ] lazy, finite # threads, parameterized [La Torre, Madhusudan, Parlato – CAV’09, CAV’10] thread creation [Bouajjani, Emmi, Parlato – SAS’11] [Emmi, Qadeer, Rakamaric – POPL’11] Lazy, finite #threads [Inverso, Tomasco, La Torre, Fisher, Parlato – CAV’14] We also combine : bounded writes & bounded context-switches

We have presented − new bounded exploration of the computations of concurrent programs − new sequentialization o bounded number of shared-memory write operations o not bounding the number of context switches − tool optimized for Bounded Model Checking Mu-CSeq is competitive with state-of-the-art tools − silver medal at SVCOMP’14 and '15 (concurrency) Conclusions

Weak Memory Models (WMM) − TSO Message Passing Interface (MPI) − Write → Send, Read → Receive Bug detection combining CSeq with − abstract interpretation − testing Ongoing Work