SlideShare a Scribd company logo
1 of 21
Abhik Roychoudhury, National University of Singapore
Satish Chandra, Google
PROGRAM REPAIR
& AUTO-CODING
Talk for ICSE 2023 10-year
Most Influential Paper Award
ICSE2023 MIP Award Talk
Hoang Duong Thien Nguyen, Dawei Qi, Abhik Roychoudhury
School of Computing, National University of Singapore, Singapore
Satish Chandra
IBM Research, USA
01
SemFix: ICSE 2013
In this paper, we present an automated repair method based on symbolic
execution, constraint solving and program synthesis.
Education Correctness Security
Program
Repair
Buggy Program
Tests
Patched
Program
02
ICSE2023 MIP Award Talk
PROGRAM REPAIR
Baseline
Codebase
Initial
Req
Modified
Codebase
CS1010S, ...
First-year programming
Intelligent Tutoring
System
Augmented
Req
THE DEBUGGING PROBLEM
05
ICSE2023 MIP Award Talk
RETROSPECTIVE: DEBUGGING
Source of specifications:
Previous version
Another implementation,
Tests … ?
Dagstuhl Seminar 13061
Fault Prediction, Localization, and Repair, Feb 2013
Repair exploiting symbolic execution
• Scalability with respect to search space size.
Repair via constraint solving
• Synthesize rather than lifting fixes from elsewhere.
Repair without formal specifications
• Do not depend on any being available.
From https://www.dagstuhl.de/13061
07
ICSE2023 MIP Award Talk
SPEC from TESTS
Test ID a b c oracle Pass
1 -1 -1 -1 INVALID
2 1 1 1 EQUILATERAL
3 2 2 3 ISOSCELES
4 2 3 2 ISOSCELES
5 3 2 2 ISOSCELES
6 2 3 4 SCALANE
1 int triangle(int a, int b, int c){
2 if (a <= 0 || b <= 0 || c <= 0)
3. return INVALID;
4. if (a == b && b == c)
5. return EQUILATERAL;
6. if (a == b || b != c) // bug !
7. return ISOSCELES;
8. return SCALENE;
9. }
08
Correct fix
(a == b || b== c || a == c)
ICSE2023 MIP Award Talk
EXAMPLE
Accumulated constraints
f (2,2,3) == true ^
f (2,3,2) == true ^
…
Find a f satisfying this constraint
By fixing the set of operators appearing in f
Program synthesis with fixed set of operators
1 int triangle (int a, int b, int c) {
if (a <= 0 || b <= 0 ||
c<=0) return INVALID;
if (a == b && b == c)
return EQUILATERAL;
if (f (a, b,c))
return ISOSCELES;
return SCALENE;
2
3
4
5
6
7
8
9 }
a==2
7
b==2 c==3
f (2,2,3) = true
Symbolic Execution
ICSE2023 MIP Award Talk
SPEC. from TESTS
Automatically generate the constraint
f (2,2,3) ^ f (2,3,2) ^ f (3,2,2) ^ ¬ f (2,3,4)
Solution
f(a,b,c) = (a == b || b == c || a == c)
“Program testing and program proving can
be considered as extreme alternatives.….
This paper describes a practical approach
between these two extremes…
Each symbolic execution result may be equivalent
to a large number of normal tests”
TESTING/
VERIFICATION
...
8
ICSE2023 MIP Award Talk
SYMBOLIC EXECUTION (1976)
Specification Inference
In the absence of formal specifications,
analyze the buggy program and its
artifacts such as execution traces via
various heuristics to glean a
specification about how it can pass tests
and what could have gone wrong!
1 int triangle (int a, int b, int c) {
if (a <= 0 || b <= 0 ||
c<=0) return INVALID;
if (a == b && b == c)
return EQUILATERAL;
if (f (a, b,c)) // X
return ISOSCELES;
return SCALENE;
2
3
4
5
6
7
8
9 }
a==2 b==2 c==3
X = true
Symbolic Execution
9
ICSE2023 MIP Award Talk
SE for REPAIR
a <=0 || b <= 0 || c <= 0
Yes
Yes
Yes
No
No
No
a == b && b == c
1, 1, 1
1,1,2
a == b || b != c
2,3,4
10
ICSE2023 MIP Award Talk
SE for TESTING
1 int triangle (int a, int b, int c) {
if (a <= 0 || b <= 0 ||
c<=0) return INVALID;
if (a == b && b == c)
return EQUILATERAL;
if (a == b || b != c)
return ISOSCELES;
return SCALINE;
2
3
4
5
6
7
8
9 }
-1, -1, -1
11
ICSE2023 MIP Award Talk
REPAIR / TESTING a <=0 || b <= 0 || c <= 0
Yes
Yes
Yes
No
No
No
a == b && b == c
1, 1, 1
1,1,2
a == b || b != c
2,3,4
-1, -1, -1
1 int triangle (int a, int b, int c) {
if (a <= 0 || b <= 0 ||
c<=0) return INVALID;
if (a == b && b == c)
return EQUILATERAL;
if (f (a, b,c)) // X
return ISOSCELES;
return SCALINE;
2
3
4
5
6
7
8
9 }
a==2 b==2 c==3
X= true / X = f(2,2,3)
Symbolic Execution
SemFix paper
comes here
Passing &
failing tests
Extract
constraints
Learning/
Inference
Generate patch
candidates
Fault localization
Semantic
Repair
Learning-based
Repair
Search-based
Repair
Synthesize code via
constraint solving Predict patch
Validate patch
candidates
Model of patches
03
Patch
Code
transformations
Buggy Program Code corpus
SUMMARY
for t in Tests {
generate repair constraint
}
Synthesize e from
t
t t
Semantics-based Schematic
A BRIEF HISTORY OF 2013-2023
ML makes significant inroads into software tools
• code completion
• code search and recommendation
• troubleshooting
• test selection
• …
• and of course, automated program repair!
From research to mainstream in less than 10 years
A new era of
software tools
ICSE2023 MIP Award Talk
Large code repositories
aka “big code”
Huge progress in ML
esp. in deep learning
ML COMES TO
AUTOMATED PROGRAM REPAIR
Immense amount of code change data available on past fixes
• Sometimes even aligned with bug symptom
ML problem
• Given a potentially buggy code fragment, predict an edit
Software tool problem
• Localize the error [as before]
• Predict an edit [ML problem]
• Validate that the edited code works [as before]
ICSE2023 MIP Award Talk
Passing &
failing tests
Learning/
Inference
Fault localization
Learning-based
Repair
Predict patch
Model of repair
Patch
Buggy Program Code corpus
Code
transformations
GETAFIX (META, 2019)
ICSE2023 MIP Award Talk
+10
+2 +35
-10 -1
-7
+1
-1
42294d 5cdd7c 1ee3fc 181d81 1d89b2 f54c2d
public int getWidth() {
@Nullable View v = this.getView();
- return v.getWidth();
+ return v != null ? v.getWidth() : 0;
}
Bader et al, Learning to fix bugs automatically, OOPSLA 2019
x == null
? x.foo()
: default
x.foo() y == null
? y.bar()
: default
y.bar()
α == null
? α.β()
: default
α.β()
Pattern discovery by anti-unification
Pattern application by probabilistic calculation
GETAFIX (META, 2019)
ICSE2023 MIP Award Talk
Developers are picky about their code – semantic equivalence is
not enough
Emphasis on ranking and picking the most likely pattern – no
budget to compile multiple fixes
Convenient UI integration is important
Where ML has helped?
Generalization in fix patterns
Productive in static analysis errors,
build errors etc.
(somewhat narrow domain, spec is
easier)
CHALLENGES IN APR
ICSE2023 MIP Award Talk
Continued challenges
Patch accuracy: tests may not
capture the full spec
Localization continues to be a
challenge
Private
Code
GitHub Copilot
Service
OpenAI GPT-4 Model GitHu
b
Public code and
text on the
internet
Provide Editor context
Improve Suggestions
04
Provide Suggestions
ICSE2023 MIP Award Talk
PROSPECTIVE: 2022-23
Modern LLMs trained on large code corpora have shown surprising capabilities (beyond code completion) out-of-the-
box, and many more accessible with few-shot prompting. The impact of these capabilities is significant on research
and on the profession.
PROGRAM REPAIR IN THE ERA OF ML-
GENERATED CODE
1. ML-generated code does not mean bugs will not appear. In production,
new unforeseen/untested conditions might occur. The need for fixing
failures is going to be there.
2. Models will improve to be more predictable as well as to avoid the more
routine kind of bugs.
3. Prompts used in code generation might themselves become the entity of
record, in which case the notion of "repair" might be applicable to prompts
too.
4. The question will remain on when ML-generated code can be
“trusted” enough to be integrated as part of your SW project!
20
Steering Search Specification Inference
GRADUAL CORRECTNESS
ICSE2023 MIP Award Talk
"EVIDENCE" from REPAIR
Automated Repair of Programs from Large Language Models, ICSE23.
Trustworthy Software
21
TRUSTED AUTOMATED PROGRAMMING
Repair techniques on code from LLMs
Evidence generation via repair
ICSE2023 MIP Award Talk

