Verifying Concurrent Programs
Abstract
Counterexample Thread Line Instruction 0 19 g eq 4 := 0; 2 11 g eq 4 := 0; 2 12 if ∗ then ... 2 13 g eq 4 := 0; 1 3 g eq 4 := 0; 1 4 if ∗ then ... 1 5 g eq 4 := 0; 1 6 if ∗ then ... 1 7 g eq 4 := 1; 2 14 assert(!g eq 4); Concrete Instr. SSA-Constraint g=0; g0 = 0 g=1; ∧g1 = 1 if (g==2) ∧g1 = 2 g=3; ∧g2 = 3 g=0; ∧g3 = 0 if (g==1) ∧g3 = 1 g=2; ∧g4 = 2 if (g==3) ∧g4 = 3 g=4; ∧g5 = 4 assert(g!=4); ∧g5 = 4 D. Kroening: SSFT12 – Verifying Concurrent Programs 22 Abstract Counterexample Thread Line Instruction 0 19 g eq 4 := 0; 2 11 g eq 4 := 0; 2 12 if ∗ then ... 2 13 g eq 4 := 0; 1 3 g eq 4 := 0; 1 4 if ∗ then ... 1 5 g eq 4 := 0; 1 6 if ∗ then ... 1 7 g eq 4 := 1; 2 14 assert(!g eq 4); Concrete Instr. SSA-Constraint g=0; g0 = 0 g=1; ∧g1 = 1 if (g==2) ∧g1 = 2 g=3; ∧g2 = 3 g=0; ∧g3 = 0 if (g==1) ∧g3 = 1 g=2; ∧g4 = 2 if (g==3) ∧g4 = 3 g=4; ∧g5 = 4 assert(g!=4); ∧g5 = 4 D. Kroening: SSFT12 – Verifying Concurrent Programs 22Counterexample Thread Line Instruction 0 19 g eq 4 := 0; 2 11 g eq 4 := 0; 2 12 if ∗ then ... 2 13 g eq 4 := 0; 1 3 g eq 4 := 0; 1 4 if ∗ then ... 1 5 g eq 4 := 0; 1 6 if ∗ then ... 1 7 g eq 4 := 1; 2 14 assert(!g eq 4); Concrete Instr. SSA-Constraint g=0; g0 = 0 g=1; ∧g1 = 1 if (g==2) ∧g1 = 2 g=3; ∧g2 = 3 g=0; ∧g3 = 0 if (g==1) ∧g3 = 1 g=2; ∧g4 = 2 if (g==3) ∧g4 = 3 g=4; ∧g5 = 4 assert(g!=4); ∧g5 = 4 D. Kroening: SSFT12 – Verifying Concurrent Programs 22 Example I In total, 4 iterations, and 4 predicates: g==4, g==3, g==1, g==2 I Final counterexample has a thread switch after each assignment to g D. Kroening: SSFT12 – Verifying Concurrent Programs 23 Tricky Details 1 volatile unsigned value; 2 3 unsigned NonblockingCounter increment() { 4 unsigned v = 0; 5 6 lock (); 7 if (value == 0u−1) { 8 unlock(); 9 return 0; 10 }else{ 11 v = value; 12 value = v + 1; 13 unlock(); 14 assert(value > v); 15 return v + 1; 16 } 17 } Is “ value>v ” global or local? CAV 2011: neither. We need broadcast! D. Kroening: SSFT12 – Verifying Concurrent Programs 24 Tricky Details 1 volatile unsigned value; 2 3 unsigned NonblockingCounter increment() { 4 unsigned v = 0; 5 6 lock (); 7 if (value == 0u−1) { 8 unlock(); 9 return 0; 10 }else{ 11 v = value; 12 value = v + 1; 13 unlock(); 14 assert(value > v); 15 return v + 1; 16 } 17 } Is “ value>v ” global or local? CAV 2011: neither. We need broadcast! D. Kroening: SSFT12 – Verifying Concurrent Programs 24 Tricky Details 1 volatile unsigned value; 2 3 unsigned NonblockingCounter increment() { 4 unsigned v = 0; 5 6 lock (); 7 if (value == 0u−1) { 8 unlock(); 9 return 0; 10 }else{ 11 v = value; 12 value = v + 1; 13 unlock(); 14 assert(value > v); 15 return v + 1; 16 } 17 } Is “ value>v ” global or local? CAV 2011: neither. We need broadcast! D. Kroening: SSFT12 – Verifying Concurrent Programs 24 The Problem We Consider Definition Consider thread state (s, `). thread state reachability problem: Is there a reachable global state (s, `1, . . . , `n) such that ` = `i for some i? Note: I can express single-index properties of threads I can also encode MutEx: using shared variable as monitor D. Kroening: SSFT12 – Verifying Concurrent Programs 25 Boolean Programs with Bounded Replication I We have an effective Model Checker for Boolean programs with a bounded number of threads I BDD-based I Exploits symmetry between threads [CAV 2009, FMSD 2010] D. Kroening: SSFT12 – Verifying Concurrent Programs 26 Symbolic Experiments 0.1 1 10 100 [sec] 1000 0.1 1 10 10
BibTeX
@misc{kroening2012verifying,
author = {Daniel Kroening},
title = {{Verifying Concurrent Programs}},
year = {2012},
}Ask Althea to put this paper to the test.
Loading related content...