Skip to main content
Log in

Automatic patch generation with context-based change application

  • Published:
Empirical Software Engineering Aims and scope Submit manuscript

Abstract

Automatic patch generation is often described as a search problem of patch candidate space, and it has two major issues: one is search space size, and the other is navigation. An effective patch generation technique should have a large search space with a high probability that patches for bugs are included, and it also needs to locate such patches effectively. We introduce ConFix, an automatic patch generation technique using context-based change application. ConFix collects abstract AST changes from human-written patches with their AST contexts to provide abundant resources for patch generation. These collected changes are only applied to possible fix locations with the same contexts for patch generation. By considering changes with a matching context only, ConFix selects a necessary change for a possible fix location more effectively than considering all the collected changes. Also, ConFix filters out fix locations with no collected changes in the same context, which means that such locations have not been modified in human-written patches, hence they are not desirable for modifications. We evaluated ConFix with 357 real bugs from Defects4j dataset. ConFix successfully fixed 22 bugs including six bugs which were not fixed by compared existing techniques. With context-based strategy, ConFix checked on average 48% less fix locations than a strategy using only a spectrum-based fault localization technique until patches were generated. Also, it ranked changes required for patches at the top for 63.6%, and within top-3 for 81.8% of the fixed bugs.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9

Similar content being viewed by others

