Skip to main content
Erschienen in: Empirical Software Engineering 2/2024

01.03.2024

A study of common bug fix patterns in Rust

verfasst von: Mohammad Robati Shirzad, Patrick Lam

Erschienen in: Empirical Software Engineering | Ausgabe 2/2024

Einloggen

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

Rust is a relatively new programming language which allows programmers to write programs that have low-level control over resources while still ensuring high-level safety guarantees (for programs written in safe Rust). Rust’s ownership framework enables programs to meet these two seemingly-contradictory goals. The Rust compiler’s Borrow-Checker component enforces the ownership framework requirements that ensure Rust’s safety guarantees. Rust is popular: as of 2022, it has ranked first, for the seventh consecutive year, in Stack Overflow’s annual Developer Survey as the most-loved programming language. The number of Rust developers is growing as the need for faster and safer software increases. Yet, to our knowledge, no research has sought to identify the most pervasive bug fix patterns within Rust programs. In this project, we introduce Ruxanne, a tool for analyzing and extracting fix patterns in Rust. Ruxanne implements a novel embedding of Rust code into fixed-sized vectors. Using Ruxanne, we mined the top 18 most-starred Rust projects in GitHub to discover the most common bug fix patterns committed to their repositories. We analyzed 87,726 code changes drawn from 57,214 commits across these 18 projects. After clustering the code changes, and conducting a manual analysis, we identified 20 groups of cross-project bug fix patterns, which we categorize as (1) general patterns and (2) borrow-checker-related patterns. Among the general patterns, the most frequently observed pattern is when the user either adds or removes struct fields. In the case of borrow-checker-related patterns, the most common pattern we encountered is when the user removes a clone() call. We describe all detected patterns and their implications to automated program repair.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Literatur
Zurück zum Zitat Alon U, Zilberstein M, Levy O, Yahav E (2018) A general path-based representation for predicting program properties. ACM SIGPLAN Not 53(4):404–419CrossRef Alon U, Zilberstein M, Levy O, Yahav E (2018) A general path-based representation for predicting program properties. ACM SIGPLAN Not 53(4):404–419CrossRef
Zurück zum Zitat Alon U, Zilberstein M, Levy O, Yahav E (2019a) code2seq: Generating sequences from structured representations of code. In: Proceedings of the 2019 Conference of the Association for Computational Linguistics (ACL). pp 6304–6315 Alon U, Zilberstein M, Levy O, Yahav E (2019a) code2seq: Generating sequences from structured representations of code. In: Proceedings of the 2019 Conference of the Association for Computational Linguistics (ACL). pp 6304–6315
Zurück zum Zitat Alon U, Zilberstein M, Levy O, Yahav E (2019b) code2vec: Learning distributed representations of code. Proc ACM Program Lang 3(POPL):1–29 Alon U, Zilberstein M, Levy O, Yahav E (2019b) code2vec: Learning distributed representations of code. Proc ACM Program Lang 3(POPL):1–29
Zurück zum Zitat Arcuri A, Briand L (2011) A practical guide for using statistical tests to assess randomized algorithms in software engineering. In: Proceedings of the 33rd international conference on software engineering. pp 1–10 Arcuri A, Briand L (2011) A practical guide for using statistical tests to assess randomized algorithms in software engineering. In: Proceedings of the 33rd international conference on software engineering. pp 1–10
Zurück zum Zitat Bielik P, Raychev V, Vechev M (2016) PHOG: Probabilistic model for code. In: International conference on machine learning. pp 2933–2942 Bielik P, Raychev V, Vechev M (2016) PHOG: Probabilistic model for code. In: International conference on machine learning. pp 2933–2942
Zurück zum Zitat Campos EC, Maia MA (2019) Discovering common bug-fix patterns: A large-scale observational study. J Softw: Evol Process 31(7):1–28 Campos EC, Maia MA (2019) Discovering common bug-fix patterns: A large-scale observational study. J Softw: Evol Process 31(7):1–28
Zurück zum Zitat Cannon L, Elliott R, Kirchhoff L, Miller J, Milner J, Mitze R, Schan E, Whittington N, Spencer H, Keppel D et al (1991) Recommended C style and coding standards. Pocket reference guide, Specialized Systems Consultants Cannon L, Elliott R, Kirchhoff L, Miller J, Milner J, Mitze R, Schan E, Whittington N, Spencer H, Keppel D et al (1991) Recommended C style and coding standards. Pocket reference guide, Specialized Systems Consultants
Zurück zum Zitat Collins CR, Stephenson K (2003) A circle packing algorithm. Comput Geom 25(3):233–256 Collins CR, Stephenson K (2003) A circle packing algorithm. Comput Geom 25(3):233–256
Zurück zum Zitat Cotroneo D, De Simone L, Iannillo A K, Natella R, Rosiello S, Bidokhti N (2019) Analyzing the context of bug-fixing changes in the OpenStack cloud computing platform. In: 2019 IEEE 30th International Symposium on Software Reliability Engineering (ISSRE). IEEE, pp 334–345 Cotroneo D, De Simone L, Iannillo A K, Natella R, Rosiello S, Bidokhti N (2019) Analyzing the context of bug-fixing changes in the OpenStack cloud computing platform. In: 2019 IEEE 30th International Symposium on Software Reliability Engineering (ISSRE). IEEE, pp 334–345
Zurück zum Zitat DeGroot M H, Schervish M J (2012) Probability and statistics. Pearson Education DeGroot M H, Schervish M J (2012) Probability and statistics. Pearson Education
Zurück zum Zitat Endres A (1975) An analysis of errors and their causes in system programs. IEEE Trans Softw Eng 1(1):140–149CrossRef Endres A (1975) An analysis of errors and their causes in system programs. IEEE Trans Softw Eng 1(1):140–149CrossRef
Zurück zum Zitat Ester M, Kriegel H-P, Sander J, Xu X et al (1996) A density-based algorithm for discovering clusters in large spatial databases with noise. In: KDD. pp 226–231 Ester M, Kriegel H-P, Sander J, Xu X et al (1996) A density-based algorithm for discovering clusters in large spatial databases with noise. In: KDD. pp 226–231
Zurück zum Zitat Eyolfson J (2018) Enforcing Abstract Immutability. PhD thesis, University of Waterloo Eyolfson J (2018) Enforcing Abstract Immutability. PhD thesis, University of Waterloo
Zurück zum Zitat Flanagan C, Felleisen M (1998) A new way of debugging Lisp programs. In: Proceedings of Lisp Users’ Group Meeting (LUGM) Flanagan C, Felleisen M (1998) A new way of debugging Lisp programs. In: Proceedings of Lisp Users’ Group Meeting (LUGM)
Zurück zum Zitat Forrest S, Nguyen T, Weimer W, Le Goues C (2009) A genetic programming approach to automated software repair. In: Proceedings of the 11th annual conference on genetic and evolutionary computation. pp 947–954 Forrest S, Nguyen T, Weimer W, Le Goues C (2009) A genetic programming approach to automated software repair. In: Proceedings of the 11th annual conference on genetic and evolutionary computation. pp 947–954
Zurück zum Zitat Gopinath R, Jensen C, Groce A et al (2015) Mutant census: An empirical examination of the competent programmer hypothesis. Technical Report, School of EECS, Oregon State University Gopinath R, Jensen C, Groce A et al (2015) Mutant census: An empirical examination of the competent programmer hypothesis. Technical Report, School of EECS, Oregon State University
Zurück zum Zitat Hanam Q, Brito FSd M, Mesbah A (2016) Discovering bug patterns in JavaScript. In: Proceedings of the 2016 24th ACM SIGSOFT international symposium on foundations of software engineering. pp 144–156 Hanam Q, Brito FSd M, Mesbah A (2016) Discovering bug patterns in JavaScript. In: Proceedings of the 2016 24th ACM SIGSOFT international symposium on foundations of software engineering. pp 144–156
Zurück zum Zitat Hindle A, Barr ET, Gabel M, Su Z, Devanbu P (2016) On the naturalness of software. Commun ACM 59(5):122–131CrossRef Hindle A, Barr ET, Gabel M, Su Z, Devanbu P (2016) On the naturalness of software. Commun ACM 59(5):122–131CrossRef
Zurück zum Zitat Hoang T, Kang H J, Lo D, Lawall J (2020) CC2Vec: Distributed representations of code changes. In: Proceedings of the ACM/IEEE 42nd international conference on software engineering. pp 518–529 Hoang T, Kang H J, Lo D, Lawall J (2020) CC2Vec: Distributed representations of code changes. In: Proceedings of the ACM/IEEE 42nd international conference on software engineering. pp 518–529
Zurück zum Zitat Huang W, Milanova A, Dietl W, Ernst MD (2012) ReIm & ReImInfer: Checking and inference of reference immutability and method purity. OOPSLA 2012, Object-Oriented Programming Systems, Languages, and Applications. Tucson, AZ, USA, pp 879–896 Huang W, Milanova A, Dietl W, Ernst MD (2012) ReIm & ReImInfer: Checking and inference of reference immutability and method purity. OOPSLA 2012, Object-Oriented Programming Systems, Languages, and Applications. Tucson, AZ, USA, pp 879–896
Zurück zum Zitat Islam MR, Zibran MF (2021) What changes in where? An empirical study of bug-fixing change patterns. ACM SIGAPP Appl Comput Rev 20(4):18–34CrossRef Islam MR, Zibran MF (2021) What changes in where? An empirical study of bug-fixing change patterns. ACM SIGAPP Appl Comput Rev 20(4):18–34CrossRef
Zurück zum Zitat Jeffrey D, Feng M, Gupta N, Gupta R (2009) Bugfix: A learning-based tool to assist developers in fixing bugs. In: 2009 IEEE 17th international conference on program comprehension. IEEE, pp 70–79 Jeffrey D, Feng M, Gupta N, Gupta R (2009) Bugfix: A learning-based tool to assist developers in fixing bugs. In: 2009 IEEE 17th international conference on program comprehension. IEEE, pp 70–79
Zurück zum Zitat Jones J A, Harrold M J (2005) Empirical evaluation of the Tarantula automatic fault-localization technique. In: Proceedings of the 20th IEEE/ACM international conference on automated software engineering. pp 273–282 Jones J A, Harrold M J (2005) Empirical evaluation of the Tarantula automatic fault-localization technique. In: Proceedings of the 20th IEEE/ACM international conference on automated software engineering. pp 273–282
Zurück zum Zitat Klabnik S, Nichols C (2019) The Rust programming language (Covers Rust 2018). No Starch Press Klabnik S, Nichols C (2019) The Rust programming language (Covers Rust 2018). No Starch Press
Zurück zum Zitat 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: 2012 34th International Conference on Software Engineering (ICSE). IEEE, pp 3–13 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: 2012 34th International Conference on Software Engineering (ICSE). IEEE, pp 3–13
Zurück zum Zitat Le Goues C, Pradel M, Roychoudhury A (2019) Automated program repair. Commun ACM 62(12):56–65CrossRef Le Goues C, Pradel M, Roychoudhury A (2019) Automated program repair. Commun ACM 62(12):56–65CrossRef
Zurück zum Zitat Li Z, Wang J, Sun M, Lui J C (2021) MirChecker: Detecting bugs in rust programs via static analysis. In: Proceedings of the 2021 ACM SIGSAC conference on computer and communications security. pp 2183–2196 Li Z, Wang J, Sun M, Lui J C (2021) MirChecker: Detecting bugs in rust programs via static analysis. In: Proceedings of the 2021 ACM SIGSAC conference on computer and communications security. pp 2183–2196
Zurück zum Zitat Lin B, Wang S, Wen M, Mao X (2022) Context-aware code change embedding for better patch correctness assessment. ACM Trans Softw Eng Methodol (TOSEM) 31(3):1–29 Lin B, Wang S, Wen M, Mao X (2022) Context-aware code change embedding for better patch correctness assessment. ACM Trans Softw Eng Methodol (TOSEM) 31(3):1–29
Zurück zum Zitat Ling M, Yu Y, Wu H, Wang Y, Cordy J R, Hassan A E (2022) In Rust we trust: a transpiler from unsafe C to safer Rust. In: Proceedings of the ACM/IEEE 44th international conference on software engineering: companion proceedings. pp 354–355 Ling M, Yu Y, Wu H, Wang Y, Cordy J R, Hassan A E (2022) In Rust we trust: a transpiler from unsafe C to safer Rust. In: Proceedings of the ACM/IEEE 44th international conference on software engineering: companion proceedings. pp 354–355
Zurück zum Zitat Liu Y, Zhang L, Zhang Z (2018) A survey of test based automatic program repair. J. Softw. 13(8):437–452CrossRef Liu Y, Zhang L, Zhang Z (2018) A survey of test based automatic program repair. J. Softw. 13(8):437–452CrossRef
Zurück zum Zitat Martinez M, Monperrus M (2012) Mining repair actions for guiding automated program fixing. PhD thesis, Inria Martinez M, Monperrus M (2012) Mining repair actions for guiding automated program fixing. PhD thesis, Inria
Zurück zum Zitat Martinez M, Monperrus M (2015) Mining software repair models for reasoning on the search space of automated program fixing. Emp Softw Eng 20(1):176–205CrossRef Martinez M, Monperrus M (2015) Mining software repair models for reasoning on the search space of automated program fixing. Emp Softw Eng 20(1):176–205CrossRef
Zurück zum Zitat Monperrus M (2014) “A critical review of automatic patch generation learned from human-written patches”: Essay on the problem statement and the evaluation of automatic software repair. In: Proceedings of the 36th international conference on software engineering. pp 234–242 Monperrus M (2014) “A critical review of automatic patch generation learned from human-written patches”: Essay on the problem statement and the evaluation of automatic software repair. In: Proceedings of the 36th international conference on software engineering. pp 234–242
Zurück zum Zitat Naish L, Lee H J, Ramamohanarao K (2009) Spectral debugging with weights and incremental ranking. In: 2009 16th Asia-pacific software engineering conference. IEEE, pp 168–175 Naish L, Lee H J, Ramamohanarao K (2009) Spectral debugging with weights and incremental ranking. In: 2009 16th Asia-pacific software engineering conference. IEEE, pp 168–175
Zurück zum Zitat Nguyen T, Weimer W, Le Goues C, Forrest S (2009) Using execution paths to evolve software patches. In: 2009 International conference on software testing, verification, and validation workshops. IEEE, pp 152–153 Nguyen T, Weimer W, Le Goues C, Forrest S (2009) Using execution paths to evolve software patches. In: 2009 International conference on software testing, verification, and validation workshops. IEEE, pp 152–153
Zurück zum Zitat Pan K, Kim S, Whitehead EJ (2009) Toward an understanding of bug fix patterns. Emp Softw Eng 14(3):286–315CrossRef Pan K, Kim S, Whitehead EJ (2009) Toward an understanding of bug fix patterns. Emp Softw Eng 14(3):286–315CrossRef
Zurück zum Zitat Qi Y, Mao X, Lei Y (2013) Efficient automated program repair through fault-recorded testing prioritization. In 2013 IEEE International Conference on Software Maintenance. IEEE, pp 180–189 Qi Y, Mao X, Lei Y (2013) Efficient automated program repair through fault-recorded testing prioritization. In 2013 IEEE International Conference on Software Maintenance. IEEE, pp 180–189
Zurück zum Zitat 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. pp 254–265 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. pp 254–265
Zurück zum Zitat Qin B, Chen Y, Yu Z, Song L, Zhang Y (2020) Understanding memory and thread safety practices and issues in real-world Rust programs. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation. pp 763–779 Qin B, Chen Y, Yu Z, Song L, Zhang Y (2020) Understanding memory and thread safety practices and issues in real-world Rust programs. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation. pp 763–779
Zurück zum Zitat Raychev V, Bielik P, Vechev M, Krause A (2016) Learning programs from noisy data. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’16. page 761-774, Association for Computing Machinery, New York, NY, USA Raychev V, Bielik P, Vechev M, Krause A (2016) Learning programs from noisy data. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL ’16. page 761-774, Association for Computing Machinery, New York, NY, USA
Zurück zum Zitat Sam G, Cameron N, Potanin A (2017) Automated refactoring of Rust programs. In Proceedings of the Australasian Computer Science Week Multiconference. pp 1–9 Sam G, Cameron N, Potanin A (2017) Automated refactoring of Rust programs. In Proceedings of the Australasian Computer Science Week Multiconference. pp 1–9
Zurück zum Zitat Spadini D, Aniche M, Bacchelli A (2018) Pydriller: Python framework for mining software repositories. In Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. pp 908–911 Spadini D, Aniche M, Bacchelli A (2018) Pydriller: Python framework for mining software repositories. In Proceedings of the 2018 26th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. pp 908–911
Zurück zum Zitat Tan S H, Roychoudhury A (2015) relifix: Automated repair of software regressions. In 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering volume 1. IEEE, pp 471–482 Tan S H, Roychoudhury A (2015) relifix: Automated repair of software regressions. In 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering volume 1. IEEE, pp 471–482
Zurück zum Zitat Tian H, Tang X, Habib A, Wang S, Liu K, Xia X, Klein J, Bissyandé T F (2022) Is this change the answer to that problem? Correlating descriptions of bug and code changes for evaluating patch correctness. In Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering. pp 1–13 Tian H, Tang X, Habib A, Wang S, Liu K, Xia X, Klein J, Bissyandé T F (2022) Is this change the answer to that problem? Correlating descriptions of bug and code changes for evaluating patch correctness. In Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering. pp 1–13
Zurück zum Zitat Wong WE, Gao R, Li Y, Abreu R, Wotawa F (2016) A survey on software fault localization. IEEE Trans Softw Eng 42(8):707–740CrossRef Wong WE, Gao R, Li Y, Abreu R, Wotawa F (2016) A survey on software fault localization. IEEE Trans Softw Eng 42(8):707–740CrossRef
Zurück zum Zitat Xie X, Chen TY, Kuo F-C, Xu B (2013) A theoretical analysis of the risk evaluation formulas for spectrum-based fault localization. ACM Trans Softw Eng Methodol (TOSEM) 22(4):1–40CrossRef Xie X, Chen TY, Kuo F-C, Xu B (2013) A theoretical analysis of the risk evaluation formulas for spectrum-based fault localization. ACM Trans Softw Eng Methodol (TOSEM) 22(4):1–40CrossRef
Zurück zum Zitat Xu R, Wunsch D (2005) Survey of clustering algorithms. IEEE Trans Neural Netw 16(3):645–678CrossRef Xu R, Wunsch D (2005) Survey of clustering algorithms. IEEE Trans Neural Netw 16(3):645–678CrossRef
Zurück zum Zitat Yang Y, He T, Feng Y, Liu S, Xu B (2022) Mining Python fix patterns via analyzing fine-grained source code changes. Emp Softw Eng 27(2):1–37 Yang Y, He T, Feng Y, Liu S, Xu B (2022) Mining Python fix patterns via analyzing fine-grained source code changes. Emp Softw Eng 27(2):1–37
Zurück zum Zitat Ye H, Gu J, Martinez M, Durieux T, Monperrus M (2021) Automated classification of overfitting patches with statically extracted code features. IEEE Trans Softw Eng 48(8):2920–2938CrossRef Ye H, Gu J, Martinez M, Durieux T, Monperrus M (2021) Automated classification of overfitting patches with statically extracted code features. IEEE Trans Softw Eng 48(8):2920–2938CrossRef
Zurück zum Zitat Zhang Y, Chen Y, Cheung S-C, Xiong Y, Zhang L (2018) An empirical study on TensorFlow program bugs. In Proceedings of the 27th ACM SIGSOFT International Symposium on Software Testing and Analysis. pp 129–140 Zhang Y, Chen Y, Cheung S-C, Xiong Y, Zhang L (2018) An empirical study on TensorFlow program bugs. In Proceedings of the 27th ACM SIGSOFT International Symposium on Software Testing and Analysis. pp 129–140
Metadaten
Titel
A study of common bug fix patterns in Rust
verfasst von
Mohammad Robati Shirzad
Patrick Lam
Publikationsdatum
01.03.2024
Verlag
Springer US
Erschienen in
Empirical Software Engineering / Ausgabe 2/2024
Print ISSN: 1382-3256
Elektronische ISSN: 1573-7616
DOI
https://doi.org/10.1007/s10664-023-10437-1

Weitere Artikel der Ausgabe 2/2024

Empirical Software Engineering 2/2024 Zur Ausgabe

Premium Partner