More Related Content

What's hot

Whitebox testing
Whitebox testingWhitebox testing
Whitebox testing
Oana Feidi
 
Istqb question-paper-dump-4
Istqb question-paper-dump-4Istqb question-paper-dump-4
Istqb question-paper-dump-4
TestingGeeks
 

What's hot (10)

Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
An Implementation of Preregistration
An Implementation of PreregistrationAn Implementation of Preregistration
An Implementation of Preregistration
 
Regression testing
Regression testingRegression testing
Regression testing
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Shift left - find defects earlier through automated test and deployment
Shift left - find defects earlier through automated test and deploymentShift left - find defects earlier through automated test and deployment
Shift left - find defects earlier through automated test and deployment
 
Mutation Testing
Mutation TestingMutation Testing
Mutation Testing
 
Whitebox testing
Whitebox testingWhitebox testing
Whitebox testing
 
The Test Pyramid
The Test PyramidThe Test Pyramid
The Test Pyramid
 
Istqb question-paper-dump-4
Istqb question-paper-dump-4Istqb question-paper-dump-4
Istqb question-paper-dump-4
 

Similar to 16May_ICSE_MIP_APR_2023.pptx

Final Exam Questions Fall03
Final Exam Questions Fall03Final Exam Questions Fall03
Final Exam Questions Fall03
Radu_Negulescu
 
