Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Katana: Dual Slicing Based Context for Learning Bug Fixes

Published: 27 May 2023 Publication History
  • Get Citation Alerts
  • Abstract

    Contextual information plays a vital role for software developers when understanding and fixing a bug. Consequently, deep learning based program repair techniques leverage context for bug fixes. However, existing techniques treat context in an arbitrary manner, by extracting code in close proximity of the buggy statement within the enclosing file, class, or method, without any analysis to find actual relations with the bug. To reduce noise, they use a predefined maximum limit on the number of tokens to be used as context. We present a program slicing based approach, in which instead of arbitrarily including code as context, we analyze statements that have a control or data dependency on the buggy statement. We propose a novel concept called dual slicing, which leverages the context of both buggy and fixed versions of the code to capture relevant repair ingredients. We present our technique and tool called Katana, the first to apply slicing-based context for a program repair task. The results show that Katana effectively preserves sufficient information for a model to choose contextual information while reducing noise. We compare against four recent state-of-the-art context-aware program repair techniques. Our results show that Katana fixes between 1.5 and 3.7 times more bugs than existing techniques.

    References

    [1]
    ECMA International. 2015. ECMAScript 2015 Language Specification (ECMA-262 6th Edition). Retrieved January 7, 2022 from https://262.ecma-international.org/6.0.
    [2]
    StackOverflow. 2021. Retrieved January 26, 2021 from https://insights.stackoverflow.com/survey/2021/.
    [3]
    Scitools. 2021. Understand by Scitools. Retrieved December 30, 2021 from https://www.scitools.com/.
    [4]
    GitHub. 2022. Katana. Retrieved November 25, 2022 from https://github.com/saltlab/Katana.
    [5]
    Muath Alkhalaf, Abdulbaki Aydin, and Tevfik Bultan. 2014. Semantic differential repair for input validation and sanitization. In Proceedings of the 2014 International Symposium on Software Testing and Analysis (ISSTA’14). ACM, New York, NY, 225–236.
    [6]
    Miltiadis Allamanis. 2019. The adverse effects of code duplication in machine learning models of code. In Proceedings of the 2019 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!’19). ACM, New York, NY, 143–153.
    [7]
    Miltiadis Allamanis, Marc Brockschmidt, and Mahmoud Khademi. 2018. Learning to represent programs with graphs. In Proceedings of the International Conference on Learning Representations (ICLR’18). 520–524.
    [8]
    Johannes Bader, Andrew Scott, Michael Pradel, and Satish Chandra. 2019. Getafix: Learning to fix bugs automatically. Proceedings of the ACM on Programming Languages3, OOPSLA (2019), Article 159, 27 pages.
    [9]
    Earl T. Barr, Yuriy Brun, Premkumar Devanbu, Mark Harman, and Federica Sarro. 2014. The plastic surgery hypothesis. InProceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE’14). ACM, New York, NY, 306–317.
    [10]
    Berkay Berabi, Jingxuan He, Veselin Raychev, and Martin Vechev. 2021. TFix: Learning to fix coding errors with a text-to-text transformer. In Proceedings of the International Conference on Machine Learning. 780–791.
    [11]
    Z. Chen, S. J. Kommrusch, M. Tufano, L. Pouchet, D. Poshyvanyk, and M. Monperrus. 2021. SequenceR: Sequence-to-sequence learning for end-to-end program repair. IEEE Transactions on Software Engineering 47 (2021), 1943–1959.
    [12]
    Elizabeth Dinella, Hanjun Dai, Ziyang Li, Mayur Naik, Le Song, and Ke Wang. 2020. Hoppity: Learning graph transformations to detect and fix bugs in programs. In Proceedings of the International Conference on Learning Representations (ICLR’20).
    [13]
    Thomas Durieux and Martin Monperrus. 2016. DynaMoth: Dynamic code synthesis for automatic program repair. In Proceedings of the 11th International Workshop on Automation of Software Test (AST’16). ACM, New York, NY, 85–91.
    [14]
    Qing Gao, Yingfei Xiong, Yaqing Mi, Lu Zhang, Weikun Yang, Zhaoping Zhou, Bing Xie, and Hong Mei. 2015. Safe memory-leak fixing for C programs. In Proceedings of the 37th International Conference on Software Engineering—Volume 1 (ICSE’15). IEEE, Los Alamitos, CA, 459–470.
    [15]
    Luca Gazzola, Daniela Micucci, and Leonardo Mariani. 2019. Automatic software repair: A survey. IEEE Transactions on Software Engineering 45, 1 (2019), 34–67.
    [16]
    Rahul Gupta, Soham Pal, Aditya Kanade, and Shirish Shevade. 2017. DeepFix: Fixing common C language errors by deep learning. In Proceedings of the 31st AAAI Conference on Artificial Intelligence. 1345–1351.
    [17]
    Shivani Gupta and Atul Gupta. 2019. Dealing with noise problem in machine learning data-sets: A systematic review. Procedia Computer Science 161 (2019), 466–474.
    [18]
    Péter Gyimesi, Béla Vancsics, Andrea Stocco, Davood Mazinanian, Árpád Beszédes, Rudolf Ferenc, and Ali Mesbah. 2019. BugsJS: A benchmark of JavaScript bugs. In Proceedings of the 2019 12th IEEE Conference on Software Testing, Validation, and Verification (ICST’19). 90–101.
    [19]
    Sakib Haque, Alexander LeClair, Lingfei Wu, and Collin McMillan. 2020. Improved Automatic Summarization of Subroutines via Attention to File Context. ACM, New York, NY, 300–310.
    [20]
    Hideaki Hata, Emad Shihab, and Graham Neubig. 2019. Learning to generate corrective patches using neural machine translation. arXiv preprint arXiv:1812.07170 (2019).
    [21]
    Jiajun Jiang, Yingfei Xiong, Hongyu Zhang, Qing Gao, and Xiangqun Chen. 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’18). ACM, New York, NY, 298–309.
    [22]
    N. Jiang, T. Lutellier, and L. Tan. 2021. CURE: Code-aware neural machine translation for automatic program repair. In Proceedings of the 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE’21). IEEE, Los Alamitos, CA, 1161–1173.
    [23]
    Guoliang Jin, Linhai Song, Wei Zhang, Shan Lu, and Ben Liblit. 2011. Automated atomicity-violation fixing. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’11). ACM, New York, NY, 389–400.
    [24]
    Guoliang Jin, Wei Zhang, Dongdong Deng, Ben Liblit, and Shan Lu. 2012. Automated concurrency-bug fixing. In Proceedings of the 10th USENIX Conference on Operating Systems Design and Implementation (OSDI’12). 221–236.
    [25]
    Arthur V. Kamienski, Luisa Palechor, Cor-Paul Bezemer, and Abram Hindle. 2021. PySStuBs: Characterizing single-statement bugs in popular open-source Python projects. In Proceedings of the 2021 IEEE/ACM 18th International Conference on Mining Software Repositories (MSR’21). 520–524.
    [26]
    Rafael-Michael Karampatsis and Charles Sutton. 2020. How often do single-statement bugs occur? The ManySStuBs4J dataset. In Proceedings of the 17th International Conference on Mining Software Repositories (MSR’20). ACM, New York, NY, 573–577.
    [27]
    Yalin Ke, Kathryn T. Stolee, Claire Le Goues, and Yuriy Brun. 2015. Repairing programs with semantic code search. In Proceedings of the 30th IEEE/ACM International Conference on Automated Software Engineering (ASE’15). IEEE, Los Alamitos, CA, 295–306.
    [28]
    Dongsun Kim, Jaechang Nam, Jaewoo Song, and Sunghun Kim. 2013. Automatic patch generation learned from human-written patches. In Proceedings of the 2013 International Conference on Software Engineering (ICSE’13). IEEE, Los Alamitos, CA, 802–811.
    [29]
    Jindae Kim and Sunghun Kim. 2019. Automatic patch generation with context-based change application. Empirical Software Engineering 24 (2019), 4071–4106.
    [30]
    Andrew J. Ko, Brad A. Myers, Michael J. Coblenz, and Htet Htet Aung. 2006. An exploratory study of how developers seek, relate, and collect relevant information during software maintenance tasks. IEEE Transactions on Software Engineering 32, 12 (Dec. 2006), 971–987.
    [31]
    Claire Le Goues, Michael Dewey-Vogt, Stephanie Forrest, and Westley Weimer. 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, Los Alamitos, CA, 3–13.
    [32]
    Claire Le Goues, ThanhVu Nguyen, Stephanie Forrest, and Westley Weimer. 2012. GenProg: A generic method for automatic software repair. IEEE Transactions on Software Engineering 38 (2012), 54–72.
    [33]
    Guangjie Li, Hui Liu, Jiahao Jin, and Qasim Umer. 2020. Deep learning based identification of suspicious return statements. In Proceedings of the 2020 IEEE 27th International Conference on Software Analysis, Evolution, and Reengineering (SANER’20). 480–491.
    [34]
    Yi Li, Shaohua Wang, and Tien N. Nguyen. 2020. DLFix: Context-based code transformation learning for automated program repair. In Proceedings of the 2020 IEEE/ACM 42nd International Conference on Software Engineering (ICSE’20). ACM, New York, NY, 602–614.
    [35]
    Yi Li, Shaohua Wang, and Tien N. Nguyen. 2022. DEAR: A novel deep learning-based approach for automated program repair. In Proceedings of the 44th International Conference on Software Engineering (ICSE’22). ACM, New York, NY, 511–523.
    [36]
    Zhen Li, Deqing Zou, Shouhuai Xu, Hai Jin, Yawei Zhu, and Zhaoxuan Chen. 2022. SySeVR: A framework for using deep learning to detect software vulnerabilities. IEEE Transactions on Dependable and Secure Computing 19 (2022), 2244–2258.
    [37]
    Zhen Li, Deqing Zou, Shouhuai Xu, Xinyu Ou, Hai Jin, Sujuan Wang, Zhijun Deng, and Yuyi Zhong. 2018. VulDeePecker: A deep learning-based system for vulnerability detection. In Proceedings of the Symposium on Network and Distributed System Security.
    [38]
    Kui Liu, Anil Koyuncu, Dongsun Kim, and Tegawendé F. Bissyandé. 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 (SANER’19). 456–467.
    [39]
    Kui Liu, Anil Koyuncu, Dongsun Kim, and Tegawendé F. Bissyandé. 2019. TBar: Revisiting template-based automated program repair. In Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA’19). ACM, New York, NY, 31–42.
    [40]
    Xuliang Liu and Hao Zhong. 2018. Mining StackOverflow for program repair. In Proceedings of the 2018 IEEE 25th International Conference on Software Analysis, Evolution, and Reengineering (SANER’18). 118–129.
    [41]
    Thibaud Lutellier, Hung Viet Pham, Lawrence Pang, Yitong Li, Moshi Wei, and Lin Tan. 2020. CoCoNuT: Combining context-aware neural translation models using ensemble for program repair. In Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA’20). ACM, New York, NY, 101–114.
    [42]
    Ehsan Mashhadi and Hadi Hemmati. 2021. Applying CodeBERT for automated program repair of Java simple bugs. In Proceedings of the 2021 IEEE/ACM 18th International Conference on Mining Software Repositories (MSR’21). 505–509.
    [43]
    Ali Mesbah, Andrew Rice, Emily Johnston, Nick Glorioso, and Edward Aftandilian. 2019. DeepDelta: Learning to repair compilation errors. In Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE’19). ACM, New York, NY, 925–936.
    [44]
    Martin Monperrus. 2018. The Living Review on Automated Program Repair. Technical Report. HAL Archives Ouvertes. https://hal.archives-ouvertes.fr/hal-01956501.
    [45]
    Simonetta Montemagni and Vito Pirrelli. 1998. Augmenting WordNet-like lexical resources with distributional evidence. An application-oriented perspective. In Proceedings of the COLING/ACL Workshop on Use of WordNet in Natural Language Processing Systems. 87–93.
    [46]
    Marjane Namavar, Noor Nashid, and Ali Mesbah. 2022. A controlled experiment of different code representations for learning-based bug repair. Empirical Software Engineering 27, 7 (2022), Article 190.
    [47]
    Hoang Duong Thien Nguyen, Dawei Qi, Abhik Roychoudhury, and Satish Chandra. 2013. SemFix: Program repair via semantic analysis. In Proceedings of the 2013 International Conference on Software Engineering (ICSE’13). 772–781.
    [48]
    A. Jefferson Offutt, Ammei Lee, Gregg Rothermel, Roland H. Untch, and Christian Zapf. 1996. An experimental determination of sufficient mutant operators. ACM Transactions on Software Engineering Methodology 5, 2 (1996), 99–118.
    [49]
    Michael Pradel and Koushik Sen. 2018. DeepBugs: A learning approach to name-based bug detection. Proceedings of the ACM on Programming Languages 2, OOPSLA (2018), Article 147, 25 pages.
    [50]
    Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J. Liu. 2020. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research 21, 140 (2020), 5485–5551.
    [51]
    Caitlin Sadowski, Edward Aftandilian, Alex Eagle, Liam Miller-Cushon, and Ciera Jaspan. 2018. Lessons from building static analysis tools at Google. Communications of the ACM 61, 4 (2018), 58–66.
    [52]
    Ripon K. Saha, Yingjun Lyu, Hiroaki Yoshida, and Mukul R. Prasad. 2017. ELIXIR: Effective object oriented program repair. In Proceedings of the 32nd IEEE/ACM International Conference on Automated Software Engineering (ASE’17). 648–659.
    [53]
    Roger Scott, Joseph Ranieri, Lucja Kot, and Vineeth Kashyap. 2020. Out of sight, out of place: Detecting and assessing swapped arguments. In Proceedings of the 2020 IEEE 20th International Working Conference on Source Code Analysis and Manipulation (SCAM’20). 227–237.
    [54]
    Sooel Son, Vitaly Shmatikov, and Kathryn S. McKinley. 2013. FixMeUp: Repairing access-control bugs in web applications. In Proceedings of the Network and Distributed System Security Symposium (NDSS’13).
    [56]
    Shin Hwei Tan and Abhik Roychoudhury. 2015. Relifix: Automated repair of software regressions. In Proceedings of the 37th International Conference on Software Engineering—Volume 1 (ICSE’15). 471–482.
    [57]
    Michele Tufano, Cody Watson, Gabriele Bavota, Massimiliano Di Penta, Martin White, and Denys Poshyvanyk. 2019. An empirical study on learning bug-fixing patches in the wild via neural machine translation. ACM Transactions on Software Engineering and Methodology 28, 4 (2019), Article 19, 29 pages.
    [58]
    Westley Weimer, Zachary P. Fry, and Stephanie Forrest. 2013. Leveraging program equivalence for adaptive program repair: Models and first results. In Proceedings of the 28th IEEE/ACM International Conference on Automated Software Engineering (ASE’13). 356–366.
    [59]
    Westley Weimer, ThanhVu Nguyen, Claire Le Goues, and Stephanie Forrest. 2009. Automatically finding patches using genetic programming. In Proceedings of the 31st International Conference on Software Engineering (ICSE’09). IEEE, Los Alamitos, CA, 364–374.
    [60]
    Mark D. Weiser. 1979. Program slices: Formal, psychological, and practical investigations of an automatic program abstraction method. In Proceedings of the 5th International Conference on Software Engineering (ICSE’79). 439–449.
    [61]
    Ming Wen, Junjie Chen, Rongxin Wu, Dan Hao, and Shing-Chi Cheung. 2018. Context-aware patch generation for better automated program repair. In Proceedings of the 40th International Conference on Software Engineering (ICSE’18). 1–11.
    [62]
    Ya Xiao, Salman Ahmed, Wenjia Song, Xinyang Ge, Bimal Viswanath, and Danfeng Yao. 2021. Embedding code contexts for cryptographic API suggestion: New methodologies and comparisons. arXiv preprint arXiv:2103.08747 (2021).
    [63]
    Jifeng Xuan, Matias Martinez, Favio DeMarco, Maxime Clement, Sebastian Lamelas Marcote, Thomas Durieux, Daniel Le Berre, and Martin Monperrus. 2017. Nopol: Automatic repair of conditional statement bugs in Java programs. IEEE Transactions on Software Engineering 43, 1 (2017), 34–55.
    [64]
    He Ye, Matias Martinez, and Martin Monperrus. 2022. Neural program repair with execution-based backpropagation. In Proceedings of the 44th International Conference on Software Engineering (ICSE’22). ACM, New York, NY, 1506–1518.
    [65]
    Fang Yu, Muath Alkhalaf, and Tevfik Bultan. 2011. Patching vulnerabilities with sanitization synthesis. In Proceedings of the 33rd International Conference on Software Engineering (ICSE’11). ACM, New York, NY, 251–260.
    [66]
    Kechi Zhang, Wenhan Wang, Huangzhao Zhang, Ge Li, and Zhi Jin. 2022. Learning to represent programs with heterogeneous graphs. In Proceedings of the 2022 IEEE/ACM 30th International Conference on Program Comprehension (ICPC’22). 378–389.
    [67]
    Jie Zhou, Ganqu Cui, Shengding Hu, Zhengyan Zhang, Cheng Yang, Zhiyuan Liu, Lifeng Wang, Changcheng Li, and Maosong Sun. 2020. Graph neural networks: A review of methods and applications. AI Open 1 (2020), 57–81.
    [68]
    Yaqin Zhou, Shangqing Liu, Jingkai Siow, Xiaoning Du, and Yang Liu. 2019. Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networks. Curran Associates Inc.
    [69]
    Qihao Zhu, Zeyu Sun, Yuan-An Xiao, Wenjie Zhang, Kang Yuan, Yingfei Xiong, and Lu Zhang. 2021. A syntax-guided edit decoder for neural program repair. In Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering (ESEC/FSE’21). ACM, New York, NY, 341–353.
    [70]
    Deqing Zou, Sujuan Wang, Shouhuai Xu, Zhen Li, and Hai Jin. 2021. \(\mu\) VulDeePecker: A deep learning-based system for multiclass vulnerability detection. IEEE Transactions on Dependable and Secure Computing 18, 5 (2019), 2224–2236.

    Cited By

    View all
    • (2024)Towards AI-Assisted Synthesis of Verified Dafny MethodsProceedings of the ACM on Software Engineering10.1145/36437631:FSE(812-835)Online publication date: 12-Jul-2024
    • (2023)A Survey of Learning-based Automated Program RepairACM Transactions on Software Engineering and Methodology10.1145/363197433:2(1-69)Online publication date: 23-Dec-2023
    • (2023)Retrieval-Based Prompt Selection for Code-Related Few-Shot LearningProceedings of the 45th International Conference on Software Engineering10.1109/ICSE48619.2023.00205(2450-2462)Online publication date: 14-May-2023

    Index Terms

    1. Katana: Dual Slicing Based Context for Learning Bug Fixes

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Transactions on Software Engineering and Methodology
      ACM Transactions on Software Engineering and Methodology  Volume 32, Issue 4
      July 2023
      938 pages
      ISSN:1049-331X
      EISSN:1557-7392
      DOI:10.1145/3599692
      • Editor:
      • Mauro Pezzè
      Issue’s Table of Contents

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      Published: 27 May 2023
      Online AM: 06 February 2023
      Accepted: 05 December 2022
      Revised: 02 December 2022
      Received: 25 May 2022
      Published in TOSEM Volume 32, Issue 4

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. Program slicing
      2. program repair
      3. deep learning
      4. contextual information
      5. graph neural networks

      Qualifiers

      • Research-article

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)305
      • Downloads (Last 6 weeks)20
      Reflects downloads up to 10 Aug 2024

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)Towards AI-Assisted Synthesis of Verified Dafny MethodsProceedings of the ACM on Software Engineering10.1145/36437631:FSE(812-835)Online publication date: 12-Jul-2024
      • (2023)A Survey of Learning-based Automated Program RepairACM Transactions on Software Engineering and Methodology10.1145/363197433:2(1-69)Online publication date: 23-Dec-2023
      • (2023)Retrieval-Based Prompt Selection for Code-Related Few-Shot LearningProceedings of the 45th International Conference on Software Engineering10.1109/ICSE48619.2023.00205(2450-2462)Online publication date: 14-May-2023

      View Options

      Get Access

      Login options

      Full Access

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Full Text

      View this article in Full Text.

      Full Text

      Media

      Figures

      Other

      Tables

      Share

      Share

      Share this Publication link

      Share on social media