SlideShare a Scribd company logo
1 of 82
Automa'c Patch Genera'on
Claire {Le~Goues}
PWLConf; September 15, 2016
1
ONCE UPON A
TIME…
2
Young Claire
3
Young Claire
(developer)
4
Bug report from
a customer…
5
6
??!
32-64 bit transiYon
for Unicode encoding
of Ukrainian.
Problem: source-level defect repair
7
bug-fixing patch
Bug fixing: the 30000-foot view
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patches.
8
Tests.
Bug fixing: the 30000-foot view
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patches.
9
Fault
localizaYon
10
prind
transformer
11
prind
transformer
Input:
2
5 6
1
3 4
8
7
9
11
10
12
Likely faulty.
probability
Maybe faulty.
probability
Not faulty.
Spectrum-based fault localiza'on
automa'cally ranks poten'ally
buggy program pieces based on
test case behavior.
Bug fixing: the 30000-foot view
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patch.
12
1. Heuris'c: including
meta-heurisYc,
“guess and check.”
2. Seman'c: symbolic
execuYon + SMT
solvers, synthesis.
GenProg: automa'c program
repair using gene'c programming.
Biased, random
search for a AST-level
edits to a program
that fixes a given bug
without breaking any
previously-passing
tests.
13
hLps://upload.wikimedia.org/wikipedia/commons/a/a4/13-02-27-spielbank-wiesbaden-by-RalfR-093.jpg
Genetic programming: the application
of evolutionary or genetic algorithms
to program source code.
14
INPUT
OUTPUT
EVALUATE FITNESS
DISCARD
ACCEPT
MUTATE
15
GenProg: meta-heuris'c search.
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patch.
16
Localize to C
statements.
Use geneYc
programming to search
for statement-level
patches, reusing code
from exisYng proram.
17
1 void gcd(int a, int b) {
2 if (a == 0) {
3 printf(“%d”, b);
4 }
5 while (b > 0) {
6 if (a > b)
7 a = a – b;
8 else
9 b = b – a;
10 }
11 printf(“%d”, a);
12 return;
13 }
>
18
1 void gcd(int a, int b) {
2 if (a == 0) {
3 printf(“%d”, b);
4 }
5 while (b > 0) {
6 if (a > b)
7 a = a – b;
8 else
9 b = b – a;
10 }
11 printf(“%d”, a);
12 return;
13 }
> gcd(4,2)
> 2
>
> gcd(1071,1029)
> 21
>
> gcd(0,55)
> 55
(looping forever)
!
GenProg: meta-heuris'c search.
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patch.
19
Localize to C
statements.
Use geneYc
programming to search
for statement-level
patches, reusing code
from exisYng proram.
20
printf(b)
{block}
while
(b>0)
{block}
{block} {block}
if(a==0)
if(a>b)
a = a – b
{block}
{block}
printf(a) return
b = b – a
Input:
21
printf(b)
{block}
while
(b>0)
{block}
{block} {block}
if(a==0)
if(a>b)
a = a – b
{block}
{block}
printf(a) return
b = b – a
Input:
Legend:
High change
probability.
Low change
probability.
Not changed.
• A patch is a series of statement-level edits:
– delete X
– replace X with Y
– insert Y aqer X.
• Replace/insert: pick Y from somewhere else in the
program.
• To mutate an individual, add new random edits to a
given (possibly empty) patch.
– (Where? Right: fault localizaYon!)
22
An individual is a candidate patch/set of
changes to the input program.
23
printf(b)
{block}
while
(b>0)
{block}
{block} {block}
if(a==0)
if(a>b)
a = a – b
{block}
{block}
printf(a) return
b = b – a
Input:
An edit is:
• Insert statement X
aqer statement Y
• Replace statement X
with statement Y
• Delete statement X
24
printf(b)
{block}
while
(b>0)
{block}
{block} {block}
if(a==0)
if(a>b)
a = a – b
{block}
{block}
printf(a) return
b = b – a
Input:
An edit is:
• Insert statement X
aOer statement Y
• Replace statement X
with statement Y
• Delete statement X
25
printf(b)
{block}
while
(b>0)
{block}
{block} {block}
if(a==0)
if(a>b)
a = a – b
{block}
{block}
printf(a) return
b = b – a
Input:
An edit is:
• Insert statement X
aOer statement Y
• Replace statement X
with statement Y
• Delete statement X
26
{block}
while
(b>0)
{block}
{block} {block}
if(a==0)
if(a>b)
a = a – b
{block}
{block}
printf(a) return
b = b – a
Input:
An edit is:
• Insert statement X
aOer statement Y
• Replace statement X
with statement Y
• Delete statement X
return
printf(b)
What about Angelix?
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patch.
27
Same idea, but
localizing to
expressions.
RHS of
assignments,
condiYonals.
1 int is_upward( int inhibit, int up_sep, int down_sep){
2 int bias;
3 if (inhibit)
4 bias = down_sep; // bias= up_sep + 100
5 else bias = up_sep ;
6 if (bias > down_sep)
7 return 1;
8 else return 0;
9 }
28
Tremendous graYtude to Abhik Roychoudhury for sharing slides with me as starYng
material for this talk.
1 int is_upward( int inhibit, int up_sep, int down_sep){
2 int bias;
3 if (inhibit)
4 bias = down_sep; // bias= up_sep + 100
5 else bias = up_sep ;
6 if (bias > down_sep)
7 return 1;
8 else return 0;
9 }
29
inhibit up_sep down_sep Observed
output
Expected
Output
Result
1 0 100 0 0 pass
1 11 110 0 1 fail
0 100 50 1 1 pass
1 -20 60 0 1 fail
0 0 10 0 0 pass
What about Angelix?
1. Localize the bug.
– And possibly analyze it
a liLle bit…
2. Create/combine fix
possibiliYes into 1+
possible patches.
3. Validate candidate
patch.
30
Concolic execu3on
to find expression
values that would
make the test pass.
Program synthesis to
construct replacement
code that produces those
values.
An expression’s angelic value is the
value that would make a given test
case pass.
• This value is set “arbitrarily”, by which we mean
symbolically.
• You can solve for this value if you have:
– the test case’s expected input/output.
– the path condiYon controlling its execuYon.
• Path condiYon: the set of condiYons that controlled
a parYcular execuYon.
– Start execuYng the test concretely, and then switch to
symbolic execuYon when the angelic value starts to
maLer.
31
1 int is_upward( int inhibit, int up_sep, int down_sep){
2 int bias;
3 if (inhibit)
4 bias = down_sep; // bias= up_sep + 100
5 else bias = up_sep ;
6 if (bias > down_sep)
7 return 1;
8 else return 0;
9 }
32
inhibit up_sep down_sep Observed
output
Expected
Output
Result
1 0 100 0 0 pass
1 11 110 0 1 fail
0 100 50 1 1 pass
1 -20 60 0 1 fail
0 0 10 0 0 pass
1 int is_upward( int inhibit, int up_sep, int down_sep){
2 int bias;
3 if (inhibit)
4 bias = ®; // bias= up_sep + 100
5 else bias = up_sep ;
6 if (bias > down_sep)
7 return 1;
8 else return 0;
9 }
33
inhibit up_sep down_sep Observed
output
Expected
Output
Result
1 11 110 0 1 fail
inhibit = 1, up_sep = 11, down_sep = 110
bias = ®, PC = true
Line 4
inhibit = 1, up_sep = 11, down_sep = 110
bias = ®, PC= ®> 110
Line 7
inhibit = 1, up_sep = 11, down_sep = 110
bias =®, PC= ® ≤ 110
Line 8
What should it have been?
34
1 int is_upward( int inhibit, int up_sep, int down_sep){
2 int bias;
3 if (inhibit)
4 ® = f(inhibit, up_sep, down_sep)
5 else bias = up_sep ;
6 if (bias > down_sep)
7 return 1;
8 else return 0;
9 }
inhibit == 1 up_sep == 11 down_sep == 110
Symbolic ExecuYon
f(1,11,110) > 110
Collect all of the constraints!
• Accumulated constraints over all test cases:
• Use oracle guided component-based program synthesis to
construct saYsfying f:
– Fix a set of of operators (component-based).
– Synthesize code that only uses those operators and saYsfies the
constraints (oracle guided).
• Generated fix
– f(inhibit,up_sep,down_sep) = up_sep + 100
35
f(1,11,110) > 110 ∧ f(1,0,100) ≤ 100
∧ f(1,-20,60) > 60
(Legi'mately interes'ng encoding
of synthesis problem elided for
(dubious) brevity.)
36
So why all that a_en'on paid to
“forests”?
37
hLps://commons.wikimedia.org/wiki/File:Michael_Spiller_-_twisty_forest_paths_(by-sa).jpg
Angelic Forest
38
E1
E2
E3
Program Angelic Paths
Angelic Forest
39
E1
E2
E3
Program Angelic Paths
SAT
angelic1
angelic2
angelic3
Angelic Forest
40
E1
E2
E3
Program Angelic Paths
UNSAT
angelic1
angelic2
angelic3
Angelic Forest
41
E1
E2
E3
Program Angelic Paths
SAT
angelic1
angelic2
angelic3
angelic1
angelic3
Angelic Forest
42
E1
E2
E3
Program Angelic Paths
UNSAT
angelic1
angelic2
angelic3
angelic1
angelic3
Tradeoffs
and
Challenges
43
Scalability
Expressive power
Output quality
hLps://www.flickr.com/photos/86530412@N02/7935377706
: hLps://pixabay.com/en/approved-control-quality-stamp-147677/
hLps://www.flickr.com/photos/cimmyt/5219256862
Program Descrip'on LOC Bug Type Time
44
(s)
Program Descrip'on LOC Bug Type Time
gcd example 22 infinite loop 153
nullhLpd webserver 5575 heap buffer overflow (code) 578
zune example 28 infinite loop 42
uniq text processing 1146 segmentaYon fault 34
look-u dicYonary lookup 1169 segmentaYon fault 45
look-s dicYonary lookup 1363 infinite loop 55
units metric conversion 1504 segmentaYon fault 109
deroff document processing 2236 segmentaYon fault 131
indent code processing 9906 infinite loop 546
flex lexical analyzer generator 18774 segmentaYon fault 230
openldap directory protocol 292598 non-overflow denial of service 665
ccrypt encrypYon uYlity 7515 segmentaYon fault 330
lighLpd webserver 51895 heap buffer overflow (vars) 394
atris graphical game 21553 local stack buffer exploit 80
php scripYng language 764489 integer overflow 56
wu-qpd FTP server 67029 format string vulnerability 2256
leukocyte computaYonal biology 6718 segmentaYon fault 360
Yff image processing 84067 segmentaYon fault 108
imagemagick image processing 450516 wrong output 2160
(s)
45
Program Descrip'on LOC Bug Type Time
gcd example 22 infinite loop 153
nullhLpd webserver 5575 heap buffer overflow (code) 578
zune example 28 infinite loop 42
uniq text processing 1146 segmentaYon fault 34
look-u dicYonary lookup 1169 segmentaYon fault 45
look-s dicYonary lookup 1363 infinite loop 55
units metric conversion 1504 segmentaYon fault 109
deroff document processing 2236 segmentaYon fault 131
indent code processing 9906 infinite loop 546
flex lexical analyzer generator 18774 segmentaYon fault 230
openldap directory protocol 292598 non-overflow denial of service 665
ccrypt encrypYon uYlity 7515 segmentaYon fault 330
lighLpd webserver 51895 heap buffer overflow (vars) 394
atris graphical game 21553 local stack buffer exploit 80
php scripYng language 764489 integer overflow 56
wu-qpd FTP server 67029 format string vulnerability 2256
leukocyte computaYonal biology 6718 segmentaYon fault 360
Yff image processing 84067 segmentaYon fault 108
imagemagick image processing 450516 wrong output 2160
(s)
46
Program Descrip'on LOC Bug Type Time
gcd example 22 infinite loop 153
nullhLpd webserver 5575 heap buffer overflow (code) 578
zune example 28 infinite loop 42
uniq text processing 1146 segmentaYon fault 34
look-u dicYonary lookup 1169 segmentaYon fault 45
look-s dicYonary lookup 1363 infinite loop 55
units metric conversion 1504 segmentaYon fault 109
deroff document processing 2236 segmentaYon fault 131
indent code processing 9906 infinite loop 546
flex lexical analyzer generator 18774 segmentaYon fault 230
openldap directory protocol 292598 non-overflow denial of service 665
ccrypt encrypYon uYlity 7515 segmentaYon fault 330
lighLpd webserver 51895 heap buffer overflow (vars) 394
atris graphical game 21553 local stack buffer exploit 80
php scripYng language 764489 integer overflow 56
wu-qpd FTP server 67029 format string vulnerability 2256
leukocyte computaYonal biology 6718 segmentaYon fault 360
Yff image processing 84067 segmentaYon fault 108
imagemagick image processing 450516 wrong output 2160
(s)
47
Program Descrip'on LOC Bug Type Time
gcd example 22 infinite loop 153
nullhLpd webserver 5575 heap buffer overflow (code) 578
zune example 28 infinite loop 42
uniq text processing 1146 segmentaYon fault 34
look-u dicYonary lookup 1169 segmentaYon fault 45
look-s dicYonary lookup 1363 infinite loop 55
units metric conversion 1504 segmentaYon fault 109
deroff document processing 2236 segmentaYon fault 131
indent code processing 9906 infinite loop 546
flex lexical analyzer generator 18774 segmentaYon fault 230
openldap directory protocol 292598 non-overflow denial of service 665
ccrypt encrypYon uYlity 7515 segmentaYon fault 330
lighLpd webserver 51895 heap buffer overflow (vars) 394
atris graphical game 21553 local stack buffer exploit 80
php scripYng language 764489 integer overflow 56
wu-qpd FTP server 67029 format string vulnerability 2256
leukocyte computaYonal biology 6718 segmentaYon fault 360
Yff image processing 84067 segmentaYon fault 108
imagemagick image processing 450516 wrong output 2160
(s)
48
“IF I GAVE YOU THE LAST 100
BUGS FROM <MY PROJECT>,
HOW MANY COULD
GENPROG ACTUALLY FIX?”
– MANY PEOPLE
49
• Goal: a large set of
important,
reproducible bugs
in non-trivial
programs.
• Approach: use
historical data
(source control!) to
approximate
discovery and repair
of bugs in the wild.
Challenge: Indica've Bug Set
50
Success/Cost
Program
Defects
Repaired
Cost per non-repair Cost per repair
Hours US$ Hours US$
|c 1/3 8.52 5.56 6.52 4.08
gmp 1/2 9.93 6.61 1.60 0.44
gzip 1/5 5.11 3.04 1.41 0.30
libYff 17/24 7.81 5.04 1.05 0.04
lighLpd 5/9 10.79 7.25 1.34 0.25
php 28/44 13.00 8.80 1.84 0.62
python 1/11 13.00 8.80 1.22 0.16
wireshark 1/7 13.00 8.80 1.23 0.17
Total 55/105 11.22h 1.60h
• $403 for all 105 trials, leading to 55 repairs; $7.32 per bug repaired.
51
Comparison (Repair-ability)
52
57%
23%
40%
100%
42%
57%
41%
40%
100%
21%
14%
11%
20%
50%
13%
WIRESHARK PHP GZIP GMP LIBTIFF
Angelix SPR GenProg
Heartbleed patch
53
if (hbtype == TLS1_HB_REQUEST
&& (payload + 18) < s->s3->rrec.length) {
…
} else if (hbtype == TLS1_HB_RESPONSE) {
…
}
return 0;
Generated patch
if (1 + 2 + payload + 16 > s->s3->rrec.length)
return 0;
…
if (hbtype == TLS1_HB_REQUEST) {
…
} else if (hbtype == TLS1_HB_RESPONSE) {
…
}
return 0;
Developer patch
Tradeoffs
and
Challenges
54
Scalability
Output quality
Expressive power
Flashback to 2008…
“delete handling
of POST requests”
55
ß nullhLpd: a webserver with basic
GET + POST funcYonality.
Version 0.5.0: remote-exploitable
heap-based buffer overflow in
handling of POST.
Failing test case: run
exploit, see if
webserver is sYll
running
Easy passing test cases:
1. “GET index.html”
2. “GET image.jpg”
3. “GET nodound.html”
+
=
CC0 Public Domain
When we added a non-crashing
test case for POST, proto-GenProg
found a much be_er patch.
• When the test suite is your objecYve
funcYon, test suite quality maLers.
–…how much is a trickier issue.
• But we’re begging the quesYon...
56
hLps://en.wikipedia.org/wiki/Basket-hilted_sword#/media/File:Schiavona-Morges.jpg
57
hLps://en.wikipedia.org/wiki/Basket-hilted_sword#/media/File:Schiavona-Morges.jpg
When we added a non-crashing
test case for POST, proto-GenProg
found a much be_er patch.
• When the test suite is your objecYve
funcYon, test suite quality maLers.
–…how much is a trickier issue.
• But we’re begging the quesYon...
58
hLps://en.wikipedia.org/wiki/Basket-hilted_sword#/media/File:Schiavona-Morges.jpg
What is a high quality patch,
anyway?
• Understandable?
– Well, I had no problem understanding the POST-deleYng
patch…
– (non-funcYonal properYes are important and being studied by
others!)
• Doesn’t delete?
– But what about goto fail?
• Does the same thing the human did/would do?
– But humans are oqen wrong! And how close does it have to
be?
• Doesn’t introduce new bugs?
– How to tell?
• Addresses the cause, not the symptom…
59
Proposal: measure quality based
on degree to which results
generalize.
• In machine learning, techniques are
trained and evaluated on disjoint
datasets to assess overfi‚ng.
• In program repair:
–Tests used to build a repair are training
tests
–Tests used to assess correctness are
evalua3on tests
60
PROBLEM: THE DESIRED STUDY IS
IMPOSSIBLE.
61
[Dataset + Tools]
• Student homework submissions from six UC
Davis IntroducYon to Programming assignments
• Two full-coverage test suites:
– White-box suite generated by Klee from reference
implementaYon.
– Black-box suite wriLen by course instructor.
– Feature: Assess patch quality as dis3nct from test
suite quality.
• Goal: Compare GenProg and TrpAutoRepair/
RSRepair, G&V techniques with different search
strategies.
62
Full dataset available at repairbenchmarks.cs.umass.edu
Both tools produced patches that
overfit to the training set.
63
But: the tools do as well as the
students!
64
Overfivng is not unique
toheuris'c techniques.
• Angelix: 120/233 of patches produced on
a subset to IntroClass overfit.
• ~40% of SPR patches studied in Angelix
paper delete funcYonality by generaYng
tautological if condiYons.
65
Overfivng is not unique
toheuris'c techniques.
• Angelix: 120/233 of patches produced on
a subset to IntroClass overfit.
• ~40% of SPR patches studied in Angelix
paper delete funcYonality by generaYng
tautological if condiYons.
66
PhD students observe that
much of the problem is in the
synthesis of overly constrained
if condiYons.
Quality Comparison with SPR
67
25%
30%
0%
0%
20%
25%
39%
50%
0%
80%
WIRESHARK PHP GZIP GMP LIBTIFF
FUNCTIONALITY-DELETING REPAIRS
Angelix SPR
68
OPTION 1: UNDERSTAND AND REASON
ABOUT THE CIRCUMSTANCES UNDER
WHICH PERFECTION IS NOT REQUIRED.
Context maLers!
69
70
2012 flashback…
ß Scenario: Long-running servers +
IDS + generate repairs for
detected anomalies.
ß Workloads: a day of unfiltered
requests to the UVA CS
webserver.
THIS PATCH
WAS BAD
Even a func'onality-reducing repair
had li_le prac'cal impact.
Program Post-patch requests lost
Fuzz Tests Failed
General Exploit
nullhLpd 0.00 % ± 0.25% 0 à 0 10 à 0
lighLpd 0.03% ± 1.53% 1410 à 1410 9 à 0
php-BAD 0.02% ± 0.02% 3 à 3 5 à 0
71
OPTION 2: DEVELOP TECHNIQUES THAT
ARE MORE LIKELY TO GENERALIZE.
How?
72
Challenge your assump'ons!
73
EXAMPLE
ASSUMPTION:
bug-fixing
patches are like
kittens: smaller
is better!
"Retouched KiLy" by Ozan Kilic, CC2.0 hLp://www.freestockphotos.biz/stockphoto/9343
• Instead of trying to make small changes, we
replaced buggy regions with code that
correctly captures the overall desired
logic?
• Principle: using human-wriLen code to
fix code at a higher granularity level
leads to beLer quality repairs.
•
What if…
74
SEARCHREPAIR:
HIGH-QUALITY
AUTOMATED BUG
REPAIR USING
SEMANTIC SEARCH
75
Seman'c code search looks for
code based on what it should do.
• Keyword: “C median three numbers”
• SemanYc:
Input Expected
2,6,8 6
2,8,6 6
6,2,8 6
6,8,2 6
8,6,2 6
9,9,9 9
76
…Generate and validate + SemanYc reasoning!
SearchRepair patches were of
much higher quality than those
produced by previous techniques.
77
Technique
Held out tests
passed
SearchRepair 97.2%
GenProg 68.7%
TRPAP 72.1%
AE 64.2%
78
The Three
Major
Challenges
79
Scalability
Output quality
Expressive power
80
80
inhibit = 1, up_sep = 11, down_sep = 110
bias = ®, PC = true
Line 4
inhibit = 1, up_sep = 11, down_sep = 110
bias = ®, PC= ®> 110
Line 7
inhibit = 1, up_sep = 11, down_sep = 110
bias =®, PC= ® ≤ 110
Line 8
COLLABORATORS MAKE
THE WORLD GO ROUND
81
82
AE: 1
SearchRepair: 20
GenProg: 32
52
0
0
68
RSRepair: 2
10
90
0
0
0
GenProg total: 287 AE total: 159
RSRepair total: 247
SearchRepair total: 150

