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)面临测试过拟合的挑战,即生成的补丁虽能通过验证测试却无法泛化。现有补丁评估方法涉及生成新测试或人工审查,既耗时又易产生偏差。本文提出一种新技术INVALIDATOR,通过语义与句法推理自动评估APR生成补丁的正确性。INVALIDATOR利用程序不变量推理程序语义,同时通过预训练语言模型从大规模代码语料中学习语言语义以捕获程序句法。给定缺陷程序与开发者修复后的程序,INVALIDATOR推断两者上的可能不变量,进而判定APR生成的补丁存在过拟合的条件为:(1)违反正确规范,或(2)保留原始缺陷程序的错误行为。当基于不变量无法判定过拟合补丁时,INVALIDATOR利用标记补丁训练的模型,依据程序句法评估补丁正确性。INVALIDATOR的优势有三:其一,融合语义与句法推理增强判别能力;其二,无需生成新测试用例,仅依赖现有测试套件并通过不变量推断泛化程序行为;其三,全自动化运行。实验结果表明,INVALIDATOR在准确率与F值上优于现有方法,正确识别79%的过拟合补丁,且较最优基线多检测23%的过拟合补丁。