SemFix: Program Repair via Semantic...

29
SemFix: Program Repair via Semantic Analysis Ye Wang, PhD student Department of Computer Science Virginia Tech

Transcript of SemFix: Program Repair via Semantic...

Page 1: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

SemFix:ProgramRepairviaSemanticAnalysis

YeWang,PhDstudentDepartmentofComputerScience

VirginiaTech

Page 2: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

ProblemStatement

• Debuggingtakesmuchtimeandeffort• Evenafterrootcauseofabugisidentified,fixingbugisnon-trivial• Problemsolvedbythispaperishowtoautomaticallyrepairbugs

Page 3: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Example

Tobefixed

Constraint

3 usablevariablesatline4:inhibit,up_sep,down_sep

letbias=f(inhibit,up_sep,down_sep)sothatbias>down_sep canpasstests

Synthesizef(1)tryaconstant:cannotsatisfyconstraint

(2)trytouse"+",{v1+c,v1+v2}:f=up_sep +100

Page 4: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Background

• Statisticalfaultlocalization• Localizeroot-causeofprogramfailurebyexploitingthecorrelationbetweenexecutionoffaultystatementsandprogramfailure

• Component-basedprogramsynthesis• Generateaprogramthatsatisfiesallthegiveninput-outputpairs.

Page 5: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Onlygeneratearepairbyalteringonestatement.Thegeneratedfixisalwayswithrespecttoagiventestsuite.• Generaterepairconstraint• Generateafix

Page 6: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Generaterepairconstraint• Thepaperfocusesonrepairschangingtherightsideofassignmentsorbranchpredicates

• Nosideeffect:f(…)donotmodifyanyprogramvariable

• RepairconstraintCisaconjunctionofconstraintsderivedfromT.Foreachtestti,thereisaconstraintCi,

Page 7: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Generaterepairconstraint• EachCi isapredicateoverthefunctionf• TogenerateCi,thepaperusessymbolicexecutioninanovelfashion.• Traditionalsymbolicexecutiontakesallinputvariablesassymbolic,whilethepaper'ssymbolicexecutionstartswithaconcreteinput.• Executetheprogramconcretelywithinputti tostatements.Denotetheprogramstatebeforeexecutingstatementsas𝜉".Thensettheresultoffunctionf(…)assymbolicandcontinuesymbolicexecutionfromstatements.

Page 8: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Generaterepairconstraint• 𝜏":symbolicvalueassignedtoresultoffunctionf(…)• Symbolicexecutionexploresmpaths.• Foreachpath𝜋%,𝑝𝑐% istheassociatedpathcondition,and𝑂% isthesymbolicexpressionofoutput• 𝑂 𝑡" istheexpectedoutputofprogramPwithinput𝑡"• Constraint:

• FirstpartmeansatleastonefeasiblepathalongwhichoutputofprogramPisthesameastheexpectedoutput.• Secondpartbuildsupinput-outputrelationshipoffunctionf

Page 9: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Generaterepairconstraint

𝑋 > 110 ∧ 1 = 1 ∨ 𝑋 ≤ 110 ∧ 1 = 0canbesimplified to𝑋 > 110

𝑓 1,11,110 > 110

𝑓 1,11,110 = 𝑋

Page 10: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Generateafix• Componentbasedprogramsynthesis• Input-outputpairsofto-be-synthesisprogramareencodedintoconstraintsonasetoflocationvariablesL,avaluationofwhichleadstoaprogramthatsatisfiesthegiveninput-outputpairs.• Constraint𝜓5678 𝐿,𝛼,𝛽 dictatesthatthesynthesizedprogrammustproduceoutput𝛽 whengiveninput𝛼• Input-outputpair 𝜉"<, 𝜏"< isgeneratedwhenfishitatthekth timeintheexecutionofprogramPwithinput𝑡",but 𝜉"<, 𝜏"< issymbolicintermsof 𝜏"<|1 ≤ 𝑘 ≤ 𝜔 ,where𝜔 isnumberoftimesfisexecutedwithinput𝑡"

Page 11: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Generateafix• 𝜏"<|1 ≤ 𝑘 ≤ 𝜔 satisfy• 𝑓 shouldsatisfytheconstraint

• Conjoinconstraintsfromallteststogetherwiththewell-formedness constraint𝜓@5A

Page 12: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Approach

