Table of Contents
Fetching ...

DynaFix: Iterative Automated Program Repair Driven by Execution-Level Dynamic Information

Zhili Huang, Ling Xu, Chao Liu, Weifeng Sun, Xu Zhang, Yan Lei, Meng Yan, Hongyu Zhang

TL;DR

DynaFix tackles the limitations of static-only and coarse-feedback APR by embedding execution-level dynamic information into an iterative repair loop. It leverages ByteTrace to collect runtime traces and employs a layered progressive repair strategy to guide LLM-based patch generation, validating patches through automated tests and semantic checks. Across Defects4J v1.2/v2.0, DynaFix fixes 186 single-function bugs (including 38 unique fixes) with significantly higher repair rates than 11 SOTA baselines, while maintaining efficient search with a capped 35 patch attempts per bug. The combination of fine-grained dynamic signals and iterative refinement enables more accurate fault localization and more effective patches, with broad implications for realistic debugging and automated repair workflows.

Abstract

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: Iterative Automated Program Repair Driven by Execution-Level Dynamic Information

TL;DR

DynaFix tackles the limitations of static-only and coarse-feedback APR by embedding execution-level dynamic information into an iterative repair loop. It leverages ByteTrace to collect runtime traces and employs a layered progressive repair strategy to guide LLM-based patch generation, validating patches through automated tests and semantic checks. Across Defects4J v1.2/v2.0, DynaFix fixes 186 single-function bugs (including 38 unique fixes) with significantly higher repair rates than 11 SOTA baselines, while maintaining efficient search with a capped 35 patch attempts per bug. The combination of fine-grained dynamic signals and iterative refinement enables more accurate fault localization and more effective patches, with broad implications for realistic debugging and automated repair workflows.

Abstract

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.
Paper Structure (22 sections, 7 figures, 4 tables, 1 algorithm)

This paper contains 22 sections, 7 figures, 4 tables, 1 algorithm.

Figures (7)

  • Figure 1: Comparison of information types used in APR: static information, result-level dynamic information, and execution-level dynamic information.
  • Figure 2: Overview of DynaFix.
  • Figure 3: Structure of the hierarchical prompt template. A fixed input–output example is included to enforce consistent response formatting, while code details are omitted.
  • Figure 4: Uniquely repaired bugs on Defects4J.
  • Figure 5: Unique Bug Repairs by DynaFix, Execution-Level Information, Exception Information, and Pure LLM on Defects4J
  • ...and 2 more figures