[论文解读] Invalidator: Automated Patch Correctness Assessment via Semantic and Syntactic Reasoning
Invalidator 是一种新颖的自动化补丁正确性评估技术,结合了通过程序不变量进行的语义推理和利用 CodeBERT 嵌入进行的语法推理,以检测 APR 生成补丁中的过拟合问题。该方法在无需生成测试用例的情况下完全自动运行,检测到 79% 的过拟合补丁,比最佳基线方法高出 23%,显著优于当前最先进水平。
Automated program repair (APR) faces the challenge of test overfitting, where generated patches pass validation tests but fail to generalize. Existing methods for patch assessment involve generating new tests or manual inspection, which can be time-consuming or biased. In this paper, we propose a novel technique, INVALIDATOR, to automatically assess the correctness of APR-generated patches via semantic and syntactic reasoning. INVALIDATOR leverages program invariants to reason about program semantics while also capturing program syntax through language semantics learned from a large code corpus using a pre-trained language model. Given a buggy program and the developer-patched program, INVALIDATOR infers likely invariants on both programs. Then, INVALIDATOR determines that an APR-generated patch overfits if: (1) it violates correct specifications or (2) maintains erroneous behaviors from the original buggy program. In case our approach fails to determine an overfitting patch based on invariants, INVALIDATOR utilizes a trained model from labeled patches to assess patch correctness based on program syntax. The benefit of INVALIDATOR is threefold. First, INVALIDATOR leverages both semantic and syntactic reasoning to enhance its discriminative capability. Second, INVALIDATOR does not require new test cases to be generated, but instead only relies on the current test suite and uses invariant inference to generalize program behaviors. Third, INVALIDATOR is fully automated. Experimental results demonstrate that INVALIDATOR outperforms existing methods in terms of Accuracy and F-measure, correctly identifying 79% of overfitting patches and detecting 23% more overfitting patches than the best baseline.
研究动机与目标
- 解决自动化程序修复(APR)中持续存在的测试过拟合问题,即补丁通过测试套件但无法泛化。
- 克服现有方法依赖昂贵的手动检查或难以生成的测试用例来检测行为差异的局限性。
- 开发一种完全自动化、可扩展且准确的补丁正确性评估方法,无需生成新测试用例。
- 利用语义(程序不变量)和语法(预训练代码嵌入)推理相结合的方式,提升对过拟合补丁的检测能力。
- 提供一种完全自动化的解决方案,以增强 APR 工具在实际软件开发中的可靠性与实际应用价值。
提出的方法
- 从程序的错误版本和开发者修复后的版本中推断程序不变量,以捕获语义规范。
- 若 APR 生成的补丁违反了正确的不变量,或保留了原始错误程序中的错误行为,则判定其为过拟合。
- 当基于不变量的推理失效时,采用训练好的机器学习模型,基于语法相似性评估补丁的正确性。
- 使用 CodeBERT 生成程序语法的密集向量表示,从大规模代码语料中捕捉语言语义。
- 通过测量 APR 生成补丁与错误程序、以及真实开发者补丁之间的语法差异,来估计过拟合的可能性。
- 在两阶段框架中结合基于不变量的推理与基于语法的分类,以提升判别能力与鲁棒性。
![(a) An overfitting patch generated by Kali [ 35 ]](https://ar5iv.labs.arxiv.org/html/2301.01113/assets/x1.png)
实验结果
研究问题
- RQ1程序不变量能否有效捕获语义规范,以检测 APR 生成补丁中的过拟合?
- RQ2当语义推理失效时,基于预训练代码模型测量的语法相似性能否提升对过拟合补丁的检测能力?
- RQ3结合语义与语法推理的方法相比现有自动化补丁正确性评估技术有何优势?
- RQ4Invalidator 在不生成额外测试用例的情况下,能在多大程度上检测过拟合补丁?
- RQ5在真实世界的 APR 数据集上,Invalidator 与最先进基线方法相比性能如何?
主要发现
- Invalidator 在 Defects4J 的 885 个 APR 生成补丁数据集上成功检测到 79% 的过拟合补丁,较最佳基线方法提升 23%,表现显著更优。
- 与最佳基线相比,Invalidator 的准确率高出 14%,F-measure 提高 19%,展现出更优的整体性能。
- 程序不变量的集成使 Invalidator 能够超越测试套件的覆盖范围,识别出通过测试但语义上错误的补丁。
- 基于 CodeBERT 特征的语法分类器通过比较与真实补丁和错误版本的相似性,提供了灵活且自适应的补丁正确性判断阈值。
- Invalidator 完全自动运行,无需生成任何新测试用例,降低了对复杂测试生成工具的依赖。
- 该方法表明,结合语义与语法推理能显著提升对过拟合补丁的检测能力,优于仅依赖单一模态的方法。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。