Continuous test suite failure prediction
Continuous test suite failure predictionContinuous test suite failure prediction
Continuous test suite failure prediction
ssuser94f898
 
Final Exam Solutions Fall02
Final Exam Solutions Fall02Final Exam Solutions Fall02
Final Exam Solutions Fall02
Radu_Negulescu
 
Cross-Project Build Co-change Prediction
Cross-Project Build Co-change PredictionCross-Project Build Co-change Prediction
Cross-Project Build Co-change Prediction
Shane McIntosh
 
Testing survey by_directions
Testing survey by_directionsTesting survey by_directions
Testing survey by_directions
Tao He
 

Similar to 16May_ICSE_MIP_APR_2023.pptx (20)

APSEC2020 Keynote
APSEC2020 KeynoteAPSEC2020 Keynote
APSEC2020 Keynote
 
Automated Program Repair, Distinguished lecture at MPI-SWS
Automated Program Repair, Distinguished lecture at MPI-SWSAutomated Program Repair, Distinguished lecture at MPI-SWS
Automated Program Repair, Distinguished lecture at MPI-SWS
 
Repair dagstuhl jan2017
Repair dagstuhl jan2017Repair dagstuhl jan2017
Repair dagstuhl jan2017
 
Automated Program Repair Keynote talk
Automated Program Repair Keynote talkAutomated Program Repair Keynote talk
Automated Program Repair Keynote talk
 
Final Exam Questions Fall03
Final Exam Questions Fall03Final Exam Questions Fall03
Final Exam Questions Fall03
 
Constraint Programming - An Alternative Approach to Heuristics in Scheduling
Constraint Programming - An Alternative Approach to Heuristics in SchedulingConstraint Programming - An Alternative Approach to Heuristics in Scheduling
Constraint Programming - An Alternative Approach to Heuristics in Scheduling
 
Continuous test suite failure prediction
Continuous test suite failure predictionContinuous test suite failure prediction
Continuous test suite failure prediction
 
Thesis+of+étienne+duclos.ppt
Thesis+of+étienne+duclos.pptThesis+of+étienne+duclos.ppt
Thesis+of+étienne+duclos.ppt
 
Impact of Coding Style Checker on Code Review -A case study on the OpenStack ...
Impact of Coding Style Checker on Code Review -A case study on the OpenStack ...Impact of Coding Style Checker on Code Review -A case study on the OpenStack ...
Impact of Coding Style Checker on Code Review -A case study on the OpenStack ...
 