Notes

  1. Apache’s JIRA issue tracker (https://issues.apache.org/jira).

  2. https://github.com/thwak/confix2019result/

  3. https://github.com/thwak/ConFix

  4. https://github.com/thwak/confix2019result

References

  • Arcuri A, Yao X (2008) A novel co-evolutionary approach to automatic software bug fixing. In: 2008. CEC 2008. (IEEE world congress on computational intelligence). IEEE congress on Evolutionary computation, pp 162–168. https://doi.org/10.1109/CEC.2008.4630793

  • Barr ET, Brun Y, Devanbu P, Harman M, Sarro F (2014) The plastic surgery hypothesis. In: Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, FSE ’14

  • Barr ET, Harman M, Jia Y, Marginean A, Petke J (2015) Automated software transplantation. In: Proceedings of the 2015 International Symposium on Software Testing and Analysis, ISSTA 2015. ACM, New York, pp 257–269. https://doi.org/10.1145/2771783.2771796

  • Campos J, Riboira A, Perez A, Abreu R (2012) Gzoltar: an eclipse plug-in for testing and debugging. In: 2012 Proceedings of the 27th IEEE/ACM International Conference on Automated Software Engineering, pp 378–381. https://doi.org/10.1145/2351676.2351752

  • Chen L, Pei Y, Furia CA (2017) Contract-based program repair without the contracts. In: 2017 32Nd IEEE/ACM international conference on automated software engineering (ASE), pp 637–647. https://doi.org/10.1109/ASE.2017.8115674

  • Chilowicz M, Duris E, Roussel G, Paris-est U (2009) Syntax tree fingerprinting: a foundation for source code similarity detection

  • D’Antoni L, Samanta R, Singh R (2016) Qlose: Program repair with quantitative objectives. In: Chaudhuri S, Farzan A (eds) Computer aided verification. Springer International Publishing, Cham, pp 383–401

    Chapter  Google Scholar 

  • Debroy V, Wong WE (2010) Using mutation to automatically suggest fixes for faulty programs. In: Proceedings of the 2010 Third International Conference on Software Testing, Verification and Validation, ICST ’10. IEEE Computer Society, Washington, pp 65–74. https://doi.org/10.1109/ICST.2010.66

  • DeMarco F, Xuan J, Le Berre D, Monperrus M (2014) Automatic repair of buggy if conditions and missing preconditions with smt. In: Proceedings of the 6th International Workshop on Constraints in Software Testing, Verification, and Analysis. ACM, pp 30–39

  • Falleri JR, Morandat F, Blanc X, Martinez M, Montperrus M (2014) Fine-grained and Accurate Source Code Differencing. In: Proceedings of the 29th ACM/IEEE International Conference on Automated Software Engineering, ASE ’14. ACM, New York, pp 313–324. https://doi.org/10.1145/2642937.2642982

  • Fluri B, Wursch M, Pinzger M, Gall H (2007) Change Distilling:Tree differencing for Fine-Grained source code change extraction. IEEE Trans Softw Eng 33(11):725–743. https://doi.org/10.1109/TSE.2007.70731

    Article  Google Scholar 

  • Gabel M, Su Z (2010) A study of the uniqueness of source code. In: Proceedings of the Eighteenth ACM SIGSOFT International Symposium on Foundations of Software Engineering, FSE ’10. ACM, New York, pp 147–156. https://doi.org/10.1145/1882291.1882315

  • Goues CL, Nguyen T, Forrest S, Weimer W (2012) Genprog: a generic method for automatic software repair. IEEE Trans Softw Eng 38(1):54–72. https://doi.org/10.1109/TSE.2011.104

    Article  Google Scholar 

  • Hill A, Păsăreanu CS, Stolee KT (2018) Automated program repair with canonical constraints. In: Proceedings of the 40th International Conference on Software Engineering: Companion Proceeedings, ICSE ’18. ACM, New York, pp 339–341. https://doi.org/10.1145/3183440.3194999

  • Jiang J, Xiong Y, Zhang H, Gao Q, Chen X (2018) Shaping program repair space with existing patches and similar code. In: Proceedings of the 27th ACM SIGSOFT International Symposium on Software Testing and Analysis, ISSTA 2018. ACM, New York, pp 298–309 .https://doi.org/10.1145/3213846.3213871

  • Just R, Jalali D, Ernst MD (2014) Defects4j: a database of existing faults to enable controlled testing studies for java programs. In: Proceedings of the 2014 International Symposium on Software Testing and Analysis, ISSTA 2014. ACM, New York, pp 437–440. https://doi.org/10.1145/2610384.2628055

  • Ke Y, Stolee KT, Goues CL, Brun Y (2015) Repairing programs with semantic code search (t). In: 2015 30Th IEEE/ACM international conference on automated software engineering (ASE), pp 295–306. https://doi.org/10.1109/ASE.2015.60

  • Kim J, Kim S (2016) Location Aware Source Code Differencing for Mining Changes. Tech. rep., Hong Kong University of Science and Technology. https://github.com/thwak/LAS. [Online; accessed 05-Mar-2019]

  • Kim D, Nam J, Song J, Kim S (2013) Automatic patch generation learned from human-written patches. In: Proceedings of the 2013 International Conference on Software Engineering, ICSE’13. http://dl.acm.org/citation.cfm?id=2486788.2486893

  • Le Goues C, Dewey-Vogt M, Forrest S, Weimer W (2012) A systematic study of automated program repair: Fixing 55 out of 105 bugs for $8 each. In: Proceedings of the 34th International Conference on Software Engineering, ICSE ’12. . IEEE Press, Piscataway, pp 3–13. http://dl.acm.org/citation.cfm?id=2337223.2337225

  • Le XB, Lo D, Goues CL (2016) History driven program repair. In: 2016 IEEE 23Rd international conference on software analysis, evolution, and reengineering (SANER), vol 01, pp 213–224. https://doi.org/10.1109/SANER.2016.76

  • Le XBD, Chu DH, Lo D, Le Goues C, Visser W (2017) S3: Syntax- and semantic-guided repair synthesis via programming by examples. In: Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017. ACM, New York, pp 593–604. https://doi.org/10.1145/3106237.3106309

  • Le XBD, Thung F, Lo D, Goues CL (2018) Overfitting in semantics-based automated program repair. Empir Softw Eng 23 (5):3007–3033. https://doi.org/10.1007/s10664-017-9577-2

    Article  Google Scholar 

  • Lipowski A, Lipowska D (2012) Roulette-wheel selection via stochastic acceptance. Physica A: Stat Mech Appl 391(6):2193 – 2196. https://doi.org/10.1016/j.physa.2011.12.004. http://www.sciencedirect.com/science/article/pii/S0378437111009010

    Article  Google Scholar 

  • Liu K, Koyuncu A, Kim D, Bissyandé FT (2019) AVATAR: fixing semantic bugs with fix patterns of static analysis violations. In: Proceedings of the 26th IEEE International Conference on Software Analysis, Evolution, and Reengineering. IEEE, pp 456–467

  • Livshits B, Zimmermann T (2005) Dynamine: Finding common error patterns by mining software revision histories. In: Proceedings of the 10th European Software Engineering Conference Held Jointly with 13th ACM SIGSOFT International Symposium on Foundations of Software Engineering, ESEC/FSE-13. ACM, New York, pp 296–305. https://doi.org/10.1145/1081706.1081754

  • Long F, Rinard M (2015) Staged program repair with condition synthesis. In: Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2015. ACM, New York, pp 166–178. https://doi.org/10.1145/2786805.2786811

  • Long F, Rinard M (2016a) An analysis of the search spaces for generate and validate patch generation systems. In: Proceedings of the 38th International Conference on Software Engineering, ICSE ’16. ACM, New York, pp 702–713. https://doi.org/10.1145/2884781.2884872

  • Long F, Rinard M (2016b) Automatic patch generation by learning correct code. In: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’16. ACM, New York, pp 298–312. https://doi.org/10.1145/2837614.2837617

  • Long F, Amidon P, Rinard M (2017) Automatic inference of code transforms for patch generation. In: Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017. ACM, New York, pp 727–739. https://doi.org/10.1145/3106237.3106253

  • Martinez M, Duchien L, Monperrus M (2013) Automatically extracting instances of code change patterns with ast analysis. In: Proceedings of the 2013 IEEE International Conference on Software Maintenance, ICSM ’13. IEEE Computer Society, Washington, pp 388–391. https://doi.org/10.1109/ICSM.2013.54

  • Martinez M, Weimer W, Monperrus M (2014) Do the fix ingredients already exist? an empirical inquiry into the redundancy assumptions of program repair approaches. In: Companion Proceedings of the 36th International Conference on Software Engineering. ACM, pp 492–495

  • Martinez M, Monperrus M (2015) Mining software repair models for reasoning on the search space of automated program fixing. Empir Softw Eng 20(1):176–205. https://doi.org/10.1007/s10664-013-9282-8

    Article  Google Scholar 

  • Martinez M, Durieux T, Sommerard R, Xuan J, Monperrus M (2016) Automatic Repair of Real Bugs in Java: A Large-Scale Experiment on the Defects4J Dataset. Springer Empirical Software Engineering. https://doi.org/10.1007/s10664-016-9470-4. https://hal.archives-ouvertes.fr/hal-01387556/document

    Article  Google Scholar 

  • Mechtaev S, Yi J, Roychoudhury A (2015) Directfix: Looking for simple program repairs. In: 2015 IEEE/ACM 37Th IEEE international conference on software engineering, vol 1, pp 448–458. https://doi.org/10.1109/ICSE.2015.63

  • Mechtaev S, Yi J, Roychoudhury A (2016) Angelix: Scalable multiline program patch synthesis via symbolic analysis. In: Proceedings of the 38th International Conference on Software Engineering, ICSE ’16. ACM, New York, pp 691–701. https://doi.org/10.1145/2884781.2884807

  • Meng N, Kim M, Mckinley KS (2011a) Sydit: Creating and Applying a Program Transformation from an Example. In: Proceedings of the 19th ACM SIGSOFT Symposium and the 13th European Conference on Foundations of Software Engineering, ESEC/FSE ’11. ACM, New York, pp 440–443. https://doi.org/10.1145/2025113.2025185

  • Meng N, Kim M, McKinley KS (2011b) Systematic editing: Generating program transformations from an example. In: Proceedings of the 32Nd ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’11. ACM, New York, pp 329–342. https://doi.org/10.1145/1993498.1993537

  • Meng N, Kim M, McKinley KS (2013) Lase: locating and applying systematic edits by learning from examples. In: Proceedings of the 2013 International Conference on Software Engineering. IEEE Press, pp 502–511

  • Meyer AdS, Garcia AAF, Souza APd, Souza Jr CLd (2004) Comparison of similarity coefficients used for cluster analysis with dominant markers in maize (zea mays l). Genet Mol Biol 27(1):83–91

    Article  Google Scholar 

  • Nguyen HA, Nguyen AT, Nguyen T, Nguyen T, Rajan H (2013a) A study of repetitiveness of code changes in software evolution. In: 2013 IEEE/ACM 28th international conference on Automated software engineering (ASE), pp 180–190. https://doi.org/10.1109/ASE.2013.6693078

  • Nguyen HDT, Qi D, Roychoudhury A, Chandra S (2013b) Semfix: Program repair via semantic analysis. In: Proceedings of the 2013 International Conference on Software Engineering. IEEE Press, pp 772–781

  • Pearson S, Campos J, Just R, Fraser G, Abreu R, Ernst MD, Pang D, Keller B (2017) Evaluating and improving fault localization. In: Proceedings of the 39th International Conference on Software Engineering, ICSE ’17. IEEE Press, Piscataway, pp 609–620. https://doi.org/10.1109/ICSE.2017.62

  • Perkins JH, Kim S, Larsen S, Amarasinghe S, Bachrach J, Carbin M, Pacheco C, Sherwood F, Sidiroglou S, Sullivan G et al (2009) Automatically patching errors in deployed software. In: Proceedings of the ACM SIGOPS 22nd symposium on Operating systems principles. ACM, pp 87–102

  • Qi Y, Mao X, Lei Y (2013) Efficient automated program repair through fault-recorded testing prioritization. In: Proceedings of the 2013 IEEE International Conference on Software Maintenance, ICSM ’13. IEEE Computer Society, Washington, pp 180–189. https://doi.org/10.1109/ICSM.2013.29

  • Qi Y, Mao X, Lei Y, Dai Z, Wang C (2014) The strength of random search on automated program repair. In: Proceedings of the 36th International Conference on Software Engineering. ACM, pp 254–265

  • Qi Z, Long F, Achour S, Rinard M (2015) An analysis of patch plausibility and correctness for generate-and-validate patch generation systems. In: Proceedings of the 2015 International Symposium on Software Testing and Analysis, ISSTA 2015. ACM, New York, pp 24–36. https://doi.org/10.1145/2771783.2771791

  • Raghavan S, Rohana R, Leon D, Podgurski A, Augustine V (2004) Dex: a semantic-graph differencing tool for studying changes in large code bases. In: 2004 Proceedings 20Th IEEE international conference on software maintenance, pp 188–197. https://doi.org/10.1109/ICSM.2004.1357803

  • Ray B, Nagappan M, Bird C, Nagappan N, Zimmermann T (2014) The uniqueness of changes: Characteristics and applications. Technical report, Microsoft Research Technical Report

  • Rolim R, Soares G, D’Antoni L, Polozov O, Gulwani S, Gheyi R, Suzuki R, Hartmann B (2017) Learning syntactic program transformations from examples. In: Proceedings of the 39th International Conference on Software Engineering, ICSE ’17. IEEE Press, Piscataway, pp 404–415. https://doi.org/10.1109/ICSE.2017.44

  • Saha RK, Lyu Y, Yoshida H, Prasad MR (2017) Elixir: Effective object oriented program repair. In: Proceedings of the 32Nd IEEE/ACM International Conference on Automated Software Engineering, ASE 2017. IEEE Press, Piscataway, pp 648–659. http://dl.acm.org/citation.cfm?id=3155562.3155643

  • Sidiroglou-Douskos S, Lahtinen E, Long F, Rinard M (2015) Automatic error elimination by horizontal code transfer across multiple applications. In: Proceedings of the 36th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’15. ACM, New York, pp 43–54. https://doi.org/10.1145/2737924.2737988

  • Smith EK, Barr ET, Le Goues C, Brun Y (2015) Is the cure worse than the disease? overfitting in automated program repair. In: Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2015. ACM, New York, pp 532–543. https://doi.org/10.1145/2786805.2786825

  • Tan SH, Roychoudhury A (2015) Relifix: Automated repair of software regressions. In: Proceedings of the 37th International Conference on Software Engineering - Volume 1, ICSE ’15. IEEE Press, Piscataway, pp 471–482. http://dl.acm.org/citation.cfm?id=2818754.2818813

  • Tan SH, Yoshida H, Prasad MR, Roychoudhury A (2016) Anti-patterns in search-based program repair. In: Proceedings of the 2016 24th ACM SIGSOFT International Symposium on Foundations of Software Engineering, FSE 2016. ACM, New York, pp 727–738. https://doi.org/10.1145/2950290.2950295

  • Weimer W, Nguyen T, Le Goues C, Forrest S (2009) Automatically finding patches using genetic programming. In: Proceedings of the 31st International Conference on Software Engineering, pp 364–374

  • Weimer W, Fry ZP, Forrest S (2013) Leveraging program equivalence for adaptive program repair: Models and first results. In: 2013 IEEE/ACM 28th international conference on Automated software engineering (ASE). IEEE, pp 356–366

  • Wen M, Chen J, Wu R, Hao D, Cheung SC (2018) Context-aware patch generation for better automated program repair. In: Proceedings of the 40th International Conference on Software Engineering, ICSE ’18. ACM, New York, pp 1–11. https://doi.org/10.1145/3180155.3180233

  • Xin Q, Reiss SP (2017a) Identifying test-suite-overfitted patches through test case generation. In: Proceedings of the 26th ACM SIGSOFT International Symposium on Software Testing and Analysis, ISSTA 2017. ACM, New York, pp 226–236 .https://doi.org/10.1145/3092703.3092718

  • Xin Q, Reiss SP (2017b) Leveraging syntax-related code for automated program repair. In: Proceedings of the 32Nd IEEE/ACM International Conference on Automated Software Engineering, ASE 2017. IEEE Press, Piscataway, pp 660–670. http://dl.acm.org/citation.cfm?id=3155562.3155644

  • Xiong Y, Wang J, Yan R, Zhang J, Han S, Huang G, Zhang L (2017) Precise condition synthesis for program repair. In: Proceedings of the 39th International Conference on Software Engineering, ICSE ’17. IEEE Press, Piscataway, pp 416–426. https://doi.org/10.1109/ICSE.2017.45

  • Xiong Y, Liu X, Zeng M, Zhang L, Huang G (2018) Identifying patch correctness in test-based program repair. In: Proceedings of the 40th International Conference on Software Engineering, ICSE ’18. ACM, New York, pp 789–799. https://doi.org/10.1145/3180155.3180182

  • Yang J, Zhikhartsev A, Liu Y, Tan L (2017) Better test cases for better automated program repair. In: Proceedings of the 2017 11th Joint Meeting on Foundations of Software Engineering, ESEC/FSE 2017. ACM, New York, pp 831–841. https://doi.org/10.1145/3106237.3106274

  • Zhong H, Su Z (2015) An empirical study on real bug fixes. In: Proceedings of the 37th International Conference on Software Engineering - Volume 1, ICSE ’15. IEEE Press, Piscataway, pp 913–923. http://dl.acm.org/citation.cfm?id=2818754.2818864

  • Zhong H, Meng N (2018) Towards reusing hints from past fixes: an exploratory study on thousands of real samples. In: Proceedings of the 40th International Conference on Software Engineering, ICSE ’18. ACM, New York, pp 885–885. https://doi.org/10.1145/3180155.3182550

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jindae Kim.

Additional information

Communicated by: Federica Sarro

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Kim, J., Kim, S. Automatic patch generation with context-based change application. Empir Software Eng 24, 4071–4106 (2019). https://doi.org/10.1007/s10664-019-09742-5

Download citation

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10664-019-09742-5

Keywords

Navigation