Aditya V. Nori, Sriram K. Rajamani
Programming Languages and Tools
Microsoft Research India
Aditya V. Nori, Sriram K. Rajamani Programming Languages and Tools - - PowerPoint PPT Presentation
Aditya V. Nori, Sriram K. Rajamani Programming Languages and Tools Microsoft Research India An industrial strength program verifier Philosophy: Synergize verification and testing Synergy [ FSE 06 ], Dash [ ISSTA 08 ], Smash [
Programming Languages and Tools
Microsoft Research India
void f(int *p, int *q) { 0: *p = 4; 1: *q = 5; 2: assert (¬𝜒𝑓𝑠𝑠𝑝𝑠) }
Does the assertion hold for all possible inputs? Must analysis: finds bugs, but can’t prove their absence May analysis: can prove the absence of bugs, but can result in false errors More generally, we are interested in the query
?
?
⊆ ∗ 𝑞 ≠ 4 = (𝑞 = 𝑟)
void f(int *p, int*q) { 0: *p = 4; 1: *q = 5; }
?
1
(𝑞 ≠ 𝑟) (𝑞 ≠ 𝑟) (∗ 𝑞 ≠ 4)
2 1
(𝑞 = 𝑟)
void f(int *p, int*q) { 0: *p = 4; 1: *q = 5; }
▪ A forest of reachable concrete states (tests) ▪ Under-approximates executions of the program ▪ A region graph (an abstraction) ▪ Over-approximates all executions of the program
▪ If a test reaches an error, we have found bug ▪ If we refine the abstraction so that there is *no* path from the initial region to error region, we have a proof
▪ Frontier ▪ 𝑋𝑄
𝛽 uses only aliases α that are present along
concrete tests that are executed
frontier
1 2 3 4 7 8 9 5 6 10 10
1 2 3 4 7 8 9 5 6 10 10
frontier
𝛽 to refine so
frontier
1 2 3 4 7 8 9 5 6 10 10 4
Can exte tend test t beyond fronti tier? Refine ne abstra tracti tion Cons nstr truc uct t initi tial al abstra tracti tion Cons nstruc uct rand ndom m tests Test t succeeded? Bug ug! Abstrac tracti tion succeeded? τ = error path in abstraction f = fronti ntier of error path th yes no no yes no no Proof! yes no no Input: ut: Program m 𝑸 Property rty 𝝎
void f(int y) { 0: int lock, x; 1: do { 2: lock = 1; 3: x = y; 4: if (*) { 5: lock = 0; 6: y = y+1; } 7: } while (x != y) 8: if (lock != 1) 9: error(); 10: }
1 2 3 4 5 6 7 8 9
×
10
𝑧 = 1 𝜐 = (0,1,2,3,4,7,8,9) frontier
Symbolic execution + Theorem proving
8 9 8:¬ρ
9
𝜍 = (𝑚𝑝𝑑𝑙. 𝑡𝑢𝑏𝑢𝑓 ! = 𝑀)
1 2 3 4 5 6 7 8 9 10
8 9 8:¬p
9
p= (𝑚𝑝𝑑𝑙. 𝑡𝑢𝑏𝑢𝑓 ! = 𝑀)
1 2 3 4 5 6 7 9 10 8:¬𝑞 8:p
Can exte tend test t beyond fronti tier? Refine ne abstra tracti tion Cons nstr truc uct t initi tial al abstra tracti tion Cons nstruc uct rand ndom m tests Test t succeeded? Bug ug! Abstrac tracti tion succeeded? τ = error path in abstraction f = fronti ntier of error path th yes no no yes no no Proof! yes no no Input: ut: Program m 𝑸 Property rty 𝝎
void f(int y) { 0: int lock, x; 1: do { 2: lock = 1; 3: x = y; 4: if (*) { 5: lock = 0; 6: y = y+1; } 7: } while (x != y) 8: if (lock != 1) 9: error(); 10: }
×
frontier
1 2 3 4 5 6 7 9 10 8:¬𝑞 8:p
𝜐 = (0,1,2,3,4,7, < 8, 𝑞 >, 9)
void f(int y) { 0: int lock, x; 1: do { 2: lock = 1; 3: x = y; 4: if (*) { 5: lock = 0; 6: y = y+1; } 7: } while (x != y) 8: if (lock != 1) 9: error(); 10: }
1 2 3 4⋀¬s 5⋀¬s 6⋀¬r 9 7⋀¬q 8⋀¬p 4⋀s 5⋀s 6⋀r 7⋀q 8⋀p 10
Sk-2 T Sk-1
𝐷𝐵𝑀𝑀(𝑔𝑝𝑝(𝑗, 𝑘))
Sk frontier
Key idea Perform a recursive Dash query
the result to either generate a test or compute 𝑋𝑄
𝛽
Sk-2 T Sk-1
𝐷𝐵𝑀𝑀(𝑔𝑝𝑝(𝑗, 𝑘))
Sk
?
𝑛𝑣𝑡𝑢 𝒬𝑗
𝒬𝑗 𝜒1 𝜒2 must summary
¬𝑛𝑏𝑧 𝒬𝑗
𝒬𝑗 𝜒1 𝜒2 ¬𝑛𝑏𝑧 𝑡𝑣𝑛𝑛𝑏𝑠𝑧
𝜒1 ∈ Π𝑜1 𝜒2 ∈ Π𝑜2 𝜒1 ∩ Ω𝑜1 ≠ ∅ 𝜒2 ∩ Ω𝑜2 = ∅ 𝑓 = (𝑜1, 𝑜2) ∈ 𝐹𝒬𝑗 𝑗𝑡 𝑏 𝑑𝑏𝑚𝑚 𝑢𝑝 𝑞𝑠𝑝𝑑𝑓𝑒𝑣𝑠𝑓 𝒬
𝑘
𝜒 1, 𝜒 2 ∈
𝑛𝑣𝑡𝑢 𝒬𝑘 Ω𝑜1 ⊇ 𝜒
1 𝜄 ⊆ 𝜒 2 𝜒2 ∩ 𝜄 ≠ ∅ Ω𝑜2 ≔ Ω𝑜2 ∪ 𝜄 [MUST − POST − USESUM]
𝒬
𝑘
𝜒 1 ⊆ Ω𝑜1 (𝜒 2⊇ 𝜄) ∧ (𝜒2 ∩ 𝜄 ≠ ∅) must summary Γ𝑓 = 𝑑𝑏𝑚𝑚 𝒬
𝑘
procedure 𝒬𝑗
1 2 4 6 7 3 5
𝜒 2 𝑈 𝑈 𝜒1 𝑈 𝑈 𝑈 frontier Ω𝑜1 𝜒2
𝜒1 ∈ Π𝑜1 𝜒2 ∈ Π𝑜2 𝜒1 ∩ Ω𝑜1 ≠ ∅ 𝜒2 ∩ Ω𝑜2 = ∅ 𝑓 = (𝑜1, 𝑜2) ∈ 𝐹𝒬𝑗 𝑗𝑡 𝑏 𝑑𝑏𝑚𝑚 𝑢𝑝 𝑞𝑠𝑝𝑑𝑓𝑒𝑣𝑠𝑓 𝒬
𝑘
𝜒 1, 𝜒 2 ∈
𝑛𝑣𝑡𝑢 𝒬𝑘 Ω𝑜1 ⊇ 𝜒
1 𝜄 ⊆ 𝜒 2 𝜒2 ∩ 𝜄 ≠ ∅ Ω𝑜2 ≔ Ω𝑜2 ∪ 𝜄 [MUST − POST − USESUM]
procedure 𝒬𝑗
1 2 4 6 7 3 5
𝜒 2 𝑈 𝑈 𝜒1 𝜒2 𝑈 𝑈 𝑈 frontier Ω𝑜1 𝜄 Γ𝑓 = 𝑑𝑏𝑚𝑚 𝒬
𝑘
𝒬
𝑘
𝜒 1 ⊆ Ω𝑜1 (𝜒 2⊇ 𝜄) ∧ (𝜒2 ∩ 𝜄 ≠ ∅) must summary
𝜒1 ∈ Π𝑜1 𝜒2 ∈ Π𝑜2 𝜒1 ∩ Ω𝑜1 ≠ ∅ 𝜒2 ∩ Ω𝑜2 = ∅ 𝑓 = (𝑜1, 𝑜2) ∈ 𝐹𝒬𝑗 𝑗𝑡 𝑏 𝑑𝑏𝑚𝑚 𝑢𝑝 𝑞𝑠𝑝𝑑𝑓𝑒𝑣𝑠𝑓 𝒬
𝑘
𝜒 1, 𝜒 2 ∈
¬𝑛𝑏𝑧 𝒬𝑘 𝜒2 ⊆ 𝜒
2 𝜄 ⊆ 𝜒 1 ¬𝜄 ∩ Ω𝑜1 = ∅ Π𝑜1 ≔ Π𝑜1 ∖ 𝜒1 ∪ 𝜒1 ∩ 𝜄, 𝜒1 ∩ ¬𝜄 𝑂𝑓 ≔ 𝑂𝑓 ∪ { 𝜒1 ∩ 𝜄, 𝜒2 } [NMAY − PRE − USESUM]
𝑘
𝑘
𝑘
1 2 4 6 7 3 5
𝜒 2 𝑈 𝑈 𝑈 𝑈 𝑈
2
𝑂𝑓 𝜒1 ∩ 𝜄 𝜒1 ∩ ¬𝜄 frontier 𝜒2 procedure 𝒬𝑗 Γ𝑓 = 𝑑𝑏𝑚𝑚 𝒬
𝑘
Γ𝑓 = 𝑑𝑏𝑚𝑚 𝒬
𝑘
𝒬
𝑘
(𝜒 1 ⊇ 𝜄) ∧ (¬𝜄 ∩ Ω𝑜1 = ∅) 𝜒 2 ⊇ 𝜒2 ¬𝑛𝑏𝑧 𝑡𝑣𝑛𝑛𝑏𝑠𝑧
Engineering for making Yogi robust, scalable and industrial
Several of the implemented optimizations are folklore
Vanilla implementation of algorithms:
Algorithms + engineering + optimizations:
42%
Intraprocedural parameter Summary database