Finding Code That Explodes Under Symbolic Evalua<on
James Bornholt Emina Torlak
University of Washington
unsat.org
Finding Code That Explodes Under Symbolic Evalua<on James - - PowerPoint PPT Presentation
Finding Code That Explodes Under Symbolic Evalua<on James Bornholt Emina Torlak University of Washington unsat.org Automated reasoning tools help us solve hard programming problems Automated reasoning tools help us solve hard programming
University of Washington
unsat.org
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
How do I compile code for this weird new architecture? [PLDI’14]
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
How do I compile code for this weird new architecture? [PLDI’14] How do I teach kids the rules of algebra effec8vely? [VMCAI’18]
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
How do I compile code for this weird new architecture? [PLDI’14]
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
How do I compile code for this weird new architecture? [PLDI’14] Interpreter for file system
Interpreter for new architecture instruc8ons
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
How do I compile code for this weird new architecture? [PLDI’14]
Symbolic evaluator
Sketch, RoseWe, …
Interpreter for file system
Interpreter for new architecture instruc8ons
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
How do I compile code for this weird new architecture? [PLDI’14]
Symbolic evaluator
Sketch, RoseWe, …
Verifica8on Synthesis Angelic Execu8on for free! Interpreter for file system
Interpreter for new architecture instruc8ons
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
Symbolic evaluator
Sketch, RoseWe, …
Verifica8on Synthesis Angelic Execu8on for free! Interpreter for file system
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
Symbolic evaluator
Sketch, RoseWe, …
Verifica8on Synthesis Angelic Execu8on for free! Interpreter for file system
Does my program s8ll work a:er the file system crashes? [ASPLOS’16]
Searching all paths through the interpreter Searching all paths through the interpreter
Symbolic evaluator
Sketch, RoseWe, …
Verifica8on Synthesis Angelic Execu8on for free! Interpreter for file system
Data structures and analyses
Data structures and analyses
Common issues and source-level repairs
10 20 1500
Data structures and analyses
Common issues and source-level repairs
300× speedup on real-world tools
10 20 1500
Data structures and analyses
Common issues and source-level repairs
300× speedup on real-world tools
10 20 1500
All-paths execu8on of programs
if (…) { … } ∀x. φ(…, x)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k))
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k)) Inputs are unknown (trying to find values that violate spec)
(filter even? ‘(x0 x1))
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k)) Inputs are unknown (trying to find values that violate spec)
(filter even? ‘(x0 x1)) ‘() ‘(x0)
¬(even? x0) (even? x0)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k)) Inputs are unknown (trying to find values that violate spec)
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k)) Inputs are unknown (trying to find values that violate spec)
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k)) Inputs are unknown (trying to find values that violate spec)
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k))
‘() ‘()
k=0
Inputs are unknown (trying to find values that violate spec)
‘(x1) ‘() ‘(x0) ‘() ‘(x0) ‘(x0 x1)
k=0 k=1 k=0 k=1 k=0 k=1 k=2
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k))
‘() ‘()
k=0
Inputs are unknown (trying to find values that violate spec) take runs 22 8mes
‘(x1) ‘() ‘(x0) ‘() ‘(x0) ‘(x0 x1)
k=0 k=1 k=0 k=1 k=0 k=1 k=2
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
#lang rosette (define (first-k-even lst k) (define xs (filter even? lst)) (take xs k))
‘() ‘()
k=0
Inputs are unknown (trying to find values that violate spec) take runs 22 8mes because filter ran
‘(x1) ‘() ‘(x0) ‘() ‘(x0) ‘(x0 x1)
k=0 k=1 k=0 k=1 k=0 k=1 k=2
Blaming filter even though it’s not the slowest
‘() ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
(even? x0) ∧ ¬ ∧ ∧ ∧ ¬ (even? x1)
Symbolic evalua<on graph Reflects the evaluator’s strategy for all-paths execu8on of the program Symbolic heap Shape of all symbolic values created by the program
Symbolic evalua<on graph
between states
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
‘() ‘()
k=0
‘(x1) ‘() ‘(x0) ‘() ‘(x0) ‘(x0 x1)
k=0 k=1 k=0 k=1 k=0 k=1 k=2
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
Symbolic execu8on
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
Symbolic execu8on
(filter even? ‘(x0 x1)) ‘() ‘(x0)
¬(even? x0) (even? x0)
Bounded model checking
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
Symbolic execu8on
(filter even? ‘(x0 x1)) ‘() ‘(x0)
¬(even? x0) (even? x0)
ys0
ys0 = (ite (even? x0) ‘() ‘(x0))
Bounded model checking
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
Symbolic execu8on
(filter even? ‘(x0 x1)) ‘() ‘(x0)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1)
ys0 ys0 ys1
ys0 = (ite (even? x0) ‘() ‘(x0)) ys1 = (append ys0 ‘(x1))
Bounded model checking
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
Symbolic execu8on
(filter even? ‘(x0 x1)) ‘() ‘(x0)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1)
ys0 ys0 ys1 ys2
ys0 = (ite (even? x0) ‘() ‘(x0)) ys1 = (append ys0 ‘(x1)) ys2 = (ite (even? x1) ys1 ys0)
Bounded model checking
(filter even? ‘(x0 x1)) ‘() ‘(x0) ‘() ‘(x1) ‘(x0) ‘(x0 x1)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1) (even? x1) ¬(even? x1)
Symbolic execu8on
(filter even? ‘(x0 x1)) ‘() ‘(x0)
¬(even? x0) (even? x0) (even? x1) ¬(even? x1)
ys0 ys0 ys1 ys2
ys0 = (ite (even? x0) ‘() ‘(x0)) ys1 = (append ys0 ‘(x1)) ys2 = (ite (even? x1) ys1 ys0)
Bounded model checking
More states, but more concrete Fewer states but less concrete
(even? x0) ∧ ¬ ∧ ∧ ∧ ¬ (even? x1)
Symbolic execu8on
Symbolic heap
(even? x0) ∧ ¬ ∧ ∧ ∧ ¬ (even? x1) (even? x0) (even? x1) ite ‘(x0) ‘() ‘(x1) append ite
ys0 = ys1 = ys2 =
Symbolic execu8on Bounded model checking
ys0 = (ite (even? x0) ‘() ‘(x0)) ys1 = (append ys0 ‘(x1)) ys2 = (ite (even? x1) ys1 ys0)
Only condi8ons in the heap Condi8ons and values (lists etc.) in the heap
(even? x0) ∧ ¬ ∧ ∧ ∧ ¬ (even? x1) (even? x0) (even? x1) ite ‘(x0) ‘() ‘(x1) append ite
ys0 = ys1 = ys2 =
Symbolic execu8on Bounded model checking
ys0 = (ite (even? x0) ‘() ‘(x0)) ys1 = (append ys0 ‘(x1)) ys2 = (ite (even? x1) ys1 ys0)
For each procedure, measure metrics that summarize the evolu8on of the symbolic evalua8on graph and symbolic heap
For each procedure, measure metrics that summarize the evolu8on of the symbolic evalua8on graph and symbolic heap Summarize metrics as a score to rank procedures in the program
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
(define (list-set lst idx val) (match lst [(cons x xs) (if (= idx 0) (cons val xs) (cons x (list-set xs (- idx 1) val))] [_ lst]))
Terminates early
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
(define (list-set lst idx val) (match lst [(cons x xs) (if (= idx 0) (cons val xs) (cons x (list-set xs (- idx 1) val))] [_ lst]))
Terminates early
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
(define (list-set lst idx val) (match lst [(cons x xs) (cons (if (= idx 0) val x) (list-set xs (- idx 1) val))] [_ lst]))
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
(define (list-set lst idx val) (match lst [(cons x xs) (cons (if (= idx 0) val x) (list-set xs (- idx 1) val))] [_ lst]))
Always recurse to the end of lst
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
(define (list-set lst idx val) (match lst [(cons x xs) (cons (if (= idx 0) val x) (list-set xs (- idx 1) val))] [_ lst]))
Always recurse to the end of lst
Time (sec)
5 10 15 20
Length
500 1000 1500 2000
Original Repaired
Algorithms or op8miza8ons poorly suited to symbolic evalua8on
Data structures of different shapes create different paths
Lost opportuni8es to exploit concrete values
Today
Tool Speedup Type system soundness checker [POPL’18] 1.35× Refinement type checker for Ruby [VMCAI’18] 6× File-system crash consistency verifier [ASPLOS’16] 24× Cryptographic protocol verifier [FM’18] 29× SQL query verifier [CIDR’17] 75× Safety-cri8cal radiotherapy system verifier [CAV’16] 290×
Tool Speedup Type system soundness checker [POPL’18] 1.35× Refinement type checker for Ruby [VMCAI’18] 6× File-system crash consistency verifier [ASPLOS’16] 24× Cryptographic protocol verifier [FM’18] 29× SQL query verifier [CIDR’17] 75× Safety-cri8cal radiotherapy system verifier [CAV’16] 290×
Used in produc8on at the UW Medical Center
6 failures without symbolic profiling, none with
“gave insight into what RoseWe is doing” “even more useful on my own code”
Does my program work
Verifica8on
Is there a program that does what I want?
Synthesis👸