arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.12743cs.SE
收藏

TraceFixer:执行轨迹驱动的程序修复

TraceFixer: Execution Trace-Driven Program Repair

Islem Bouzenia, Yangruibo Ding, Kexin Pei, Baishakhi Ray, Michael Pradel

AI总结:

本文提出 TraceFixer,利用运行时执行轨迹和偏离点的期望程序状态训练神经程序修复模型,以预测源代码编辑;实验显示其显著提升 Python 单行缺陷修复效果,并成功修复 20 个真实缺陷中的 10 个。

摘要:

在调试非预期的程序行为时,开发者通常能够识别出执行过程中实际行为与期望行为发生偏离的位置。例如,某个变量可能被赋予了错误的值,随后对剩余计算产生负面影响。一旦开发者识别出这种偏离,应如何修复代码,使其产生期望的行为?本文提出 TraceFixer,这是一种预测如何编辑源代码,从而使代码不再偏离预期行为的技术。其核心思想是训练一个神经程序修复模型,该模型不仅从源代码编辑中学习,还利用运行时轨迹的片段。模型的输入包括错误代码的部分执行轨迹(可通过代码插桩自动获得),以及程序在偏离点应达到的正确状态(由用户提供,例如在交互式调试器中提供)。我们的方法与当前程序修复技术存在根本差异:这些技术虽有相似目标,但既不利用执行轨迹,也不利用有关期望程序状态的信息。我们在 Python 代码的单行错误上评估 TraceFixer。在使用由模拟真实缺陷的神经模型生成的数十万次代码编辑训练模型后,我们发现,与仅从源代码编辑中学习的基线相比,利用执行轨迹可将缺陷修复能力提高 13% 至 20%(取决于数据集,统计范围为前 10 个预测)。将 TraceFixer 应用于 20 个真实世界 Python 缺陷的结果表明,该方法成功修复了其中 10 个。

英文摘要:

When debugging unintended program behavior, developers can often identify the point in the execution where the actual behavior diverges from the desired behavior. For example, a variable may get assigned a wrong value, which then negatively influences the remaining computation. Once a developer identifies such a divergence, how to fix the code so that it provides the desired behavior? This paper presents TraceFixer, a technique for predicting how to edit source code so that it does not diverge from the expected behavior anymore. The key idea is to train a neural program repair model that not only learns from source code edits but also exploits excerpts of runtime traces. The input to the model is a partial execution trace of the incorrect code, which can be obtained automatically through code instrumentation, and the correct state that the program should reach at the divergence point, which the user provides, e.g., in an interactive debugger. Our approach fundamentally differs from current program repair techniques, which share a similar goal but exploit neither execution traces nor information about the desired program state. We evaluate TraceFixer on single-line mistakes in Python code. After training the model on hundreds of thousands of code edits created by a neural model that mimics real-world bugs, we find that exploiting execution traces improves the bug-fixing ability by 13% to 20% (depending on the dataset, within the top-10 predictions) compared to a baseline that learns from source code edits only. Applying TraceFixer to 20 real-world Python bugs shows that the approach successfully fixes 10 of them.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