More Related Content

Similar to clegoues-pwlconf-sept16-asPDF.pdf

Frege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMFrege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMDierk König
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia岳華 杜
 
20170415 當julia遇上資料科學
20170415 當julia遇上資料科學20170415 當julia遇上資料科學
20170415 當julia遇上資料科學岳華 杜
 
20171127 當julia遇上資料科學
20171127 當julia遇上資料科學20171127 當julia遇上資料科學
20171127 當julia遇上資料科學岳華 杜
 
Pepe Vila - Cache and Syphilis [rooted2019]
Pepe Vila - Cache and Syphilis [rooted2019]Pepe Vila - Cache and Syphilis [rooted2019]
Pepe Vila - Cache and Syphilis [rooted2019]RootedCON
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesGanesh Samarthyam
 
Demystifying Zero Knowledge Proofs [FINAL].pptx
Demystifying Zero Knowledge Proofs [FINAL].pptxDemystifying Zero Knowledge Proofs [FINAL].pptx
Demystifying Zero Knowledge Proofs [FINAL].pptxRedWhite12
 
Camouflage: Automated Anonymization of Field Data (ICSE 2011)
Camouflage: Automated Anonymization of Field Data (ICSE 2011)Camouflage: Automated Anonymization of Field Data (ICSE 2011)
Camouflage: Automated Anonymization of Field Data (ICSE 2011)James Clause
 
Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Maarten Mulders
 
