Human-In-The-Loop Automatic Program Repair

Marcel Böhme, Charaka Geethal, Van-Thuan Pham

TL;DR

This paper introduces LEARN2FIX, a novel human-in-the-loop system for automatic program repair that works even when no bug oracle (beyond the user reporting the bug) is available. It intelligently queries users to build an automatic bug oracle, which then guides the repair process, leading to higher-quality patches with reduced human effort.

What Problem Does This Paper Address?

Automatic Program Repair (APR) aims to fix bugs in software automatically. However, most APR techniques rely on a comprehensive set of test cases that can detect bugs. This paper tackles the challenging scenario where only a single failing test case is provided by a user, and no other test suite exists. The core problem is how to effectively learn about the bug and generate a repair without extensive manual test creation or a pre-existing oracle. This is particularly difficult due to the "class imbalance problem" – most generated test cases are likely to pass, making it hard to train an accurate bug detector.

Methods

LEARN2FIX employs a multi-stage approach:

  • Active Oracle Learning: The system iteratively queries a human oracle (the user) to label generated test cases. It uses an active learning strategy to prioritize asking the user about test cases that are most likely to reveal the bug.
  • Mutational Fuzzing: To generate new test cases, LEARN2FIX uses mutational fuzzing. This technique takes an existing failing test case and applies small modifications (like bit flips or arithmetic changes) to create new inputs, exploring the "neighborhood" of the failing test.
  • SMT-based Automatic Oracle: The system learns an automatic bug oracle using Satisfiability Modulo Theory (SMT) constraints. This oracle is trained on the labeled test cases and aims to predict whether a new test case will expose the bug. The paper specifically uses SMT(LRA) (Satisfiability Modulo Linear Real Arithmetic) for numeric inputs.
  • Oracle Committee for Probabilistic Decisions: To overcome the limitation that SMT solvers provide binary (pass/fail) decisions, LEARN2FIX uses a committee of "look-one-ahead" oracles. This committee helps estimate the probability that a test case is failing, allowing the system to decide whether to query the human oracle.
  • Test-Driven Repair: Once a sufficient set of labeled test cases is generated, the system uses a standard APR tool (GenProg) to synthesize a patch that satisfies these tests.

Datasets

The primary dataset used for evaluation is Codeflaws [11]. This benchmark contains 3902 buggy programs with corresponding "golden" (fixed) versions and manually constructed training and validation test suites. The authors selected 552 subjects from Codeflaws that met specific criteria, including having functional bugs, numeric inputs/outputs, and at least one failing test case.

Key Insights and Ideas

  • Human-in-the-loop is crucial when oracles are absent: The paper demonstrates that a semi-automatic approach, where humans guide the learning process, is effective for APR in scenarios lacking pre-existing test suites.
  • Active learning significantly reduces human effort: By intelligently selecting which test cases to present to the user, LEARN2FIX can build a high-quality bug oracle with a surprisingly small number of queries (around 20).
  • SMT is a powerful tool for learning bug oracles: The use of SMT constraints provides a natural and effective way to represent the conditions under which a bug is exposed.
  • Learned test suites lead to better patches: Patches generated using LEARN2FIX's automatically created test suites exhibit higher quality (fewer validation tests fail) compared to those generated using manually constructed test suites.
  • Addressing class imbalance is key: The paper highlights the challenge of class imbalance (many passing tests, few failing) and proposes strategies like prioritizing minority class queries and using an oracle committee to mitigate its impact.

Key Results

  • Oracle Quality: LEARN2FIX's automatic oracle achieves high prediction accuracy on manually labeled validation tests, reaching 75-84% for the median subject with a labeling effort of 10-30 queries. Conditional accuracy (focusing on failing tests) is even higher, at least 78%.
  • Human Effort Reduction: The proportion of generated tests sent to the human oracle decreases significantly as the labeling effort increases. For a labeling effort of 30, the probability of labeling a failing test case is substantially higher than random chance.
  • Patch Quality: While fewer subjects are repaired using LEARN2FIX's generated test suites compared to manual ones, the validation score (proportion of validation tests passing on the patched program) is higher. This indicates that LEARN2FIX's generated test suites are better suited for producing high-quality, less overfitted patches. Specifically, the proportion of validation tests failing on repaired subjects is 31% smaller on average when using LEARN2FIX's generated suites (l=30) compared to manual suites.

Limitations and Future Work

  • Numeric Input Restriction: The current implementation of LEARN2FIX is limited to programs that take numeric inputs due to the reliance on SMT(LRA). Extending this to handle more complex data types like strings and arrays is a significant area for future work.
  • Oracle Approximation: The learned oracle is an approximation and may mispredict. Future work could explore probabilistic or statistical frameworks to better quantify the risk of misprediction.
  • Generalizability: While the study used a diverse set of real-world bugs from Codeflaws, further evaluation on different benchmarks and with other APR tools would be beneficial.
  • Active Learning Strategies: Exploring alternative active learning strategies, such as those that pass only uncertain test cases to the human (binary classification with abstention), is also a promising direction.

Summary updated

BibTeX
@inproceedings{bohme2020human,
  author = {Marcel Böhme and Charaka Geethal and Van-Thuan Pham},
  title = {{Human-In-The-Loop Automatic Program Repair}},
  booktitle = {ICST},
  year = {2020},
  doi = {10.1109/icst46399.2020.00036},
}
Figure