
Specialists from the Massachusetts Technological University (MIT) have created the Code Phage algorithm that can automatically correct errors in the source code of programs. The main feature of the new application was the ability to search for suitable patching in an executable code of donor programs, so the algorithm can use donor fragments written in any programming language, reports N+1 .
The new algorithm works as the following principle: first it receives the source code of the “target” program and two data sets, one of which is successfully executed and the other causes an error. The algorithm uses these data sets in order to find one among donor programs in which both of them are processed without error.
Further, in the executable code of the Donor program, the algorithm passes through all conditional transitions, looking for such that after it two sets of incoming data are in different branches. The idea here is that with a high probability this transition just contains the necessary check, which avoids error.
Further, the algorithm in the fragment of the executable code again launches data that created the error in order to build a symbolic tree of representations as a function of the input data based on the results of the performance. According to this tree, the algorithm creates the source code in the desired programming language.
In the last step, the algorithm inserts a new source code into various parts of the “target” program to correct the existing error, but do not make new ones. This procedure is built in such a way that after making a patch in the event of data that can cause an error, the program will simply complete its execution. Thus, the algorithm does not introduce any new behavior, but simply localizes the "dangerous" section of the code and adds a mandatory check in this place.
Based on the test results, in all cases, the authors managed to automatically correct errors associated with zero division and overflow of integer type. As targeted programs and donors, open code applications were used.
Scientists note that for the first time they managed to create a similar algorithm, which also has several fundamental advantages. Of these, according to the authors, the main thing is the ability to work with the executable code of donors, which makes the algorithm independent of the programming language. Also, a new approach is able to effectively solve the problem of transferring variables from the donor code to the target, which also makes the method universal.