Introduction to Julia
Introduction to JuliaIntroduction to Julia
Introduction to Julia岳華 杜
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCanSecWest
 
Erlang bootstrap course
Erlang bootstrap courseErlang bootstrap course
Erlang bootstrap courseMartin Logan
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teamscentralohioissa
 
lecture8_Cuong.ppt
lecture8_Cuong.pptlecture8_Cuong.ppt
lecture8_Cuong.pptHongV34104
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia岳華 杜
 

Similar to clegoues-pwlconf-sept16-asPDF.pdf (20)

Frege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVMFrege - consequently functional programming for the JVM
Frege - consequently functional programming for the JVM
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia
 
20170415 當julia遇上資料科學
20170415 當julia遇上資料科學20170415 當julia遇上資料科學
20170415 當julia遇上資料科學
 
20171127 當julia遇上資料科學
20171127 當julia遇上資料科學20171127 當julia遇上資料科學
20171127 當julia遇上資料科學
 
random test
random testrandom test
random test
 
Pepe Vila - Cache and Syphilis [rooted2019]
Pepe Vila - Cache and Syphilis [rooted2019]Pepe Vila - Cache and Syphilis [rooted2019]
Pepe Vila - Cache and Syphilis [rooted2019]
 
APSEC2020 Keynote
APSEC2020 KeynoteAPSEC2020 Keynote
APSEC2020 Keynote
 
