CN113590167B - Conditional statement defect patch generation and verification method in object-oriented program - Google Patents
Conditional statement defect patch generation and verification method in object-oriented program Download PDFInfo
- Publication number
- CN113590167B CN113590167B CN202110777641.8A CN202110777641A CN113590167B CN 113590167 B CN113590167 B CN 113590167B CN 202110777641 A CN202110777641 A CN 202110777641A CN 113590167 B CN113590167 B CN 113590167B
- Authority
- CN
- China
- Prior art keywords
- patch
- program
- candidate
- defect
- repair
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 230000007547 defect Effects 0.000 title claims abstract description 50
- 238000000034 method Methods 0.000 title claims abstract description 35
- 238000012795 verification Methods 0.000 title claims abstract description 15
- 230000008439 repair process Effects 0.000 claims abstract description 40
- 238000012360 testing method Methods 0.000 claims abstract description 35
- 238000005516 engineering process Methods 0.000 claims abstract description 11
- 230000014509 gene expression Effects 0.000 claims description 32
- 230000035772 mutation Effects 0.000 claims description 14
- 230000002194 synthesizing effect Effects 0.000 claims description 3
- 238000011160 research Methods 0.000 claims description 2
- 238000012216 screening Methods 0.000 claims description 2
- 230000015572 biosynthetic process Effects 0.000 abstract description 4
- 238000011161 development Methods 0.000 description 2
- 239000002131 composite material Substances 0.000 description 1
- 230000002950 deficient Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000007689 inspection Methods 0.000 description 1
- 230000004807 localization Effects 0.000 description 1
- 238000003786 synthesis reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/658—Incremental updates; Differential updates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3604—Software analysis for verifying properties of programs
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Debugging And Monitoring (AREA)
- Stored Programmes (AREA)
Abstract
The invention provides a conditional statement defect patch generation and verification method in an object-oriented program. The method comprises three steps of repair information collection, patch generation and patch verification. The method comprises the steps of firstly running a test case, collecting context information of a program position to be repaired, then generating a candidate patch automatically by comprehensively using a variation technology and a program synthesis technology, and finally running the test case to verify the effectiveness of the candidate patch. The method can effectively repair two defects of conditional statement errors and conditional statement missing, remarkably improves defect repair rate and patch precision, and relieves the problem of patch overfitting.
Description
Technical Field
The invention belongs to the field of software debugging in software engineering, and particularly relates to a conditional statement defect patch generation and verification method in an object-oriented program.
Background
Software bugs refer to errors in the software that result in the software failing to meet requirements or specifications and needing to be replaced or repaired. Defect repair refers to the act of repairing failed software or software components. In the software development process, debugging is an important means for determining and repairing program defects and ensuring product quality. However, in the development process of fast iteration, the traditional manual debugging faces huge time and labor cost pressure. In order to reduce the debugging pressure of developers and reduce the development cost, researchers propose the capability of computers to assist and even replace the developers in debugging work, and the technology is called automatic defect repair. The technology analyzes and explains the reasons of program failure by means of the capability of a computer, provides one or more feasible repair schemes for the problem program, and therefore effectively reduces debugging cost of developers.
In the existing research results, most of the defect repair techniques use test cases to describe the correct program behavior and verify whether the program patch is valid by rerunning the test cases. If the test case is fully executed, then the program patch is considered a valid patch capable of repairing the defect. However, due to the incompleteness of the test suite, the valid patch generated by such techniques may just pass a given test case without actually achieving the repair.
Disclosure of Invention
Program patch generation and verification are the core steps in automated defect repair. In order to improve the defect repair rate and the patch precision, the invention focuses on the conditional statement defect in the object-oriented program, and provides a novel conditional statement defect repair patch generation and verification method. The method comprises the steps of firstly running a test case, collecting context information of a program position to be repaired, then generating a candidate patch automatically by comprehensively using a variation technology and a program synthesis technology, and finally running the test case to verify the effectiveness of the candidate patch.
A method for generating and verifying a conditional statement defect patch in an object-oriented program comprises the following steps.
Step 1, collecting information required by defect repair.
And acquiring context information of the position of the program to be repaired in the test case execution process by executing the test case. Assuming that the conditional expression to be modified or added at the program position is exp, relevant information is collected from two aspects of input and expected output of the expression exp, and input related data and expected output are converted into a defect repair equation to be solved for guiding generation and verification of a program patch.
And 2, generating a candidate patch for repairing the defect.
And selecting different patch generation strategies according to the statement type of the repairable program position. If the repairable program position is an if conditional statement, which indicates that the program defect is a conditional statement error, the original conditional expression at the position is mutated, and the generated program variant is used as a candidate patch. And if no valid patch meeting the requirement exists in the program variant, synthesizing the candidate patch by using a constraint solving method according to the defect repair equation. And if the repairable program position is not the if conditional statement, which indicates that the program defect is the condition statement missing, synthesizing the conditional expression by directly using a constraint solving method, and adding the synthesized conditional expression as a precondition to form a candidate patch.
And 3, verifying the validity of the candidate patch.
For candidate patches generated by a mutation technology, screening out candidate patches meeting a defect repair equation, and running a test case to verify the effectiveness of the candidate patches; and for candidate patches which are synthesized based on constraint solving, directly running the test cases to verify the validity of the patches.
If the candidate patch is a valid patch, the patch is directly output, the repair process is terminated, and the success of repair is reported. Otherwise, the candidate patch is discarded and the next one is selected for verification. And if no valid patch exists in the candidate patches, reporting the repair failure.
The method focuses on two defects of conditional statement errors and conditional statement missing in an object-oriented program, and different patch generation strategies are selected according to statement types at the position of a repairable program during repair. On one hand, three applicable mutation operators are defined for the conditional statement, and the original conditional expression is simply changed by using a mutation technology to generate the candidate patch. On the other hand, by collecting program semantic information, conditional expressions satisfying constraints are synthesized as candidate patches using component-based program synthesis techniques. Finally, patch verification is performed using the test suite. The method has the advantages that two defects of conditional statement errors and conditional statement missing can be effectively repaired, the defect repair rate and the patch precision are obviously improved, and the problem of over-fitting of the patch is relieved.
Drawings
FIG. 1 is a flow chart of an embodiment of the method of the present invention.
Detailed Description
In order to more clearly show the objects and technical solutions of the present invention, the following will describe the specific embodiments and parameters of the present invention in more detail with reference to the specific implementation processes and the attached drawings.
A method for generating and verifying a conditional statement bug fixing patch in an object-oriented program is shown in FIG. 1 and comprises the following steps.
Step 1, collecting information required for defect repair, step G1 in fig. 1.
The program defect localization technique may obtain a list of suspect statements, each suspect statement comprising a setWherein the location represents the position of the program to be repaired, is used for uniquely identifying a program statement in the defective program and consists of a class name and a line number; the angelicValue refers to a value which can enable the failed test case to be successfully executed, and for the conditional statement defect, the value range is { true, false }; />Indicating a failed test case. On the basis, the context information of the program position to be repaired in the test case execution process is obtained by executing the test case. Assuming that the conditional expression to be modified or added at the program location is exp, relevant information is collected from both the input and output aspects of the expression, and the input data and the desired output can be converted into program semantic constraints to be solved for guiding the synthesis of the program patch.
Further, step 1 comprises the following three steps.
Wherein l is location, which represents the position of exp, and n and m respectively represent the m-th execution of the nth test case. Assuming that all accessible variables have u basic variables, a set of object sets OBJ (w objects in total), and constants before the conditional expression exp to be repaired is executed in the program execution process, thenThe data contained are as follows:
the side-by-side u basic variables and corresponding variable values. Such as: a → 10;
the w bolean values in the positive and negative sides respectively indicate whether w objects in the OBJ are empty. If a certain object is empty, the corresponding value is false;
the status query method and its output of the respective corresponding classes of the objects in the even and odd OBJ, as obj1.Size () → 2;
and an outer constant, such as-1,0,1.
And 1-2, collecting an expected output result of the conditional expression.
In the process of using the test case to run the program, after the conditional expression exp to be repaired is executed, the value which can be passed by the test case and is output by the expression is called expected outputAnd expressing the value range as true, false. />And n and m respectively represent the mth execution of the nth test case.
If it is notIn position is a conditional statement, indicating that it is a conditional statement fault defect, ->Is the expected output of the conditional expression exp for this positional error. For failed test cases>Equal to a value that enables the test case to pass; for a successful test case>Equal to the actual output.
If it is notIn position is an unconditional statement, indicating that the conditional statement is missing a defect, based on the status of the conditional statement, and the status of the conditional statement is not satisfied>Is the expected output of the conditional expression exp for the position missing. For failed test cases>Are all false; with respect to the successful test cases,are both true.
And 1-3, forming a defect repair equation.
And 2, generating a candidate patch for defect repair, wherein the step G2 is shown in the figure 1.
And selecting different patch generation strategies according to the statement type of the repairable program position. And when the statement of the position to be repaired is the if conditional statement, using the strategy one, otherwise, using the strategy two.
The first strategy is as follows: and generating a program patch based on the mutation operator.
When the program position to be repaired is an if conditional statement, small code changes are introduced into the conditional expression at the position based on a predefined mutation operator, and all possible first-order program variants are generated to serve as candidate patches. And if no valid patch exists after verification, generating a candidate patch by using the strategy two. The variation operators in the strategy have three types: (1) negating the conditional expression; (2) Replacing homogeneous operators, including arithmetic operators, relational operators and logical operators; and (3) removing a clause in the conditional expression. For example, a conditional statement if (a >0| | b < 0) is mutated, based on a candidate patch generated by the mutation operator (1) such as if (| (a >0| | b < 0)), based on a candidate patch generated by the mutation operator (2) such as if (a <0| | b < 0), based on a candidate patch generated by the mutation operator (3) such as if (a > 0).
And (2) strategy two: the composite patch is solved based on the constraints.
Obtained by running test cases in step 1<,/>>And after the constraint is generated with the comparison operator, the arithmetic operator and the logic operator, inputting the generated constraint into the SMT solver, and if the constraint has a solution, outputting a conditional expression exp-patch meeting the program constraint. If the constraint is not solved, the next statement in the list of suspect statements continues to be analyzed. And if all statements are analyzed and no valid patch is generated, reporting the repair failure. For example, assuming a conditional expression to be repaired is obtained</>,/>>To is formed by<{x=1, y=1, 0}, true>、<{x=2, y=1, 0}, false>The arithmetic operator is { +, - }, and the logical operator is<,>And then the conditional expression exp-patch synthesized after constraint solving is' x-y<0”。
And for the condition statement missing defect, adding the condition expression exp-patch synthesized by constraint solving as a precondition to a repairable program position to form a candidate patch.
And for the conditional statement error defect, replacing the original error conditional expression exp by using the constraint solving synthesized conditional expression exp-patch to form a candidate program patch.
And 3, verifying the validity of the candidate patch, namely the step G3 in the figure 1.
When the candidate patches are generated by the mutation technology, for each candidate patch, the solution of the defect repair equation (formula 1) in the step 1 needs to be satisfied first, otherwise, the candidate patch is discarded; a test case is then run to verify the validity of the candidate patch. If the candidate patch is a valid patch, the patch information is directly output, and the repair process is terminated. Otherwise, the candidate patch is discarded, and the next candidate patch is selected for inspection and verification. And if all candidate patches generated by the mutation are not valid patches, solving the synthesized candidate patches by using the constraint.
And for candidate patches which are synthesized based on constraint solving, directly running the test cases to verify the validity of the patches. If a valid patch exists which allows all test cases to be executed, the patch is directly output, and the repair process is terminated. Otherwise, the candidate patch is discarded and the next one is selected for verification. If no valid patch is found that meets the requirements, the next statement in the list of suspect statements continues to be analyzed. And if all the sentences in the suspicious sentence list are analyzed and no valid patch is generated, reporting that the repair is failed.
Aiming at the conditional statement defects, two methods of generating patches based on mutation operators and solving synthetic patches based on constraints are provided. According to the statement type of the program position to be repaired, different patch generation and verification strategies can be selected, and the defect repair rate of the repair method is improved. When the conditional statement defect is repaired, the method is feasible and has a good effect.
Claims (2)
1. The method for generating and verifying the conditional statement defect patch in the object-oriented program is characterized by comprising the following steps of:
step 1, collecting information required by defect repair;
acquiring context information of a program position to be repaired in a test case execution process by executing the test case;
assuming that a conditional expression to be modified or added at the program position is exp, collecting relevant information from two aspects of input and expected output of the expression exp, and converting input related data and expected output into a defect repair equation to be solved for guiding generation and verification of a program patch;
step 2, generating candidate patches for defect repair;
selecting different patch generation strategies according to statement types of the repairable program positions; if the repairable program position is an if conditional statement, which indicates that the program defect is a conditional statement error, the original conditional expression of the position is mutated, and the generated program variant is used as a candidate patch; if the repairable program position is not the if conditional statement, which indicates that the program defect is the condition statement missing, synthesizing the conditional expression by directly using a constraint solving method, and adding the synthesized conditional expression as a precondition to form a candidate patch;
step 3, verifying the validity of the candidate patch;
for candidate patches generated by a mutation technology, screening out candidate patches conforming to a defect repair equation, and running a test case to verify the effectiveness of the candidate patches; for candidate patches synthesized based on constraint solving, directly running test cases to verify the validity of the candidate patches;
if the candidate patch is a valid patch, directly outputting the patch, terminating the repair process, and reporting the success of repair; if the candidate patch has no valid patch, reporting the repair failure;
therefore, the condition statement missing defect and the condition statement error defect in the object-oriented program can be repaired.
2. The method of claim 1, wherein the step 2 of generating a candidate patch for defect repair comprises: when a mutation technology is used to generate candidate patches, three types of applicable mutation operators are defined for conditional statements according to the real defect repair mode summarized in the existing research: negating the conditional expression; replacing homogeneous operators, including arithmetic operators, relational operators and logical operators; one clause in the conditional expression is removed.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110777641.8A CN113590167B (en) | 2021-07-09 | 2021-07-09 | Conditional statement defect patch generation and verification method in object-oriented program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110777641.8A CN113590167B (en) | 2021-07-09 | 2021-07-09 | Conditional statement defect patch generation and verification method in object-oriented program |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113590167A CN113590167A (en) | 2021-11-02 |
CN113590167B true CN113590167B (en) | 2023-03-24 |
Family
ID=78246729
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110777641.8A Expired - Fee Related CN113590167B (en) | 2021-07-09 | 2021-07-09 | Conditional statement defect patch generation and verification method in object-oriented program |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113590167B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106663003A (en) * | 2014-06-13 | 2017-05-10 | 查尔斯斯塔克德拉珀实验室公司 | Systems and methods for software analysis |
CN107577603A (en) * | 2017-08-31 | 2018-01-12 | 中国科学院软件研究所 | A kind of procedure condition sentence automation repair system and method based on test case structure decision tree |
CN108228232A (en) * | 2018-01-12 | 2018-06-29 | 扬州大学 | A kind of self-repairing method for circulatory problems in program |
CN109165155A (en) * | 2018-06-20 | 2019-01-08 | 扬州大学 | A kind of software defect recovery template extracting method based on clustering |
CN110825621A (en) * | 2019-10-16 | 2020-02-21 | 四川大学 | Regression test case priority calculation method based on dynamic risk |
CN111506493A (en) * | 2019-12-31 | 2020-08-07 | 中国石油大学(华东) | Program slice-based repair position determination method for automatically repairing defects |
CN112306493A (en) * | 2020-10-23 | 2021-02-02 | 广州博冠信息科技有限公司 | Hot repair patch generation method and device, storage medium and computer equipment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8615752B2 (en) * | 2008-12-30 | 2013-12-24 | International Business Machines Corporation | System and method for detecting software patch dependencies |
-
2021
- 2021-07-09 CN CN202110777641.8A patent/CN113590167B/en not_active Expired - Fee Related
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106663003A (en) * | 2014-06-13 | 2017-05-10 | 查尔斯斯塔克德拉珀实验室公司 | Systems and methods for software analysis |
CN107577603A (en) * | 2017-08-31 | 2018-01-12 | 中国科学院软件研究所 | A kind of procedure condition sentence automation repair system and method based on test case structure decision tree |
CN108228232A (en) * | 2018-01-12 | 2018-06-29 | 扬州大学 | A kind of self-repairing method for circulatory problems in program |
CN109165155A (en) * | 2018-06-20 | 2019-01-08 | 扬州大学 | A kind of software defect recovery template extracting method based on clustering |
CN110825621A (en) * | 2019-10-16 | 2020-02-21 | 四川大学 | Regression test case priority calculation method based on dynamic risk |
CN111506493A (en) * | 2019-12-31 | 2020-08-07 | 中国石油大学(华东) | Program slice-based repair position determination method for automatically repairing defects |
CN112306493A (en) * | 2020-10-23 | 2021-02-02 | 广州博冠信息科技有限公司 | Hot repair patch generation method and device, storage medium and computer equipment |
Non-Patent Citations (3)
Title |
---|
Nopol: Automatic Repair of Conditional Statement Bugs in Java Programs;Jifeng Xuan等;《 IEEE Transactions on Software Engineering》;第34 - 55页 * |
布尔程序修复逆向转换工具的设计与实现;张灵;《cnki优秀硕士学位论文全文库 信息科技辑》(第06期);第I138-191页 * |
面向对象程序中的条件语句缺陷自动修复方法研究;伍佳;《cnki优秀硕士学位论文全文库 信息科技辑》(第02期);第I138-162页 * |
Also Published As
Publication number | Publication date |
---|---|
CN113590167A (en) | 2021-11-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Liu et al. | Mining stackoverflow for program repair | |
Karampatsis et al. | How often do single-statement bugs occur? the manysstubs4j dataset | |
Martinez et al. | Automatic repair of real bugs in java: A large-scale experiment on the defects4j dataset | |
AlOmar et al. | On the impact of refactoring on the relationship between quality attributes and design metrics | |
Marinescu | Detection strategies: Metrics-based rules for detecting design flaws | |
Engström et al. | Empirical evaluations of regression test selection techniques: a systematic review | |
US9588871B1 (en) | Method and system for dynamic business rule extraction | |
Wedyan et al. | The effectiveness of automated static analysis tools for fault detection and refactoring prediction | |
Yue et al. | A characterization study of repeated bug fixes | |
Lutellier et al. | Encore: Ensemble learning using convolution neural machine translation for automatic program repair | |
Mirzaaghaei | Automatic test suite evolution | |
US10853051B2 (en) | Automated candidate repair patch generation | |
CN112685320B (en) | Software defect repairing method and device based on multiple candidate programs | |
CN107643905B (en) | Automatic repair method for software version consistency defects | |
Baker et al. | Detect, fix, and verify TensorFlow API misuses | |
AlOmar et al. | Do design metrics capture developers perception of quality? an empirical study on self-affirmed refactoring activities | |
Mijatov et al. | Testing functional requirements in UML activity diagrams | |
Hentze et al. | Generic Solution-Space Sampling for Multi-domain Product Lines | |
CN113590167B (en) | Conditional statement defect patch generation and verification method in object-oriented program | |
An et al. | Fonte: Finding bug inducing commits from failures | |
Kabadi et al. | The Future Can’t Help Fix The Past: Assessing Program Repair In The Wild | |
Singhal et al. | A critical review of various testing techniques in aspect-oriented software systems | |
CN113051582B (en) | Computer software technology development and debugging system | |
Rodriguez-Echeverria et al. | Suggesting model transformation repairs for rule-based languages using a contract-based testing approach | |
Khalilian et al. | APRSuite: A suite of components and use cases based on categorical decomposition of automatic program repair techniques and tools |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20230324 |