Skip to main content
QUICK REVIEW

[论文解读] FAPR: Fast and Accurate Program Repair for Introductory Programming Courses

Yunlong Lu, Na Meng|arXiv (Cornell University)|Jul 14, 2021
Software Testing and Debugging Techniques参考文献 33被引用 8
一句话总结

FAPR 是一种针对入门级编程课程的快速且准确的程序修复系统,通过基于标记的比较与基于测试的验证,结合语法编码,生成最小且正确的修复方案。其修复建议覆盖率达 95.5%,在采样修复中正确率达到 89.6%,在 C 和 C++ 程序中,其速度、准确率和跨语言可移植性均优于 Clara。

ABSTRACT

In introductory programming courses, it is challenging for instructors to provide debugging feedback on students' incorrect programs. Some recent tools automatically offer program repair feedback by identifying any differences between incorrect and correct programs, but suffer from issues related to scalability, accuracy, and cross-language portability. This paper presents FAPR -- our novel approach that suggests repairs based on program differences in a fast and accurate manner. FAPR is different from current tools in three aspects. First, it encodes syntactic information into token sequences to enable high-speed comparison between incorrect and correct programs. Second, to accurately extract program differences, FAPR adopts a novel matching algorithm that maximizes token-level matches and minimizes statement-level differences. Third, FAPR relies on testing instead of static/dynamic analysis to validate and refine candidate repairs, so it eliminates the language dependency or high runtime overhead incurred by complex program analysis. We implemented FAPR to suggest repairs for both C and C++ programs; our experience shows the great cross-language portability of FAPR. More importantly, we empirically compared FAPR with a state-of-the-art tool Clara. FAPR suggested repairs for over 95.5% of incorrect solutions. We sampled 250 repairs among FAPR's suggestions, and found 89.6% of the samples to be minimal and correct. FAPR outperformed Clara by suggesting repairs for more cases, creating smaller repairs, producing higher-quality fixes, and causing lower runtime overheads. Our results imply that FAPR can potentially help instructors or TAs to effectively locate bugs in incorrect code, and to provide debugging hints/guidelines based on those generated repairs.

研究动机与目标

  • 为解决在入门级编程课程中提供可扩展、准确且跨语言的程序修复反馈的挑战。
  • 降低依赖复杂静态或动态分析的现有工具所导致的高运行时开销和语言依赖性。
  • 通过语法编码和语句级差异最小化,减少代码修改量,同时保留算法意图,从而提升修复质量。
  • 仅使用测试用例和基于标记的比较,避免手动错误建模或复杂程序分析,实现高效、可移植且准确的修复建议。

提出的方法

  • FAPR 首先通过标记序列的最长公共子序列(LCS)算法,识别与错误程序最相似的最多 100 个正确程序。
  • 通过抽象语法树(AST)中的深度信息增强标记序列,以编码语法结构,提升比较的准确性。
  • 采用一种新颖的匹配算法,选择使语句级差异最小的 LCS,确保修复方案最小且语义上有意义。
  • 通过将选定的正确程序中的变量名替换为错误程序中的变量名,对程序进行规范化,以对齐语法结构。
  • 通过探索规范化后的正确程序与错误程序之间的代码差异子集,生成候选修复方案。
  • 使用自动化测试对每个候选修复方案进行验证,确保其正确性,且不依赖静态或动态程序分析。

实验结果

研究问题

  • RQ1程序修复系统是否能在不依赖复杂静态或动态分析的情况下,实现高效率和高准确率?
  • RQ2通过语法编码增强的基于标记的比较,在生成最小且正确的修复方案方面效果如何?
  • RQ3基于测试的验证方法在多大程度上能确保跨语言可移植性和修复质量?
  • RQ4FAPR 与最先进的工具(如 Clara)相比,在修复覆盖率、正确率和性能方面表现如何?

主要发现

  • FAPR 对 6,676 个错误 C 程序中的 99% 提供了修复建议,对 20,897 个 C/C++ 程序中的 95.5% 提供了修复建议,表明其具有极高的修复覆盖率。
  • 在 250 个采样修复中,89.6% 的修复方案为最小且正确,表明修复质量极高。
  • FAPR 在所有指标上均优于 Clara:修复建议率更高,修复规模更小,修复质量更优,运行时开销更低。
  • FAPR 对 14,221 个正确程序的总预处理时间仅为 306 秒,凸显其高效性。
  • 系统几乎无需开发者投入即可从 C 语言移植到 C++ 语言,证实其具有强大的跨语言可移植性。
  • FAPR 基于测试的验证机制消除了对语言特定分析的依赖,使其在多种编程语言中具有广泛适用性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。