Python for Beginners(v2)
Python for Beginners(v2)Python for Beginners(v2)
Python for Beginners(v2)
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Advanced Debugging Using Java Bytecodes
Advanced Debugging Using Java BytecodesAdvanced Debugging Using Java Bytecodes
Advanced Debugging Using Java Bytecodes
 
Demystifying Zero Knowledge Proofs [FINAL].pptx
Demystifying Zero Knowledge Proofs [FINAL].pptxDemystifying Zero Knowledge Proofs [FINAL].pptx
Demystifying Zero Knowledge Proofs [FINAL].pptx
 
Camouflage: Automated Anonymization of Field Data (ICSE 2011)
Camouflage: Automated Anonymization of Field Data (ICSE 2011)Camouflage: Automated Anonymization of Field Data (ICSE 2011)
Camouflage: Automated Anonymization of Field Data (ICSE 2011)
 
Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)Building a DSL with GraalVM (CodeOne)
Building a DSL with GraalVM (CodeOne)
 
21221
2122121221
21221
 
Introduction to Julia
Introduction to JuliaIntroduction to Julia
Introduction to Julia
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
Erlang bootstrap course
Erlang bootstrap courseErlang bootstrap course
Erlang bootstrap course
 
Aaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security TeamsAaron Bedra - Effective Software Security Teams
Aaron Bedra - Effective Software Security Teams
 
