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生成的补丁的正确性。无效化器利用程序不变量推理程序语义,同时通过使用预训练的语言模型从大型代码语料库中学习的语言语义来捕获程序语法。给定一个有缺陷的程序和开发人员修补的程序,无效化器会推断两个程序上的可能不变量。然后,无效化器确定修补程序过度拟合的条件为:(1)它违反了正确的规范或(2)保留了原本有故障的程序上的错误行为。如果我们的方法无法根据不变量确定是否存在过度拟合的补丁,则无效化器利用来自标记补丁的训练模型,根据程序的句法评估补丁的正确性。无效化器的好处是三重的。首先,无效化器利用语义和句法推理来增强其判别能力。其次,无效化器不需要生成新的测试用例,而是仅依赖于当前的测试套件,并利用不变量推理推广程序的行为。第三,无效化器是完全自动化的。实验结果表明,与最佳基线相比,无效化器在准确度和F值方面表现更好,能够正确识别79%的过度拟合补丁,并检测到比最佳基线多23%的过度拟合补丁。