Fuzzy test method and system for aero-engine compiler based on large language model
Through a fuzz testing method based on large language model, multiple variant operators and variant prompt templates are designed, complex variant programs are generated and output statements are inserted, which solves the problem of the existing technology being unable to effectively detect silent miscompilation errors in the aircraft engine C compiler. The problem of this method realizes effective detection of the most harmful errors in the compiler, and improves the reliability and security of the system.
Patent Information
- Application Number
- CN202411490506.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-24
AI Technical Summary
The prior art cannot effectively detect back-end miscompilation errors in the aircraft engine C compiler, especially the most harmful silent miscompilation errors.
Using a fuzz testing method based on a large language model, a variety of variant operators and mutation prompt templates are designed by collecting aero engine embedded codes and C compiler test suite programs of various structures as seed programs. Variable programs with more complex data flows and control flows, and monitor local and global variables by inserting output statements to detect silent miscompilation errors.
It improves the complexity and diversity of the test program, can effectively detect the most harmful silent miscompilation errors in the compiler, and enhances the reliability and safety of the embedded system of the aero engine.
Smart Images

Figure CN119473880A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of software testing and compiler testing, and mainly to back-end fuzz testing of aircraft engine embedded C compilers. Background Art
[0002] The compiler is one of the most important basic software. In aircraft engine embedded systems, the stability and correctness of the compiler are crucial to the overall safety of the system. Therefore, when the embedded system performs critical tasks, any compiler errors may cause unforeseen system failures and even threaten aviation safety. Therefore, rigorous and comprehensive testing of the compiler is an indispensable key step to ensure the high reliability and safety of embedded systems. This not only helps to verify the performance of the compiler, but also identifies potential vulnerabilities and errors at an early stage, thereby avoiding catastrophic consequences in actual applications.
[0003] Fuzz testing is the most widely used compiler testing method. The general process of fuzz testing is to generate a large amount of grammatically correct test code and input it into different compilers. If any unexpected or inconsistent behavior occurs during compilation, it indicates that there is a compiler error. Fuzz testing can be divided into generation-based and mutation-based methods. The generation-based method designs a series of grammatical rules, or uses a large amount of grammatically correct code to train a deep neural network to generate test code; the mutation-based method designs a variety of mutation operators to perform local mutations on the existing seed program to generate test code.
[0004] With the development of Large Language Models (LLM), some researchers have begun to explore the application of LLM in compiler fuzz testing. LLM, especially code generation LLM, has powerful and intelligent code generation capabilities after being trained with a large amount of natural language and code data. It can generate complex code for compiler testing according to the requirements of prompt words.
[0005] Although both traditional methods and methods based on large language models have been proven to be able to detect compiler errors, they still have defects. First, traditional fuzz testing methods do not generate enough diversity in test code. Generation-based methods Csmith and Yarpgen generate test code that conforms to grammatical specifications, but the diversity of the code is limited by manually designed generation rules; the most advanced mutation-based method GrayC accumulates small mutations in seed programs to generate a large amount of code that does not have the ability to trigger compiler errors. Second, almost all fuzz testing methods have difficulty detecting the most harmful miscompilation errors, and can only detect less harmful compiler crash errors; finally, there is currently no fuzz testing method based on a large language model specifically designed for C compilers. Fuzz4all is a method based on a large language model and based on both generation and mutation. This method uses a large natural language model (i.e., ChatGPT-4) to automatically summarize the feature documents of the programming language entered by the user, generate input prompts, and then prompt the code generation model (i.e., StarCoder) to generate test programs for the new features of the programming language. Although Fuzz4All has found many flaws in compilers of programming languages that have been actively updated in recent years and have new features (such as C++ and Go), it has not found any errors in the C language compiler (i.e. GCC), which prioritizes stability and security and is not updated frequently. Summary of the invention
[0006] Purpose of the invention: In view of the problem that the prior art cannot effectively detect back-end miscompilation errors in aircraft engine C compilers, especially the most harmful silent miscompilation errors, the present invention provides an aircraft engine compiler fuzzy testing method and system based on a large language model.
[0007] Technical solution: To achieve the above purpose, the technical solution adopted by the present invention is:
[0008] A fuzz testing method for an aircraft engine compiler based on a large language model comprises the following steps:
[0009] Collect various structures of aircraft engine embedded codes and C compiler test suite programs as seed program libraries;
[0010] According to the control structure and data flow characteristics of the aircraft engine code, a variety of mutation operators and their corresponding mutation prompt templates are designed, including insertion mutation operators, deletion mutation operators and replacement mutation operators; the mutation prompt template initially contains three template parts, which respectively indicate the mutation task, specific instructions and the seed program to be mutated; the mutation prompt template for insertion mutation requires the large language model to be inserted at the most complex position of the data flow, and reuses existing variables to enhance the complexity of the data flow;
[0011] A diversity-guided mutation operator selection algorithm is used to make the seed program mutate in a more diverse direction; in the algorithm, a score is set for each mutation operator, and the score of the mutation operator is determined by the diversity of the program it generates, that is, the average distance between programs generated when generating program variants; the algorithm uses the Markov chain Monte Carlo method to sample mutation operators;
[0012] In order to enable variant programs to detect the most harmful errors of compilers, namely silent miscompilation errors, a large language model is used to insert output statements into variant programs to monitor local and global variables. Variant programs with output statements become test cases. The prompt template for inserting output statements includes tasks, specific instruction sample codes, and variant programs that need to insert output statements.
[0013] In order to ensure the validity of the test cases, the test cases that fail the compiler front end and their error information are used as feedback to update the mutation prompt template of the corresponding mutation operator;
[0014] Use test cases to test the aircraft engine compiler to detect back-end errors in the compiler.
[0015] Furthermore, among the multiple mutation operators, insertion mutation includes inserting branch structure, inserting loop structure, inserting control statement, inserting structure, inserting expression and inserting dead code; replacement mutation operator includes replacing certain constants, replacing certain variables, replacing certain operators and replacing the right value of assignment statement; deletion mutation operator includes removing qualifiers, removing modifiers and removing certain unary operators.
[0016] Furthermore, in the hint template for inserting mutations, specific instructions include: instruction [1] requires that when constructing a branch statement, existing variables or expressions in the seed program be reused in branch conditions and code blocks; instruction [2] requires that insertion be performed at locations with high control flow complexity; instruction [3] requires that when there are insufficient existing variables in the seed program, new variables be defined for use in branch statement code blocks.
[0017] Furthermore, for the insertion mutation operator, the [Instructions] in the mutation prompt template include: [1] Utilize existing variables or expressions for <insert structure>. [2] It is best to insert at a location with complex control flow. [3] If necessary, declare and initialize new variables. [4] The response should contain only code.
[0018] For the replacement mutation operator, the [Instructions] in the mutation prompt template include: [1] If there are no <replacement object> to replace, respond me with the original code I provide. [2] There response should contain only code.
[0019] For the delete mutation operator, the [Instructions] in the mutation prompt template include: [1] If there are no <delete object> to remove, respond me with the original code I provide. [2] There response should contain only code.
[0020] Among them, <insert structure>, <replace object>, and <delete object> correspond to the description string in the operator.
[0021] Furthermore, the distance Dist between two programs P1 and P2 is the Jaccard distance between them, and the calculation formula is as follows:
[0022]
[0023] Among them, Stmt P1 and Stmt P2 They represent the line-level code sets of programs P1 and P2 respectively, that is, the programs are divided into lines to form a set, and each element in the set is a line of code.
[0024] Furthermore, the algorithm is based on the Markov Chain Monte Carlo algorithm and selects the mutation operator according to the score ranking of the mutation operator; the calculation formula of the mutation operator score Score(·) is:
[0025]
[0026] Among them, Mut represents the mutation operator, n is the number of program variants obtained by Mut mutation, Dist(P i ,P i-1 ) represents the distance between programs generated by the i-th mutation. When i=1, P i-1 is the seed program; Rate(Mut) represents the probability of Mut mutation generating a valid variant program, and the calculation formula is as follows:
[0027]
[0028] Among them, #FrontPass Mut Indicates the number of variant programs generated using Mut that can pass the compiler front end, #All Mut Represents the total number of variant programs generated using Mut.
[0029] Furthermore, if a syntax error occurs when compiling a test case, that is, it fails to pass the compiler front end, a new part will be added to the mutation prompt template. The newly added part will be filled with the test case and the error information generated during compilation, thereby prompting the large language model to avoid the same type of errors.
[0030] Furthermore, testing the C compiler under test using test cases includes random difference testing and different optimization level testing; the random difference testing belongs to the testing in the cross-compiler scenario, and the different optimization level testing belongs to the testing in the cross-optimization level scenario; the random difference testing is used to find errors in the compiler at the -O0 optimization level, and the different optimization level testing is used to find errors in the compiler at optimization levels other than -O0.
[0031] An aircraft engine compiler fuzz testing system based on a large language model, comprising:
[0032] A program mutation module is used to collect aircraft engine embedded codes and C compiler test suite programs of various structures as seed program libraries; according to the control structure and data flow characteristics of aircraft engine codes, various mutation operators and their corresponding mutation prompt templates are designed, including insertion mutation operators, deletion mutation operators and replacement mutation operators; the mutation prompt template initially includes three template parts, which respectively indicate the mutation task, specific instructions and seed programs that need to be mutated; the mutation prompt template for insertion mutation requires the large language model to be inserted at the most complex position of the data flow, and reuses existing variables to enhance the complexity of the data flow; and adopts a diversity-guided mutation operator selection algorithm to mutate the seed program in a more diverse direction; in the algorithm, a score is set for each mutation operator, and the score of the mutation operator is determined by the diversity of the program it generates, that is, the average program distance generated when generating program variants; the Markov chain Monte Carlo method is used in the algorithm to sample mutation operators; the test cases that fail the compiler front end and their error information are used as feedback to update the mutation prompt template of the corresponding mutation operator;
[0033] The output statement insertion module is used to use the large language model to insert output statements into the variant program to monitor local variables and global variables. The variant program with output statements becomes a test case; wherein the prompt template for inserting output statements includes tasks, specific instruction sample codes and the variant program that needs to insert output statements;
[0034] The differential test module is used to test the aircraft engine compiler to be tested using test cases to detect back-end errors in the compiler.
[0035] A computer program product includes a computer program / instruction, which, when executed by a processor, implements the steps of a large language model-based aerospace engine compiler fuzz testing method.
[0036] Beneficial effects: Compared with the existing methods, the aero-engine compiler fuzz testing method and system based on a large language model provided by the present invention aims at the problem that the test program generated by the previous method has low complexity and needs to accumulate a large number of small mutations. A variety of mutation operators and their mutation prompt templates are designed, and mutation operators are selected based on diversity, so that the large language model can generate variant programs with more complex data flows and control flows. In view of the problem that the previous method lacks the ability to discover compiler miscompilation errors, the large language model is used to insert output statements into the variant program to monitor variables, which helps to discover the most harmful miscompilation errors, especially silent miscompilation errors. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 It is a flow chart of an aircraft engine compiler fuzz testing method based on a large language model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] like Figure 1 As shown, the embodiment of the present invention provides an aircraft engine compiler fuzz testing method based on a large language model, which mainly includes program mutation, output statement insertion and differential testing. The specific implementation of each step is as follows:
[0040] Step S1: Program variation
[0041] Step S1.1, collecting aircraft engine embedded codes and C compiler test suite programs of various structures as a seed program library. Each seed program in the seed program library can be successfully compiled and run.
[0042] Step S1.2: Design a variety of mutation operators and their corresponding mutation prompt templates according to the control structure and data flow characteristics of the aircraft engine code.
[0043] This embodiment designs 13 kinds of program mutation operators and their corresponding mutation prompt templates. The specific mutation operator description is shown in Table 1:
[0044] Table 1 Mutation operators and their [Task] settings
[0045]
[0046]
[0047] Each mutation operator has a corresponding mutation hint template, which initially contains three template parts: [Task], [Instructions], and [Code], which respectively indicate the mutation task, specific instructions, and seed program to be mutated. Among them, [Task] summarizes the mutation task to be performed, [Instructions] describes several more detailed instructions, and [Code] is the program to be mutated. In the hint template for inserting mutations, the large language model is required to insert code in the most complex position of the control flow in [Instructions], and reuse existing variables to enhance the complexity of the data flow.
[0048] In the prompt template for inserting mutations, the first three instructions in [Instructions], instruction [1] requires that when building a branch statement, existing variables or expressions in the seed program be reused in the branch conditions and code blocks. This will link the data flow in the original seed program to the branch statement, thereby achieving the effect of data flow enhancement. Instruction [2] requires that the insertion be performed at a location with high control flow complexity, which can also enhance the data flow. When inserting structures with new control flow (such as loop statements and branch statements), the control flow complexity of the program will also be enhanced. Instruction [3] ensures that new variables can be defined for use in branch statement code blocks when there are insufficient existing variables in the seed program.
[0049] In this embodiment, for the insertion mutation operator, the [Instructions] in the mutation prompt template include: [1] Utilize existing variables or expressions for <Insert structure>. [2] It is best to insert at a location with complex control flow. [3] If necessary, declare and initialize new variables. [4] The response should contain only code. Among them, <Insert structure> includes "the conditions and code blocks within the branching statements", "the conditions and code blocks within the loop statements", etc., which respectively indicate the insertion of branch structure and loop structure, etc.
[0050] For the replacement mutation operator, the [Instructions] in the mutation prompt template include: [1] If there are no <replacement object> to replace, respond me with the original code I provide. [2] There response should contain only code. The <replacement structure> includes "constants", "types", etc., which respectively represent replacement constants and data types, etc.
[0051] For the delete mutation operator, the [Instructions] in the mutation prompt template include: [1] If there are no <delete object> to remove, respond me with the original code I provide. [2] There response should contain only code. Among them, <delete object> includes "qualifiers" and "modifiers", etc., which respectively represent deletion qualifiers and modifiers, etc.
[0052] The following is an example of a mutation tip template that inserts a branch structure:
[0053] [Task]
[0054] Insert a branch statement such as `if`, `if-else`, `switch`, or other conditional constructs into the provided C code.
[0055] [Instructions]
[0056] [1]Utilize existing variables or expressions for the conditions and code blocks.
[0057] [2]It is best to insert at a location with complex control flow.
[0058] [3]If necessary, declare and initialize new variables.
[0059] [4]The response should contain only code.
[0060] [Code]
[0061] / / Seed program
[0062] Among them, [Instructions] formulates specific instructions. In Instruction 1, it is required to reuse existing variables or expressions to construct the conditions and code blocks of conditional statements. This is to enhance the data flow complexity of the variant program; Instruction 2, it is required to insert at the location with complex control flow. This is to enhance the control flow complexity of the variant program; Instruction 3, it is required to declare and initialize new variables if necessary. This is to prevent the number of existing variables or expressions from being too small to construct a complete conditional statement code block; Instruction 4, it is required that the answer of the large language model only contains code. This is to reduce the overhead caused by the number of tokens and facilitate the extraction of code in the answer.
[0063] Step S1.3, using a diversity-guided mutation operator selection algorithm to mutate the seed program in a more diverse direction. In the algorithm, a score is set for each mutation operator, and the score of the mutation operator is determined by the diversity of the programs it generates, that is, the average distance between programs generated when generating program variants. The Markov chain Monte Carlo method is used in the algorithm to sample mutation operators.
[0064] The distance Dist between two programs P1 and P2 is the Jaccard distance between them, and the calculation formula is as follows:
[0065]
[0066] Among them, Stmt P1 and Stmt P2 They represent the line-level code sets of programs P1 and P2 respectively, that is, the programs are divided into lines to form a set, and each element in the set is a line of code.
[0067] The algorithm uses the Markov chain Monte Carlo method to sample mutation operators according to the scores of mutation operators. The calculation formula of mutation operator score Score(·) is:
[0068]
[0069] Among them, Mut represents the mutation operator, n is the number of program variants obtained by Mut mutation, Dist(P i ,P i-1 ) represents the distance between programs generated by the i-th mutation. Note that P i-1 It may be a seed program or a variant program, because here a seed program is mutated multiple times iteratively. Rate(Mut) indicates the probability that Mut mutation will produce a valid variant program.
[0070] Step S1.4: updating the mutation prompt template based on error information feedback.
[0071] To ensure the validity of the test cases, the test cases that failed the compiler front end and their error information are used as feedback to update the mutation prompt template of the corresponding mutation operator. If a syntax error occurs when the test case is compiled, that is, it fails to pass the compiler front end, a new section will be added to the mutation prompt template: [example to avoid syntax error], which will be filled with the test case and the error information generated during compilation, so as to prompt the large language model to avoid the same type of errors.
[0072] Step S2: Insert output statement
[0073] In order to enable variant programs to detect the most harmful errors of the compiler, that is, silent miscompilation errors, the large language model is used to insert output statements into the variant programs to monitor local and global variables. The variant programs with output statements become test cases. The specific process is: for the variant program generated by the large language model, a prompt for inserting output statements is generated for it. The prompt template is divided into four parts: [Task], [Instruction], [Example], and [Code]. [Example] is a sample code for the large language model to learn how to insert output statements for the variant program, and [Code] is the variant program that needs to insert output statements. An example of a prompt template for inserting output statements is as follows:
[0074]
[0075]
[0076] }
[0077] [Code]
[0078] / / Variant program
[0079] Step S3: Differential test
[0080] The aircraft engine compiler to be tested is tested using test cases to detect back-end errors in the compiler. In the present embodiment, the C compiler to be tested is subjected to random difference testing and different optimization level testing using test cases. The random difference testing belongs to the testing under the cross-compiler scenario, and the different optimization level testing belongs to the testing under the cross-optimization level scenario. Here, the random difference testing is generally used to find errors under the compiler-O0 optimization level, and the different optimization level testing is generally used to find errors under the compiler optimization levels other than -O0.
[0081] During the implementation of the present invention, five miscompilation errors have been found in a cross-compiler for an aircraft engine, three of which are silent miscompilation errors that are the most harmful. The discovery of these three errors benefited from the role of the output statement insertion step.
[0082] Based on the same inventive concept, an embodiment of the present invention further provides an aircraft engine compiler fuzzy testing system based on a large language model, comprising:
[0083] A program mutation module is used to collect aircraft engine embedded codes and C compiler test suite programs of various structures as seed program libraries; according to the control structure and data flow characteristics of aircraft engine codes, various mutation operators and their corresponding mutation prompt templates are designed, including insertion mutation operators, deletion mutation operators and replacement mutation operators; the mutation prompt template initially includes three template parts, which respectively indicate the mutation task, specific instructions and seed programs that need to be mutated; the mutation prompt template for insertion mutation requires the large language model to be inserted at the most complex position of the data flow, and reuses existing variables to enhance the complexity of the data flow; and adopts a diversity-guided mutation operator selection algorithm to mutate the seed program in a more diverse direction; in the algorithm, a score is set for each mutation operator, and the score of the mutation operator is determined by the diversity of the program it generates, that is, the average program distance generated when generating program variants; the Markov chain Monte Carlo method is used in the algorithm to sample mutation operators; the test cases that fail the compiler front end and their error information are used as feedback to update the mutation prompt template of the corresponding mutation operator;
[0084] The output statement insertion module is used to use the large language model to insert output statements into the variant program to monitor local variables and global variables. The variant program with output statements becomes a test case; wherein the prompt template for inserting output statements includes tasks, specific instruction sample codes and the variant program that needs to insert output statements;
[0085] The differential test module is used to test the aircraft engine compiler to be tested using test cases to detect back-end errors in the compiler.
[0086] The embodiment of the present invention also provides a computer program product, including a computer program / instruction, which implements the steps of the aerospace engine compiler fuzz testing method based on a large language model when executed by a processor. The program / instruction code for implementing the method of the present invention can be written in any combination of one or more programming languages. These program / instruction codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that the program / instruction code implements the steps of the method of the present invention when executed by the processor or controller. The program / instruction code can be executed completely on the machine, partially on the machine, partially on the machine as an independent software package, or completely on a remote machine or server. What is not described in detail in the present invention is a well-known technology for those skilled in the art.
[0087] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A fuzz testing method for aircraft engine compiler based on a large language model, characterized in that: The steps include: Collect various structures of aircraft engine embedded codes and C compiler test suite programs as seed program libraries; According to the control structure and data flow characteristics of the aircraft engine code, a variety of mutation operators and their corresponding mutation prompt templates are designed, including insertion mutation operators, deletion mutation operators and replacement mutation operators; the mutation prompt template initially contains three template parts, which respectively indicate the mutation task, specific instructions and the seed program to be mutated; the mutation prompt template for insertion mutation requires the large language model to be inserted at the most complex position of the data flow, and reuses existing variables to enhance the complexity of the data flow; A diversity-guided mutation operator selection algorithm is used to make the seed program mutate in a more diverse direction; in the algorithm, a score is set for each mutation operator, and the score of the mutation operator is determined by the diversity of the program it generates, that is, the average distance between programs generated when generating program variants; the algorithm uses the Markov chain Monte Carlo method to sample mutation operators; Using the large language model, output statements are inserted into the variant program to monitor local and global variables. The variant program with output statements becomes a test case. The prompt template for inserting output statements includes tasks, specific instruction sample codes and variant programs where output statements need to be inserted; Use the test cases that fail the compiler front end and their error information as feedback to update the mutation prompt template of the corresponding mutation operator; Use test cases to test the aircraft engine compiler to detect back-end errors in the compiler.
2. The method for fuzz testing an aircraft engine compiler based on a large language model according to claim 1, characterized in that: The multiple mutation operators, wherein insertion mutation includes insertion of branch structure, insertion of loop structure, insertion of control statement, insertion of structure, insertion of expression and insertion of dead code; The replacement mutation operator includes replacing certain constants, replacing certain variables, replacing certain operators and replacing the right value of the assignment statement; the deletion mutation operator includes removing qualifiers, removing modifiers and removing certain unary operators.
3. The method for fuzz testing an aircraft engine compiler based on a large language model according to claim 1, characterized in that: In the hint template for inserting mutations, the specific instructions include: instruction [1] requires that when building a branch statement, existing variables or expressions in the seed program be reused in the branch conditions and code blocks; instruction [2] requires that insertion be performed at locations with high control flow complexity; instruction [3] requires that when there are insufficient existing variables in the seed program, new variables be defined for use in the branch statement code blocks.
4. The method for fuzz testing an aircraft engine compiler based on a large language model according to claim 3, characterized in that: For the insertion mutation operator, the [Instructions] in the mutation prompt template include: [1] Utilize existing variables or expressions for <insert structure>. [2] It is best to insert ata location with complex control flow. [3] If necessary, declare and initialize new variables. [4] The response should contain only code. For the replacement mutation operator, the [Instructions] in the mutation prompt template include: [1] If there are no <replacement object> to replace, respond me with the original code I provide. [2] There response should contain only code. For the delete mutation operator, the [Instructions] in the mutation prompt template include: [1] If there are no <object to remove>, respond me with the original code I provide. [2] The responses should contain only code. Among them, <insert structure>, <replace object>, and <delete object> correspond to the description string in the operator.
5. The aircraft engine compiler fuzz testing method based on a large language model according to claim 1 is characterized in that: The distance Dist between two programs P1 and P2 is the Jaccard distance between them, and the calculation formula is as follows: Among them, Stmt P1 and Stmt P2 They represent the line-level code sets of programs P1 and P2 respectively, that is, the programs are divided into lines to form a set, and each element in the set is a line of code.
6. The aircraft engine compiler fuzz testing method based on a large language model according to claim 1 is characterized in that: The algorithm is based on the Markov Chain Monte Carlo algorithm and selects mutation operators according to their score rankings. The calculation formula of mutation operator score Score(·) is: Among them, Mut represents the mutation operator, n is the number of program variants obtained by Mut mutation, Dist(P i ,P i-1 ) represents the distance between programs generated by the i-th mutation. When i=1, P i-1 is the seed program; Rate(Mut) represents the probability of Mut mutation generating a valid variant program, and the calculation formula is as follows: Among them, #FrontPass Mut Indicates the number of variant programs generated using Mut that can pass the compiler front end, #All Mut Represents the total number of variant programs generated using Mut.
7. The aircraft engine compiler fuzz testing method based on a large language model according to claim 1 is characterized in that: If a syntax error occurs when a test case is compiled, that is, it fails to pass the compiler front end, a new part will be added to the mutation prompt template. The newly added part will be filled with the test case and the error information generated during compilation, thereby prompting the large language model to avoid the same type of errors.
8. The aircraft engine compiler fuzz testing method based on a large language model according to claim 1 is characterized in that: Testing the C compiler under test using test cases includes random difference testing and different optimization level testing; random difference testing belongs to testing in cross-compiler scenarios, and different optimization level testing belongs to testing in cross-optimization level scenarios; random difference testing is used to find errors in the compiler under -O0 optimization level, and different optimization level testing is used to find errors in the compiler under optimization levels other than -O0.
9. An aircraft engine compiler fuzz testing system based on a large language model, characterized in that: include: Program mutation module, used to collect aircraft engine embedded codes and C compiler test suite programs of various structures as seed program libraries; According to the control structure and data flow characteristics of the aircraft engine code, a variety of mutation operators and their corresponding mutation prompt templates are designed, including insertion mutation operators, deletion mutation operators and replacement mutation operators; the mutation prompt template initially contains three template parts, which respectively indicate the mutation task, specific instructions and the seed program to be mutated; the mutation prompt template for insertion mutation requires the large language model to be inserted at the most complex position of the data flow, and reuses existing variables to enhance the complexity of the data flow; and adopting a diversity-guided mutation operator selection algorithm to make the seed program mutate in a more diverse direction; in the algorithm, a score is set for each mutation operator, and the score of the mutation operator is determined by the diversity of the program it generates, that is, the average distance between programs generated when generating program variants; the algorithm uses a Markov chain Monte Carlo method to sample mutation operators; Use the test cases that fail the compiler front end and their error information as feedback to update the mutation prompt template of the corresponding mutation operator; Output statement insertion module, used to insert output statements into variant programs using the large language model to monitor local variables and global variables. The variant programs with output statements become test cases. The prompt template for inserting output statements includes tasks, specific instruction sample codes and variant programs where output statements need to be inserted; The differential test module is used to test the aircraft engine compiler to be tested using test cases to detect back-end errors in the compiler.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of a large language model-based aerospace engine compiler fuzz testing method according to claims 1-8 are implemented.
Citation Information
Patent Citations
Compiler defect positioning method based on big language model enabling
CN117453539A
Fuzzy testing method for scheduling optimization of deep learning compiler
CN118093363A
Compiler middle-rear end defect detection method and system based on diversified guidance
CN118467345A
Compiler error recovery fault detection method and system based on variation configuration selection
CN118626295A
Syntax language generator for compiler validation
US20140173552A1
Cited By
Man-machine cooperation high-real-time function test method and device, medium and program product
CN120316020A
Fuzz testing architecture generation for computing systems and applications
US20260278113A1