lecture8_Cuong.ppt
lecture8_Cuong.pptlecture8_Cuong.ppt
lecture8_Cuong.ppt
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
 

Recently uploaded

Motivation and Theory Maslow and Murray pdf
Motivation and Theory Maslow and Murray pdfMotivation and Theory Maslow and Murray pdf
Motivation and Theory Maslow and Murray pdfakankshagupta7348026
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Salam Al-Karadaghi
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfhenrik385807
 
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptxBasil Achie
 
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...NETWAYS
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...NETWAYS
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...henrik385807
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...NETWAYS
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Krijn Poppe
 
George Lever - eCommerce Day Chile 2024
George Lever -  eCommerce Day Chile 2024George Lever -  eCommerce Day Chile 2024
George Lever - eCommerce Day Chile 2024eCommerce Institute
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024eCommerce Institute
 
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Kayode Fayemi
 
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSebastiano Panichella
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Pooja Nehwal
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Delhi Call girls
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 

Recently uploaded (20)

Motivation and Theory Maslow and Murray pdf
Motivation and Theory Maslow and Murray pdfMotivation and Theory Maslow and Murray pdf
Motivation and Theory Maslow and Murray pdf
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
 
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
 
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
 
George Lever - eCommerce Day Chile 2024
George Lever -  eCommerce Day Chile 2024George Lever -  eCommerce Day Chile 2024
George Lever - eCommerce Day Chile 2024
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
 
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
Governance and Nation-Building in Nigeria: Some Reflections on Options for Po...
 
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation TrackSBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
SBFT Tool Competition 2024 - CPS-UAV Test Case Generation Track
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 

