Automated Program Repair (APR) aims to automatically generate correct patches for buggy programs. Recent approaches leveraging large language models (LLMs) have shown promise but face limitations. Most rely solely on static analysis, ignoring runtime behaviors. Some attempt to incorporate dynamic signals, but these are often restricted to training or fine-tuning, or injected only once into the repair prompt, without iterative use. This fails to fully capture program execution. Current iterative repair frameworks typically rely on coarse-grained feedback, such as pass/fail results or exception types, and do not leverage fine-grained execution-level information effectively. As a result, models struggle to simulate human stepwise debugging, limiting their effectiveness in multi-step reasoning and complex bug repair. To address these challenges, we propose DynaFix, an execution-level dynamic information-driven APR method that iteratively leverages runtime information to refine the repair process. In each repair round, DynaFix captures execution-level dynamic information such as variable states, control-flow paths, and call stacks, transforming them into structured prompts to guide LLMs in generating candidate patches. If a patch fails validation, DynaFix re-executes the modified program to collect new execution information for the next attempt. This iterative loop incrementally improves patches based on updated feedback, similar to the stepwise debugging practices of human developers. We evaluate DynaFix on the Defects4J v1.2 and v2.0 benchmarks. DynaFix repairs 186 single-function bugs, a 10% improvement over state-of-the-art baselines, including 38 bugs previously unrepaired. It achieves correct patches within at most 35 attempts, reducing the patch search space by 70% compared with existing methods, thereby demonstrating both effectiveness and efficiency in repairing complex bugs.


翻译:自动程序修复旨在为存在缺陷的程序自动生成正确补丁。近年来利用大语言模型的方法展现出潜力,但仍存在局限。多数方法仅依赖静态分析,忽略了运行时行为。部分尝试引入动态信号,但这些信号通常仅限于训练或微调阶段,或仅在修复提示中注入一次,未能进行迭代利用。这导致无法充分捕捉程序执行过程。现有的迭代修复框架通常依赖粗粒度反馈,如通过/失败结果或异常类型,未能有效利用细粒度的执行级信息。因此,模型难以模拟人类逐步调试的过程,限制了其在多步推理和复杂缺陷修复中的有效性。为解决这些问题,我们提出DynaFix,一种基于执行级动态信息驱动的自动程序修复方法,通过迭代利用运行时信息来优化修复过程。在每一轮修复中,DynaFix捕获变量状态、控制流路径和调用栈等执行级动态信息,将其转化为结构化提示以指导大语言模型生成候选补丁。若补丁验证失败,DynaFix会重新执行修改后的程序,为下一次尝试收集新的执行信息。这种迭代循环基于更新的反馈逐步改进补丁,类似于人类开发者的逐步调试实践。我们在Defects4J v1.2和v2.0基准上评估DynaFix。该方法成功修复了186个单函数缺陷,相比最先进的基线方法提升了10%,其中包括38个先前未被修复的缺陷。DynaFix最多在35次尝试内生成正确补丁,与现有方法相比将补丁搜索空间减少了70%,从而在修复复杂缺陷方面同时展现出有效性和高效性。

0
下载
关闭预览

相关内容

【NeurIPS2024】IPO: 面向视觉-语言模型的可解释提示优化
专知会员服务
22+阅读 · 2024年10月23日
Python图像处理,366页pdf,Image Operators Image Processing in Python
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员