Final Exam Solutions Fall02
Final Exam Solutions Fall02Final Exam Solutions Fall02
Final Exam Solutions Fall02
 
Planning/Scheduling with CP Optimizer
Planning/Scheduling with CP OptimizerPlanning/Scheduling with CP Optimizer
Planning/Scheduling with CP Optimizer
 
CV - Rajat Gupta
CV - Rajat GuptaCV - Rajat Gupta
CV - Rajat Gupta
 
Vision Algorithmics
Vision AlgorithmicsVision Algorithmics
Vision Algorithmics
 
Multi-Objective Cross-Project Defect Prediction
Multi-Objective Cross-Project Defect PredictionMulti-Objective Cross-Project Defect Prediction
Multi-Objective Cross-Project Defect Prediction
 
STAR: Stack Trace based Automatic Crash Reproduction
STAR: Stack Trace based Automatic Crash ReproductionSTAR: Stack Trace based Automatic Crash Reproduction
STAR: Stack Trace based Automatic Crash Reproduction
 
Cross-Project Build Co-change Prediction
Cross-Project Build Co-change PredictionCross-Project Build Co-change Prediction
Cross-Project Build Co-change Prediction
 
Testing survey by_directions
Testing survey by_directionsTesting survey by_directions
Testing survey by_directions
 
Reengineering and Reuse of Legacy Software
Reengineering and Reuse of Legacy SoftwareReengineering and Reuse of Legacy Software
Reengineering and Reuse of Legacy Software
 
22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf22316-2019-Summer-model-answer-paper.pdf
22316-2019-Summer-model-answer-paper.pdf
 
The relationship between test and production code quality (@ SIG)
The relationship between test and production code quality (@ SIG)The relationship between test and production code quality (@ SIG)
The relationship between test and production code quality (@ SIG)
 

More from Abhik Roychoudhury

More from Abhik Roychoudhury (16)

IFIP2023-Abhik.pptx
IFIP2023-Abhik.pptxIFIP2023-Abhik.pptx
IFIP2023-Abhik.pptx
 
Fuzzing.pptx
Fuzzing.pptxFuzzing.pptx
Fuzzing.pptx
 
Dagstuhl2021
Dagstuhl2021Dagstuhl2021
Dagstuhl2021
 
Singapore International Cyberweek 2020
Singapore International Cyberweek 2020Singapore International Cyberweek 2020
Singapore International Cyberweek 2020
 
NUS PhD e-open day 2020
NUS PhD e-open day 2020NUS PhD e-open day 2020
NUS PhD e-open day 2020
 
Art of Computer Science Research Planning
Art of Computer Science Research PlanningArt of Computer Science Research Planning
Art of Computer Science Research Planning
 
Automated Repair - ISSTA Summer School
Automated Repair - ISSTA Summer SchoolAutomated Repair - ISSTA Summer School
Automated Repair - ISSTA Summer School
 
Isorc18 keynote
Isorc18 keynoteIsorc18 keynote
Isorc18 keynote
 
Symbexecsearch
SymbexecsearchSymbexecsearch
Symbexecsearch
 
Mobilesoft 2017 Keynote
Mobilesoft 2017 KeynoteMobilesoft 2017 Keynote
Mobilesoft 2017 Keynote
 
Binary Analysis - Luxembourg
Binary Analysis - LuxembourgBinary Analysis - Luxembourg
Binary Analysis - Luxembourg
 
Abhik-Satish-dagstuhl
Abhik-Satish-dagstuhlAbhik-Satish-dagstuhl
Abhik-Satish-dagstuhl
 
Issta13 workshop on debugging
Issta13 workshop on debuggingIssta13 workshop on debugging
Issta13 workshop on debugging
 
Repair dagstuhl
Repair dagstuhlRepair dagstuhl
Repair dagstuhl
 
PAS 2012
PAS 2012PAS 2012
PAS 2012
 
Pas oct12
Pas oct12Pas oct12
Pas oct12
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptxHVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
HVAC System | Audit of HVAC System | Audit and regulatory Comploance.pptx
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
The Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptxThe Ball Poem- John Berryman_20240518_001617_0000.pptx
The Ball Poem- John Berryman_20240518_001617_0000.pptx
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 