clegoues-pwlconf-sept16-asPDF.pdf

  • 1. Automa'c Patch Genera'on Claire {Le~Goues} PWLConf; September 15, 2016 1
  • 4. 4 Bug report from a customer…
  • 5. 5
  • 6. 6 ??! 32-64 bit transiYon for Unicode encoding of Ukrainian.
  • 7. Problem: source-level defect repair 7 bug-fixing patch
  • 8. Bug fixing: the 30000-foot view 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patches. 8 Tests.
  • 9. Bug fixing: the 30000-foot view 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patches. 9 Fault localizaYon
  • 11. 11 prind transformer Input: 2 5 6 1 3 4 8 7 9 11 10 12 Likely faulty. probability Maybe faulty. probability Not faulty. Spectrum-based fault localiza'on automa'cally ranks poten'ally buggy program pieces based on test case behavior.
  • 12. Bug fixing: the 30000-foot view 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patch. 12 1. Heuris'c: including meta-heurisYc, “guess and check.” 2. Seman'c: symbolic execuYon + SMT solvers, synthesis.
  • 13. GenProg: automa'c program repair using gene'c programming. Biased, random search for a AST-level edits to a program that fixes a given bug without breaking any previously-passing tests. 13 hLps://upload.wikimedia.org/wikipedia/commons/a/a4/13-02-27-spielbank-wiesbaden-by-RalfR-093.jpg
  • 14. Genetic programming: the application of evolutionary or genetic algorithms to program source code. 14
  • 16. GenProg: meta-heuris'c search. 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patch. 16 Localize to C statements. Use geneYc programming to search for statement-level patches, reusing code from exisYng proram.
  • 17. 17 1 void gcd(int a, int b) { 2 if (a == 0) { 3 printf(“%d”, b); 4 } 5 while (b > 0) { 6 if (a > b) 7 a = a – b; 8 else 9 b = b – a; 10 } 11 printf(“%d”, a); 12 return; 13 } >
  • 18. 18 1 void gcd(int a, int b) { 2 if (a == 0) { 3 printf(“%d”, b); 4 } 5 while (b > 0) { 6 if (a > b) 7 a = a – b; 8 else 9 b = b – a; 10 } 11 printf(“%d”, a); 12 return; 13 } > gcd(4,2) > 2 > > gcd(1071,1029) > 21 > > gcd(0,55) > 55 (looping forever) !
  • 19. GenProg: meta-heuris'c search. 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patch. 19 Localize to C statements. Use geneYc programming to search for statement-level patches, reusing code from exisYng proram.
  • 20. 20 printf(b) {block} while (b>0) {block} {block} {block} if(a==0) if(a>b) a = a – b {block} {block} printf(a) return b = b – a Input:
  • 21. 21 printf(b) {block} while (b>0) {block} {block} {block} if(a==0) if(a>b) a = a – b {block} {block} printf(a) return b = b – a Input: Legend: High change probability. Low change probability. Not changed.
  • 22. • A patch is a series of statement-level edits: – delete X – replace X with Y – insert Y aqer X. • Replace/insert: pick Y from somewhere else in the program. • To mutate an individual, add new random edits to a given (possibly empty) patch. – (Where? Right: fault localizaYon!) 22 An individual is a candidate patch/set of changes to the input program.
  • 23. 23 printf(b) {block} while (b>0) {block} {block} {block} if(a==0) if(a>b) a = a – b {block} {block} printf(a) return b = b – a Input: An edit is: • Insert statement X aqer statement Y • Replace statement X with statement Y • Delete statement X
  • 24. 24 printf(b) {block} while (b>0) {block} {block} {block} if(a==0) if(a>b) a = a – b {block} {block} printf(a) return b = b – a Input: An edit is: • Insert statement X aOer statement Y • Replace statement X with statement Y • Delete statement X
  • 25. 25 printf(b) {block} while (b>0) {block} {block} {block} if(a==0) if(a>b) a = a – b {block} {block} printf(a) return b = b – a Input: An edit is: • Insert statement X aOer statement Y • Replace statement X with statement Y • Delete statement X
  • 26. 26 {block} while (b>0) {block} {block} {block} if(a==0) if(a>b) a = a – b {block} {block} printf(a) return b = b – a Input: An edit is: • Insert statement X aOer statement Y • Replace statement X with statement Y • Delete statement X return printf(b)
  • 27. What about Angelix? 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patch. 27 Same idea, but localizing to expressions. RHS of assignments, condiYonals.
  • 28. 1 int is_upward( int inhibit, int up_sep, int down_sep){ 2 int bias; 3 if (inhibit) 4 bias = down_sep; // bias= up_sep + 100 5 else bias = up_sep ; 6 if (bias > down_sep) 7 return 1; 8 else return 0; 9 } 28 Tremendous graYtude to Abhik Roychoudhury for sharing slides with me as starYng material for this talk.
  • 29. 1 int is_upward( int inhibit, int up_sep, int down_sep){ 2 int bias; 3 if (inhibit) 4 bias = down_sep; // bias= up_sep + 100 5 else bias = up_sep ; 6 if (bias > down_sep) 7 return 1; 8 else return 0; 9 } 29 inhibit up_sep down_sep Observed output Expected Output Result 1 0 100 0 0 pass 1 11 110 0 1 fail 0 100 50 1 1 pass 1 -20 60 0 1 fail 0 0 10 0 0 pass
  • 30. What about Angelix? 1. Localize the bug. – And possibly analyze it a liLle bit… 2. Create/combine fix possibiliYes into 1+ possible patches. 3. Validate candidate patch. 30 Concolic execu3on to find expression values that would make the test pass. Program synthesis to construct replacement code that produces those values.
  • 31. An expression’s angelic value is the value that would make a given test case pass. • This value is set “arbitrarily”, by which we mean symbolically. • You can solve for this value if you have: – the test case’s expected input/output. – the path condiYon controlling its execuYon. • Path condiYon: the set of condiYons that controlled a parYcular execuYon. – Start execuYng the test concretely, and then switch to symbolic execuYon when the angelic value starts to maLer. 31
  • 32. 1 int is_upward( int inhibit, int up_sep, int down_sep){ 2 int bias; 3 if (inhibit) 4 bias = down_sep; // bias= up_sep + 100 5 else bias = up_sep ; 6 if (bias > down_sep) 7 return 1; 8 else return 0; 9 } 32 inhibit up_sep down_sep Observed output Expected Output Result 1 0 100 0 0 pass 1 11 110 0 1 fail 0 100 50 1 1 pass 1 -20 60 0 1 fail 0 0 10 0 0 pass
  • 33. 1 int is_upward( int inhibit, int up_sep, int down_sep){ 2 int bias; 3 if (inhibit) 4 bias = ®; // bias= up_sep + 100 5 else bias = up_sep ; 6 if (bias > down_sep) 7 return 1; 8 else return 0; 9 } 33 inhibit up_sep down_sep Observed output Expected Output Result 1 11 110 0 1 fail inhibit = 1, up_sep = 11, down_sep = 110 bias = ®, PC = true Line 4 inhibit = 1, up_sep = 11, down_sep = 110 bias = ®, PC= ®> 110 Line 7 inhibit = 1, up_sep = 11, down_sep = 110 bias =®, PC= ® ≤ 110 Line 8
  • 34. What should it have been? 34 1 int is_upward( int inhibit, int up_sep, int down_sep){ 2 int bias; 3 if (inhibit) 4 ® = f(inhibit, up_sep, down_sep) 5 else bias = up_sep ; 6 if (bias > down_sep) 7 return 1; 8 else return 0; 9 } inhibit == 1 up_sep == 11 down_sep == 110 Symbolic ExecuYon f(1,11,110) > 110
  • 35. Collect all of the constraints! • Accumulated constraints over all test cases: • Use oracle guided component-based program synthesis to construct saYsfying f: – Fix a set of of operators (component-based). – Synthesize code that only uses those operators and saYsfies the constraints (oracle guided). • Generated fix – f(inhibit,up_sep,down_sep) = up_sep + 100 35 f(1,11,110) > 110 ∧ f(1,0,100) ≤ 100 ∧ f(1,-20,60) > 60
  • 36. (Legi'mately interes'ng encoding of synthesis problem elided for (dubious) brevity.) 36
  • 37. So why all that a_en'on paid to “forests”? 37 hLps://commons.wikimedia.org/wiki/File:Michael_Spiller_-_twisty_forest_paths_(by-sa).jpg
  • 39. Angelic Forest 39 E1 E2 E3 Program Angelic Paths SAT angelic1 angelic2 angelic3
  • 40. Angelic Forest 40 E1 E2 E3 Program Angelic Paths UNSAT angelic1 angelic2 angelic3
  • 41. Angelic Forest 41 E1 E2 E3 Program Angelic Paths SAT angelic1 angelic2 angelic3 angelic1 angelic3
  • 42. Angelic Forest 42 E1 E2 E3 Program Angelic Paths UNSAT angelic1 angelic2 angelic3 angelic1 angelic3
  • 43. Tradeoffs and Challenges 43 Scalability Expressive power Output quality hLps://www.flickr.com/photos/86530412@N02/7935377706 : hLps://pixabay.com/en/approved-control-quality-stamp-147677/ hLps://www.flickr.com/photos/cimmyt/5219256862
  • 44. Program Descrip'on LOC Bug Type Time 44 (s)
  • 45. Program Descrip'on LOC Bug Type Time gcd example 22 infinite loop 153 nullhLpd webserver 5575 heap buffer overflow (code) 578 zune example 28 infinite loop 42 uniq text processing 1146 segmentaYon fault 34 look-u dicYonary lookup 1169 segmentaYon fault 45 look-s dicYonary lookup 1363 infinite loop 55 units metric conversion 1504 segmentaYon fault 109 deroff document processing 2236 segmentaYon fault 131 indent code processing 9906 infinite loop 546 flex lexical analyzer generator 18774 segmentaYon fault 230 openldap directory protocol 292598 non-overflow denial of service 665 ccrypt encrypYon uYlity 7515 segmentaYon fault 330 lighLpd webserver 51895 heap buffer overflow (vars) 394 atris graphical game 21553 local stack buffer exploit 80 php scripYng language 764489 integer overflow 56 wu-qpd FTP server 67029 format string vulnerability 2256 leukocyte computaYonal biology 6718 segmentaYon fault 360 Yff image processing 84067 segmentaYon fault 108 imagemagick image processing 450516 wrong output 2160 (s) 45
  • 46. Program Descrip'on LOC Bug Type Time gcd example 22 infinite loop 153 nullhLpd webserver 5575 heap buffer overflow (code) 578 zune example 28 infinite loop 42 uniq text processing 1146 segmentaYon fault 34 look-u dicYonary lookup 1169 segmentaYon fault 45 look-s dicYonary lookup 1363 infinite loop 55 units metric conversion 1504 segmentaYon fault 109 deroff document processing 2236 segmentaYon fault 131 indent code processing 9906 infinite loop 546 flex lexical analyzer generator 18774 segmentaYon fault 230 openldap directory protocol 292598 non-overflow denial of service 665 ccrypt encrypYon uYlity 7515 segmentaYon fault 330 lighLpd webserver 51895 heap buffer overflow (vars) 394 atris graphical game 21553 local stack buffer exploit 80 php scripYng language 764489 integer overflow 56 wu-qpd FTP server 67029 format string vulnerability 2256 leukocyte computaYonal biology 6718 segmentaYon fault 360 Yff image processing 84067 segmentaYon fault 108 imagemagick image processing 450516 wrong output 2160 (s) 46
  • 47. Program Descrip'on LOC Bug Type Time gcd example 22 infinite loop 153 nullhLpd webserver 5575 heap buffer overflow (code) 578 zune example 28 infinite loop 42 uniq text processing 1146 segmentaYon fault 34 look-u dicYonary lookup 1169 segmentaYon fault 45 look-s dicYonary lookup 1363 infinite loop 55 units metric conversion 1504 segmentaYon fault 109 deroff document processing 2236 segmentaYon fault 131 indent code processing 9906 infinite loop 546 flex lexical analyzer generator 18774 segmentaYon fault 230 openldap directory protocol 292598 non-overflow denial of service 665 ccrypt encrypYon uYlity 7515 segmentaYon fault 330 lighLpd webserver 51895 heap buffer overflow (vars) 394 atris graphical game 21553 local stack buffer exploit 80 php scripYng language 764489 integer overflow 56 wu-qpd FTP server 67029 format string vulnerability 2256 leukocyte computaYonal biology 6718 segmentaYon fault 360 Yff image processing 84067 segmentaYon fault 108 imagemagick image processing 450516 wrong output 2160 (s) 47
  • 48. Program Descrip'on LOC Bug Type Time gcd example 22 infinite loop 153 nullhLpd webserver 5575 heap buffer overflow (code) 578 zune example 28 infinite loop 42 uniq text processing 1146 segmentaYon fault 34 look-u dicYonary lookup 1169 segmentaYon fault 45 look-s dicYonary lookup 1363 infinite loop 55 units metric conversion 1504 segmentaYon fault 109 deroff document processing 2236 segmentaYon fault 131 indent code processing 9906 infinite loop 546 flex lexical analyzer generator 18774 segmentaYon fault 230 openldap directory protocol 292598 non-overflow denial of service 665 ccrypt encrypYon uYlity 7515 segmentaYon fault 330 lighLpd webserver 51895 heap buffer overflow (vars) 394 atris graphical game 21553 local stack buffer exploit 80 php scripYng language 764489 integer overflow 56 wu-qpd FTP server 67029 format string vulnerability 2256 leukocyte computaYonal biology 6718 segmentaYon fault 360 Yff image processing 84067 segmentaYon fault 108 imagemagick image processing 450516 wrong output 2160 (s) 48
  • 49. “IF I GAVE YOU THE LAST 100 BUGS FROM <MY PROJECT>, HOW MANY COULD GENPROG ACTUALLY FIX?” – MANY PEOPLE 49
  • 50. • Goal: a large set of important, reproducible bugs in non-trivial programs. • Approach: use historical data (source control!) to approximate discovery and repair of bugs in the wild. Challenge: Indica've Bug Set 50
  • 51. Success/Cost Program Defects Repaired Cost per non-repair Cost per repair Hours US$ Hours US$ |c 1/3 8.52 5.56 6.52 4.08 gmp 1/2 9.93 6.61 1.60 0.44 gzip 1/5 5.11 3.04 1.41 0.30 libYff 17/24 7.81 5.04 1.05 0.04 lighLpd 5/9 10.79 7.25 1.34 0.25 php 28/44 13.00 8.80 1.84 0.62 python 1/11 13.00 8.80 1.22 0.16 wireshark 1/7 13.00 8.80 1.23 0.17 Total 55/105 11.22h 1.60h • $403 for all 105 trials, leading to 55 repairs; $7.32 per bug repaired. 51
  • 53. Heartbleed patch 53 if (hbtype == TLS1_HB_REQUEST && (payload + 18) < s->s3->rrec.length) { … } else if (hbtype == TLS1_HB_RESPONSE) { … } return 0; Generated patch if (1 + 2 + payload + 16 > s->s3->rrec.length) return 0; … if (hbtype == TLS1_HB_REQUEST) { … } else if (hbtype == TLS1_HB_RESPONSE) { … } return 0; Developer patch
  • 55. Flashback to 2008… “delete handling of POST requests” 55 ß nullhLpd: a webserver with basic GET + POST funcYonality. Version 0.5.0: remote-exploitable heap-based buffer overflow in handling of POST. Failing test case: run exploit, see if webserver is sYll running Easy passing test cases: 1. “GET index.html” 2. “GET image.jpg” 3. “GET nodound.html” + = CC0 Public Domain
  • 56. When we added a non-crashing test case for POST, proto-GenProg found a much be_er patch. • When the test suite is your objecYve funcYon, test suite quality maLers. –…how much is a trickier issue. • But we’re begging the quesYon... 56 hLps://en.wikipedia.org/wiki/Basket-hilted_sword#/media/File:Schiavona-Morges.jpg
  • 58. When we added a non-crashing test case for POST, proto-GenProg found a much be_er patch. • When the test suite is your objecYve funcYon, test suite quality maLers. –…how much is a trickier issue. • But we’re begging the quesYon... 58 hLps://en.wikipedia.org/wiki/Basket-hilted_sword#/media/File:Schiavona-Morges.jpg
  • 59. What is a high quality patch, anyway? • Understandable? – Well, I had no problem understanding the POST-deleYng patch… – (non-funcYonal properYes are important and being studied by others!) • Doesn’t delete? – But what about goto fail? • Does the same thing the human did/would do? – But humans are oqen wrong! And how close does it have to be? • Doesn’t introduce new bugs? – How to tell? • Addresses the cause, not the symptom… 59
  • 60. Proposal: measure quality based on degree to which results generalize. • In machine learning, techniques are trained and evaluated on disjoint datasets to assess overfi‚ng. • In program repair: –Tests used to build a repair are training tests –Tests used to assess correctness are evalua3on tests 60
  • 61. PROBLEM: THE DESIRED STUDY IS IMPOSSIBLE. 61
  • 62. [Dataset + Tools] • Student homework submissions from six UC Davis IntroducYon to Programming assignments • Two full-coverage test suites: – White-box suite generated by Klee from reference implementaYon. – Black-box suite wriLen by course instructor. – Feature: Assess patch quality as dis3nct from test suite quality. • Goal: Compare GenProg and TrpAutoRepair/ RSRepair, G&V techniques with different search strategies. 62 Full dataset available at repairbenchmarks.cs.umass.edu
  • 63. Both tools produced patches that overfit to the training set. 63
  • 64. But: the tools do as well as the students! 64
  • 65. Overfivng is not unique toheuris'c techniques. • Angelix: 120/233 of patches produced on a subset to IntroClass overfit. • ~40% of SPR patches studied in Angelix paper delete funcYonality by generaYng tautological if condiYons. 65
  • 66. Overfivng is not unique toheuris'c techniques. • Angelix: 120/233 of patches produced on a subset to IntroClass overfit. • ~40% of SPR patches studied in Angelix paper delete funcYonality by generaYng tautological if condiYons. 66 PhD students observe that much of the problem is in the synthesis of overly constrained if condiYons.
  • 67. Quality Comparison with SPR 67 25% 30% 0% 0% 20% 25% 39% 50% 0% 80% WIRESHARK PHP GZIP GMP LIBTIFF FUNCTIONALITY-DELETING REPAIRS Angelix SPR
  • 68. 68
  • 69. OPTION 1: UNDERSTAND AND REASON ABOUT THE CIRCUMSTANCES UNDER WHICH PERFECTION IS NOT REQUIRED. Context maLers! 69
  • 70. 70 2012 flashback… ß Scenario: Long-running servers + IDS + generate repairs for detected anomalies. ß Workloads: a day of unfiltered requests to the UVA CS webserver. THIS PATCH WAS BAD
  • 71. Even a func'onality-reducing repair had li_le prac'cal impact. Program Post-patch requests lost Fuzz Tests Failed General Exploit nullhLpd 0.00 % ± 0.25% 0 à 0 10 à 0 lighLpd 0.03% ± 1.53% 1410 à 1410 9 à 0 php-BAD 0.02% ± 0.02% 3 à 3 5 à 0 71
  • 72. OPTION 2: DEVELOP TECHNIQUES THAT ARE MORE LIKELY TO GENERALIZE. How? 72
  • 73. Challenge your assump'ons! 73 EXAMPLE ASSUMPTION: bug-fixing patches are like kittens: smaller is better! "Retouched KiLy" by Ozan Kilic, CC2.0 hLp://www.freestockphotos.biz/stockphoto/9343
  • 74. • Instead of trying to make small changes, we replaced buggy regions with code that correctly captures the overall desired logic? • Principle: using human-wriLen code to fix code at a higher granularity level leads to beLer quality repairs. • What if… 74
  • 76. Seman'c code search looks for code based on what it should do. • Keyword: “C median three numbers” • SemanYc: Input Expected 2,6,8 6 2,8,6 6 6,2,8 6 6,8,2 6 8,6,2 6 9,9,9 9 76 …Generate and validate + SemanYc reasoning!
  • 77. SearchRepair patches were of much higher quality than those produced by previous techniques. 77 Technique Held out tests passed SearchRepair 97.2% GenProg 68.7% TRPAP 72.1% AE 64.2%
  • 78. 78
  • 80. 80 80 inhibit = 1, up_sep = 11, down_sep = 110 bias = ®, PC = true Line 4 inhibit = 1, up_sep = 11, down_sep = 110 bias = ®, PC= ®> 110 Line 7 inhibit = 1, up_sep = 11, down_sep = 110 bias =®, PC= ® ≤ 110 Line 8
  • 82. 82 AE: 1 SearchRepair: 20 GenProg: 32 52 0 0 68 RSRepair: 2 10 90 0 0 0 GenProg total: 287 AE total: 159 RSRepair total: 247 SearchRepair total: 150