• Puttingitalltogether• ThealgorithmtakesasinputsabuggyprogramP,atestsuiteTandarankedlistofsuspiciousprogramstatementsRC• Whensuccessful,thealgorithmproducesarepair,applyingwhichonPmakesPpassalltestsinthetestsuiteT.

Page 13: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Evaluation

• UseSemFix torepairseededdefectsandrealdefectsinanopensourcesoftware.Theproposedmethodisalsocomparedwithgeneticprogrammingbasedrepairtechniques.

Page 14: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Evaluation

• Intuitively,itishardertogeneratearepairtopassmoretests• Repairsgeneratedwithsmallnumberoftestsmaynotbevalidforotherteststhatarenotintestsuite.

Page 15: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Evaluation

Page 16: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Evaluation

• Differenttypesofbugs

Page 17: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

RelatedWork

• Geneticprogramming:• W.Weimer,T.Nguyen,C.LeGoues,andS.Forrest,“Automaticallyfindingpatchesusinggeneticprogramming,”inICSE,2009.• C.LeGoues,M.Dewey-Vogt,S.Forrest,andW.Weimer,“Asystematicstudyofautomatedprogramrepair:Fixing55outof105bugsfor$8each,”inICSE,2012.

• AutoFix-EandAutoFix-E2arebasedontheprogramcontractsinEiffelprograms• Jobstmann,et.al.usesLTLspecificationsforfinitestateprograms

Page 18: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

RelatedWork

• Gopinath,et.al.usebehavioralspecificationsandencodethespecificationconstraintonthebuggyprogramintoSATconstraint• RobertandRoderickemploytemplatebasedrepairforlinearexpressions.• Dallmeier,et.al.trytogeneratefixesfromobjectbehavioranomalies.• ClearView followsasimilarschemebutworksondeployedbinaryprogramwhenhighavailabilityisrequired.

Page 19: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

RelatedWork

• BugFix suggestsbug-fixthathasbeenusedinasimilardebuggingsituation.• Debroy andWongproposetousemutationforprogramrepair.• PHPRepair focusesonHTMLgenerationerrorsinPHPprograms.• Insteadoffixingabuggyprogram,programsketchingallowsaprogrammertowriteasketchoftheimplementationideawhileleavingthelowleveldetailsomittedasholestobeautomaticallyfilledupbythesketchcomplier.

Page 20: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Conclusion

• TheproposedSemFix isasemanticsbasedprogramrepairtool.• Therepairconstraint,whichisderivedfromasetoftests, issolvedbygeneratingavalidrepair.• SemFix cansynthesizearepaireveniftherepaircodedoesnotexistanywhereintheprogram.

Page 21: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Whichiseasier,fixingabugmanuallyorverifytheauto-generatedbugfix?

Page 22: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Canyouapplyartificialintelligence(AI)toautomaticbugrepairingtoimproveit?• Ifyes,how?

Page 23: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• IfyouareasoftwareengineerinanITcompany,willyouuseanautomaticbugrepairingtool?• Ifyes,whichcaseswillyouuseitin?whichcaseswillyounotuseitin?

Page 24: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Thepapersays"thetestsuitecouldbelargeandthusaffectthescalabilityofourtechnique".• Doyouthinkselectingasubsetoftheentiretestsuiteforrepairgenerationisagoodidea?

Page 25: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Thesebasiccomponentsareusedtogeneratearepairs.• Doyouthinktheyareenough?Shouldweaddsomethingmore,likedivision(/)?

Page 26: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Theproposedmethodonlysynthesisanexpression.• Shouldweusesomemorecomplicatedlogics,likeif-condition,for-loop,andwhile-loop?• Ifyes,howwilltheyaffecttheprecisionandspeedofthebugrepairingmethod?

Page 27: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Theproposedmethodonlychangeonestatement.• Doyouthinkchangingmorestatementsisagoodidea?Why?

Page 28: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• Tobehonest,nomatterhowmanytestcasesareused,wecannotguaranteethebugfixisright.• Canthebugrepairingmethoduseanotherconstraint,insteadoftests?

Page 29: SemFix: Program Repair via Semantic Analysiscourses.cs.vt.edu/cs6704/spring17/slides_by_students/CS6704_Sem… · • BugFix suggests bug-fix that has been used in a similar debugging

Discussion

• CananyotherresearchbedonebasedonSemFix?• Ifyes,talkaboutthedetails.