16May_ICSE_MIP_APR_2023.pptx

  • 1. Abhik Roychoudhury, National University of Singapore Satish Chandra, Google PROGRAM REPAIR & AUTO-CODING Talk for ICSE 2023 10-year Most Influential Paper Award
  • 2. ICSE2023 MIP Award Talk Hoang Duong Thien Nguyen, Dawei Qi, Abhik Roychoudhury School of Computing, National University of Singapore, Singapore Satish Chandra IBM Research, USA 01 SemFix: ICSE 2013 In this paper, we present an automated repair method based on symbolic execution, constraint solving and program synthesis.
  • 3. Education Correctness Security Program Repair Buggy Program Tests Patched Program 02 ICSE2023 MIP Award Talk PROGRAM REPAIR Baseline Codebase Initial Req Modified Codebase CS1010S, ... First-year programming Intelligent Tutoring System Augmented Req
  • 4. THE DEBUGGING PROBLEM 05 ICSE2023 MIP Award Talk RETROSPECTIVE: DEBUGGING Source of specifications: Previous version Another implementation, Tests … ?
  • 5. Dagstuhl Seminar 13061 Fault Prediction, Localization, and Repair, Feb 2013 Repair exploiting symbolic execution • Scalability with respect to search space size. Repair via constraint solving • Synthesize rather than lifting fixes from elsewhere. Repair without formal specifications • Do not depend on any being available. From https://www.dagstuhl.de/13061 07 ICSE2023 MIP Award Talk SPEC from TESTS
  • 6. Test ID a b c oracle Pass 1 -1 -1 -1 INVALID 2 1 1 1 EQUILATERAL 3 2 2 3 ISOSCELES 4 2 3 2 ISOSCELES 5 3 2 2 ISOSCELES 6 2 3 4 SCALANE 1 int triangle(int a, int b, int c){ 2 if (a <= 0 || b <= 0 || c <= 0) 3. return INVALID; 4. if (a == b && b == c) 5. return EQUILATERAL; 6. if (a == b || b != c) // bug ! 7. return ISOSCELES; 8. return SCALENE; 9. } 08 Correct fix (a == b || b== c || a == c) ICSE2023 MIP Award Talk EXAMPLE
  • 7. Accumulated constraints f (2,2,3) == true ^ f (2,3,2) == true ^ … Find a f satisfying this constraint By fixing the set of operators appearing in f Program synthesis with fixed set of operators 1 int triangle (int a, int b, int c) { if (a <= 0 || b <= 0 || c<=0) return INVALID; if (a == b && b == c) return EQUILATERAL; if (f (a, b,c)) return ISOSCELES; return SCALENE; 2 3 4 5 6 7 8 9 } a==2 7 b==2 c==3 f (2,2,3) = true Symbolic Execution ICSE2023 MIP Award Talk SPEC. from TESTS Automatically generate the constraint f (2,2,3) ^ f (2,3,2) ^ f (3,2,2) ^ ¬ f (2,3,4) Solution f(a,b,c) = (a == b || b == c || a == c)
  • 8. “Program testing and program proving can be considered as extreme alternatives.…. This paper describes a practical approach between these two extremes… Each symbolic execution result may be equivalent to a large number of normal tests” TESTING/ VERIFICATION ... 8 ICSE2023 MIP Award Talk SYMBOLIC EXECUTION (1976)
  • 9. Specification Inference In the absence of formal specifications, analyze the buggy program and its artifacts such as execution traces via various heuristics to glean a specification about how it can pass tests and what could have gone wrong! 1 int triangle (int a, int b, int c) { if (a <= 0 || b <= 0 || c<=0) return INVALID; if (a == b && b == c) return EQUILATERAL; if (f (a, b,c)) // X return ISOSCELES; return SCALENE; 2 3 4 5 6 7 8 9 } a==2 b==2 c==3 X = true Symbolic Execution 9 ICSE2023 MIP Award Talk SE for REPAIR
  • 10. a <=0 || b <= 0 || c <= 0 Yes Yes Yes No No No a == b && b == c 1, 1, 1 1,1,2 a == b || b != c 2,3,4 10 ICSE2023 MIP Award Talk SE for TESTING 1 int triangle (int a, int b, int c) { if (a <= 0 || b <= 0 || c<=0) return INVALID; if (a == b && b == c) return EQUILATERAL; if (a == b || b != c) return ISOSCELES; return SCALINE; 2 3 4 5 6 7 8 9 } -1, -1, -1
  • 11. 11 ICSE2023 MIP Award Talk REPAIR / TESTING a <=0 || b <= 0 || c <= 0 Yes Yes Yes No No No a == b && b == c 1, 1, 1 1,1,2 a == b || b != c 2,3,4 -1, -1, -1 1 int triangle (int a, int b, int c) { if (a <= 0 || b <= 0 || c<=0) return INVALID; if (a == b && b == c) return EQUILATERAL; if (f (a, b,c)) // X return ISOSCELES; return SCALINE; 2 3 4 5 6 7 8 9 } a==2 b==2 c==3 X= true / X = f(2,2,3) Symbolic Execution
  • 12. SemFix paper comes here Passing & failing tests Extract constraints Learning/ Inference Generate patch candidates Fault localization Semantic Repair Learning-based Repair Search-based Repair Synthesize code via constraint solving Predict patch Validate patch candidates Model of patches 03 Patch Code transformations Buggy Program Code corpus SUMMARY for t in Tests { generate repair constraint } Synthesize e from t t t Semantics-based Schematic
  • 13. A BRIEF HISTORY OF 2013-2023 ML makes significant inroads into software tools • code completion • code search and recommendation • troubleshooting • test selection • … • and of course, automated program repair! From research to mainstream in less than 10 years A new era of software tools ICSE2023 MIP Award Talk Large code repositories aka “big code” Huge progress in ML esp. in deep learning
  • 14. ML COMES TO AUTOMATED PROGRAM REPAIR Immense amount of code change data available on past fixes • Sometimes even aligned with bug symptom ML problem • Given a potentially buggy code fragment, predict an edit Software tool problem • Localize the error [as before] • Predict an edit [ML problem] • Validate that the edited code works [as before] ICSE2023 MIP Award Talk Passing & failing tests Learning/ Inference Fault localization Learning-based Repair Predict patch Model of repair Patch Buggy Program Code corpus Code transformations
  • 15. GETAFIX (META, 2019) ICSE2023 MIP Award Talk +10 +2 +35 -10 -1 -7 +1 -1 42294d 5cdd7c 1ee3fc 181d81 1d89b2 f54c2d public int getWidth() { @Nullable View v = this.getView(); - return v.getWidth(); + return v != null ? v.getWidth() : 0; } Bader et al, Learning to fix bugs automatically, OOPSLA 2019 x == null ? x.foo() : default x.foo() y == null ? y.bar() : default y.bar() α == null ? α.β() : default α.β() Pattern discovery by anti-unification Pattern application by probabilistic calculation
  • 16. GETAFIX (META, 2019) ICSE2023 MIP Award Talk Developers are picky about their code – semantic equivalence is not enough Emphasis on ranking and picking the most likely pattern – no budget to compile multiple fixes Convenient UI integration is important
  • 17. Where ML has helped? Generalization in fix patterns Productive in static analysis errors, build errors etc. (somewhat narrow domain, spec is easier) CHALLENGES IN APR ICSE2023 MIP Award Talk Continued challenges Patch accuracy: tests may not capture the full spec Localization continues to be a challenge
  • 18. Private Code GitHub Copilot Service OpenAI GPT-4 Model GitHu b Public code and text on the internet Provide Editor context Improve Suggestions 04 Provide Suggestions ICSE2023 MIP Award Talk PROSPECTIVE: 2022-23 Modern LLMs trained on large code corpora have shown surprising capabilities (beyond code completion) out-of-the- box, and many more accessible with few-shot prompting. The impact of these capabilities is significant on research and on the profession.
  • 19. PROGRAM REPAIR IN THE ERA OF ML- GENERATED CODE 1. ML-generated code does not mean bugs will not appear. In production, new unforeseen/untested conditions might occur. The need for fixing failures is going to be there. 2. Models will improve to be more predictable as well as to avoid the more routine kind of bugs. 3. Prompts used in code generation might themselves become the entity of record, in which case the notion of "repair" might be applicable to prompts too. 4. The question will remain on when ML-generated code can be “trusted” enough to be integrated as part of your SW project!
  • 20. 20 Steering Search Specification Inference GRADUAL CORRECTNESS ICSE2023 MIP Award Talk "EVIDENCE" from REPAIR Automated Repair of Programs from Large Language Models, ICSE23.
  • 21. Trustworthy Software 21 TRUSTED AUTOMATED PROGRAMMING Repair techniques on code from LLMs Evidence generation via repair ICSE2023 MIP Award Talk