Software development support apparatus, software development support method, and software development support program
The software development support device automates memory safety checks in Rust's unsafe blocks, reducing programmer workload and ensuring compliance with predefined rules to enhance memory safety.
Patent Information
- Application Number
- JP2023079837
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-05-15
- Publication Date
- 2024-11-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The frequent use of unsafe blocks in Rust programming leads to increased programmer workload for ensuring memory safety, as the compiler does not check memory safety within these blocks, undermining the language's inherent safety features.
A software development support device and method that includes a storage section, extraction section, and determination section to define and enforce description rules for blocks declared unsafe in Rust, allowing only permitted descriptions and outputting violations.
Reduces the burden on programmers by automating the check for memory safety violations in unsafe blocks, ensuring compliance with predefined rules, thereby enhancing memory safety.
Smart Images

Figure 2024164392000001_ABST
Abstract
Description
[Technical field]
[0001] The present invention relates to information processing technology. [Background technology]
[0002] 2. Description of the Related Art There is known a source code analysis support system that analyzes whether source code complies with coding rules and outputs the analysis results (see, for example, Patent Document 1). [Prior art documents] [Patent documents]
[0003] [Patent Document 1] JP 2010-198522 A Summary of the Invention [Problem to be solved by the invention]
[0004] Rust, widely known as one of the programming languages with a reputation for memory safety, has a mechanism called unsafe. In a block declared as unsafe, the compiler does not check memory safety as a trade-off for allowing high degrees of freedom in programming, and the programmer is responsible for this. This forces the programmer to carefully check the programs they create. [Means for solving the problem]
[0005] In one embodiment, a software development support device includes a storage unit, an extraction unit, a determination unit, and an output unit. The storage unit stores description rules that define descriptions that are permitted in blocks that declare "unsafe" among descriptions written in the Rust language. The extraction unit extracts blocks that are declared "unsafe" from source code of target software written in the Rust language. The determination unit determines whether or not to permit descriptions included in the blocks extracted by the extraction unit, according to the description rules stored in the storage unit. The output unit outputs information that identifies descriptions that are determined to be not permitted by the determination unit from the source code of the target software. Effect of the Invention
[0006] According to the above aspect, the burden of work for ensuring memory safety is reduced. [Brief description of the drawings]
[0007] [Figure 1A] This is an example (part 1) of a function that is only allowed to be used within a block declared as unsafe in the Rust language. [Figure 1B] This is the second example of a function that is only allowed to be used within a block declared as unsafe in the Rust language. [Diagram 2] FIG. 1 is a diagram illustrating an example of a procedure for software development. [Diagram 3] FIG. 11 is a diagram showing an example of a rule check procedure. [Figure 4] FIG. 11 illustrates an example of a software classification definition. [Diagram 5] FIG. 2 is a diagram illustrating an example of a hierarchical structure of software. [Figure 6A] FIG. 13 is a diagram showing an example of an unsafe description rule definition. [Figure 6B] FIG. 13 is a diagram showing an example of an unsafe description rule. [Figure 7] FIG. 11 is a diagram showing an example of a source file classification list. [Figure 8]FIG. 2 illustrates an example of a functional configuration of a software development support device. [Figure 9] FIG. 2 is a diagram illustrating an example of a hardware configuration of an information processing device. [Figure 10A] 13 is a flowchart (part 1) showing the processing contents of the software development support processing. [Figure 10B] 13 is a second flowchart showing the processing contents of the software development support processing. [Figure 11] FIG. 13 is a diagram showing an example of a violation list. [Figure 12] FIG. 13 is a diagram showing an example of a permission list. [Figure 13] FIG. 11 is a diagram showing an example of a program correction procedure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0008] Hereinafter, the embodiments will be described in detail with reference to the drawings.
[0009] One of the widely known programming languages is Rust, which is well known for its memory safety and high speed processing.
[0010] The Rust language has a mechanism called "unsafe." Within a block that declares unsafe, programming is permitted with a higher degree of freedom than in other parts. On the other hand, the compiler does not check the memory safety of statements within a block that declares unsafe, and it is the programmer's responsibility to guarantee the memory safety of statements within the block.
[0011] Figures 1A and 1B are examples of how functions in the Rust language are permitted to be used only within a block that declares unsafe. For ease of explanation, the examples show line numbers at the beginning of each line; for example, "001:" indicates the first line.
[0012] The first example in Figure 1A shows a dereference of a raw pointer within an unsafe block, a raw pointer defined with a "let ... as *const" or "let ... as *mut" statement.
[0013] In this first example, the statement on line 5 describes the definition of the pointer io_reg as a raw pointer. Regarding this raw pointer io_reg, the statement on line 8 describes the assignment of the value "1" to the reference of the raw pointer io_reg. In addition, the statement on line 9 describes the acquisition and display of the value of the reference of the raw pointer io_reg, following the display of "io_reg data =". Since it is not guaranteed that valid data is stored in the reference of a raw pointer, such a statement that acquires the value of a reference is treated as dereferencing a raw pointer, and is generally prohibited in the Rust language.
[0014] However, in the first example, the statement on line 7 declares unsafe, and the statements on lines 8 and 9 between "unsafe {" on line 7 and "}" on line 10 are included in the block that declares unsafe. Therefore, the statement on line 9 is exceptionally permitted in the Rust language, and no memory safety error will be output when the program is compiled. For this reason, the programmer must thoroughly verify that the process written in the statement on line 9 will not cause a malfunction, and more specifically, that valid data is always stored at the point of reference of the raw pointer io_reg when the process is executed.
[0015] The second example shown in Figure 1B is an example in which a block declared as unsafe contains statements that access and modify a static mut variable, which is a mutable static variable.
[0016] In this second example, the statement in the first line describes defining a static mut variable G_VAR and assigning an initial value of "0". Regarding this variable G_VAR, the statement in the fifth line describes incrementing the value of the variable G_VAR, and the statement in the sixth line describes obtaining and displaying the value of the variable G_VAR, following the display of "G_VAR =". Since static mut variables are not guaranteed to be free of contention among multiple threads, statements that access or change the variable G_VAR in this way are generally prohibited in the Rust language.
[0017] However, in the second example, the statement on line 4 declares unsafe, and the statements on lines 5 and 6 between "unsafe {" on line 4 and "}" on line 7 are statements within the block that declares unsafe. Therefore, the statements on lines 5 and 6 are exceptionally permitted in the Rust language, and no memory safety errors are output when the program is compiled. For this reason, programmers must thoroughly verify that the processing described in the statements on lines 5 and 6 will not cause any malfunctions, and more specifically, that there is no possibility of contention occurring for the variable G_VAR among multiple threads.
[0018] As described above, if unsafe declarations are used frequently in programs written in the Rust language, the inherent memory safety features of the Rust language cannot be fully utilized, and the possibility of memory operation-related bugs increases. Furthermore, the burden of verification work on the programmer to ensure memory safety increases.
[0019] Therefore, in the embodiment described below, description rules that are permitted in descriptions within an unsafe declaration block are defined in advance. Then, the source code (software) of a program written in the Rust language is checked according to these description rules. If a violation of a rule is detected by this check, the programmer makes a correction to eliminate the violation.
[0020] First, a description will be given of Fig. 2. Fig. 2 shows an example of a procedure for software development, and represents the procedure when software development is carried out using a software development support device described later.
[0021] When the procedure in Figure 2 begins, first, a programmer creates a program with source code written in the Rust language (S101). Next, a Rust language compiler is executed on the PC to compile the created program (S102). Note that "PC" is an abbreviation for Personal Computer.
[0022] It is determined whether an error is detected in compiling this program (S103). If an error is detected (YES in S103), the programmer modifies the program to eliminate the error (S104), and then the process returns to S102, where the process from compilation onwards is carried out again for the modified program.
[0023] On the other hand, if no errors are detected in compiling the program (NO in S103), a rule check is performed on the program based on the description rules described above (S105). Then, in the rule check, it is determined whether or not a rule violation is detected in the program (S106).
[0024] If a rule violation is detected (YES in S106), the programmer modifies the program to eliminate the rule violation (S107). After that, the process returns to S102, and the process from compilation onward is carried out again for the modified program.
[0025] On the other hand, if the rule check detects no violation of the rules in the program (NO in S106), the program is implemented in a product and tested (S108), and if the test passes, the program is considered complete.
[0026] As described above, the software development procedure according to this embodiment is characterized in that it includes a procedure for rule checking based on the description rules within the unsafe declaration block, which is enclosed in a dashed box in Figure 2.
[0027] Next, a description will be given of Fig. 3. Fig. 3 is a diagram showing an example of a rule check procedure, and shows details of the procedure enclosed in a dashed line frame in Fig. 2.
[0028] First, prior to a rule check, the unsafe description rule 10 is created, for example, by a development project / development department (S201). The unsafe description rule 10 is created using a software classification definition 20 and an unsafe description rule definition 30.
[0029] 4 shows an example of the software classification definition 20. This definition example is an example in which software is classified according to each layer of the software hierarchical structure, and is prepared in advance.
[0030] Figure 5 shows an example of a software hierarchical structure. The "application layer," "middleware layer," and "driver layer" in this hierarchical structure correspond to the classification names of "application," "middleware," and "driver" in Figure 4, respectively.
[0031] In this embodiment, a "library" represents a collection of general-purpose software that is referenced in various software, and is treated as a separate classification that is not classified into any of the hierarchical structures described above, as shown in Figures 4 and 5, respectively.
[0032] 6A is an example of the unsafe description rule definition 30. This unsafe description rule definition 30 has a table format including the items "rule No.", "rule", and "attached condition".
[0033] The "Rule No." item shows information for identifying each row of the table shown in FIG. 6A.
[0034] The "Rules" section shows the writing rules that are only allowed in blocks that declare unsafe in the Rust language. For example, rule No. 5-1, "inline assembly," is a writing rule that embeds inline assembly in a program written in the Rust language. The four rules excluding "inline assembly" are each one of the four writing rules that are widely known in the Rust language and are referred to as the "unsafe superpower." Writing that follows these writing rules can be detected by existing compilers, and if the writing is placed outside a block that declares unsafe, the compiler will output an error regarding memory safety. On the other hand, if the writing is placed inside a block that declares unsafe, the compiler will not output an error regarding memory safety.
[0035] The "Conditions" item shows conditions that are attached to the description rule shown in the "Rule" item.
[0036] For example, for the rule "dereference of raw pointer," rule No. "1-1" has an additional condition of "access permission address range 1." "Access permission address range 1" is a value that represents the range of addresses in memory space, and this rule No. "1-1" represents a description rule that performs dereferencing of raw pointers that reference addresses included in "access permission address range 1." Similarly, rule No. "1-2" represents a description rule that performs dereferencing of raw pointers that reference addresses included in "access permission address range 2."
[0037] For example, rule No. "2-1" is a description rule for calling functions and methods that are not guaranteed to be safe, and calls FFI. "FFI" is an abbreviation for Foreign Function Interface. On the other hand, "2-2" is a description rule for calling functions and methods other than FFI.
[0038] For example, rule No. "3-1" is a description rule for accessing a static mut variable, i.e., a mutable (changeable) static variable, while rule No. "3-2" is a description rule for accessing an extern {static} variable, i.e., a static variable in an external function.
[0039] Moreover, rule No. "4-1" is a description rule that implements a trait whose associated conditions are not defined but whose safety is not guaranteed.
[0040] Moreover, rule No. "5-1" is a description rule for writing inline assembly in which access to a system register is described.
[0041] 6B shows an example of the unsafe description rule 10. This unsafe description rule 10 is created using the software classification definition 20 shown in FIG.
[0042] The unsafe description rule 10 illustrated in Fig. 6B has a table format including the items "rule No.", "rule", and "attached conditions", and the items "1", "2", "3", and "4" which are classification identifiers. Among these, the items "rule No.", "rule", and "attached conditions" are direct copies of the information in the unsafe description rule definition 30 illustrated in Fig. 6A.
[0043] On the other hand, the classification identifiers indicated as "1", "2", "3", and "4" in the unsafe description rules 10 are identifiers associated with the respective classifications in the software classification definition 20 in Fig. 4. In the procedure S201 for creating the unsafe description rules 10, a setting as to whether or not to permit descriptions in the description rules defined in the unsafe description rule definition 30 within a block declaring unsafe is performed for each software classification identified by a classification identifier.
[0044] In the example of Figure 6B, for software included in the classification identified by the classification identifier, a circle is marked if description according to the description rule specified by each rule No. is permitted within the block, and a penalty mark is marked if description is not permitted.
[0045] Therefore, in the example of FIG. 6B, for example, it is shown that the description rule of rule No. "1-1" in a block declaring unsafe is permitted for software classified as "library". On the other hand, it is shown that the description rule of rule No. "1-1" in a block declaring unsafe is not permitted for software classified as "application", "middleware", and "driver". Also, for example, it is shown that the description rule of rule No. "2-1" in a block declaring unsafe is permitted for software belonging to any of the classifications shown in the example of FIG. 4. On the other hand, it is shown that the description rule of rule No. "2-2" in a block declaring unsafe is not permitted for software belonging to any of the classifications shown in the example of FIG. 4.
[0046] The unsafe description rule 10 is created using the software classification definition 20 and the unsafe description rule definition 30 as described above.
[0047] Returning to the explanation of FIG. 3, in parallel with the creation of the unsafe description rules 10, the source files 40 are classified by, for example, a development project / development department (S202), and a source file classification list 50 is created.
[0048] The source file 40 is a file that stores the source code of a program in which errors are no longer detected by the Rust language compiler as a result of the procedure in S103 in Fig. 2. In the procedure in S202, the program is classified according to the software classification definition 20, and the result of this classification is shown in the source file classification list 50.
[0049] FIG. 7 shows an example of the source file classification list 50. As shown in FIG.
[0050] The source file classification list 50 is a list that associates "file names" that identify individual source files 40 with "classification identifiers" that indicate the classifications that include the programs stored in the source files 40. Note that the classification identifiers used are those associated with each classification in the software classification definition 20 in FIG. 4.
[0051] 7, for example, "source file A" is the file name of one of the source files 40. The program stored in this "source file A" is classified into the "application layer" in the hierarchical structure of FIG. 5, and as a result, it is shown that the classification identifier "1" associated with "application" in the software classification definition 20 is assigned to the program.
[0052] The unsafe description rules 10 and the source file classification list 50 created as described above are input to the software development support device 100 together with the source file 40. The software development support device 100 searches for blocks that declare unsafe from the source code of the program included in the source file 40. Then, based on the unsafe description rules 10 and the source file classification list 50, it determines whether or not the description in the block is permitted, and outputs the determination result as a determination result list 60.
[0053] Thereafter, the programmer modifies the program included in the source file 40 based on the judgment results shown in the judgment result list 60 (S203). The program after this modification is the target program for testing performed in the procedure of S108 in FIG. 2.
[0054] The rule check according to the procedure shown in FIG. 3 is carried out as described above.
[0055] Next, the software development support device 100 will be described in further detail.
[0056] First, an example of a functional configuration of the software development support device 100 will be described with reference to Fig. 8. The software development support device 100 illustrated in Fig. 8 includes a storage unit 101, an extraction unit 102, a determination unit 103, and an output unit 104.
[0057] The storage unit 101 stores description rules that define descriptions that are permitted within blocks that declare "unsafe" in the Rust language.
[0058] The extraction unit 102 extracts blocks in which unsafe is declared from the source code of the target software written in the Rust language. The source code of the target software is, for example, the source code stored in the source file 40 shown in FIG.
[0059] The determining unit 103 determines whether or not the description contained in the block extracted by the extracting unit 102 is permitted, in accordance with the description rules stored in the storage unit 101 .
[0060] The output unit 104 outputs information for identifying, from the source code of the target software, a description that has been determined to be not permitted by the above determination by the determination unit 103. Note that the output unit 104 may further output information for identifying, from the source code of the target software, a description that has been determined to be permitted by the above determination by the determination unit 103.
[0061] The description rule stored in the storage unit 101 is, for example, the unsafe description rule 10 created by the procedure of S201 in the rule check shown in Fig. 3. As described above, the unsafe description rule 10 is defined as a combination of a "rule" and an "attaching condition", that is, a combination of a description rule that is permitted only within a block that declares unsafe and an attendant condition for the description rule.
[0062] As described above, the unsafe description rules 10 define descriptions permitted in blocks declared as unsafe for each type of software in which the block is used, more specifically, for each layer of the software hierarchy. Therefore, the determination unit 103 may determine whether or not to permit descriptions contained in the blocks extracted by the extraction unit 102 according to description rules corresponding to the type of target software. When the target software is a program stored in the source file 40, information on the type of target software is obtained from the source file classification list 50.
[0063] Next, the hardware configuration of the software development support device 100 will be described.
[0064] 9 shows an example of the hardware configuration of an information processing device 70. A software development support device 100 can be configured using this information processing device 70.
[0065] The information processing device 70 is a computer equipped with the following components: a CPU 71, a memory 72, an input device 73, a display device 74, an auxiliary storage device 75, and a communication I / F 76. All of these components are connected to an internal bus 77, and are configured to enable data to be exchanged between the components. Note that "CPU" is an abbreviation for Central Processing Unit. Also, "I / F" is an abbreviation for Interface.
[0066] The CPU 71 controls each component of the information processing device 70 by, for example, executing a predetermined program using the memory 72, thereby enabling the provision of the functions of each component of the software development support device 100.
[0067] The input device 73 is, for example, a keyboard or a pointing device for inputting instructions.
[0068] The display device 74 is used, for example, to display and output various types of information.
[0069] The auxiliary storage device 75 is, for example, a flash memory or a hard disk drive. Programs and data are stored in the auxiliary storage device 75, and the information processing device 70 can load them into the memory 72 for use.
[0070] The communication I / F 76 transmits and receives data via a communication network (not shown) according to instructions sent from the CPU 71 as necessary, for example.
[0071] When a software development support device 100 is constructed using an information processing device 70, a CPU 71 provides the functions of an extraction unit 102 and a judgment unit 103, a display device 74 provides the function of an output unit 104, and an auxiliary memory device 75 provides the function of a memory unit 101.
[0072] When the software development support device 100 is configured using the information processing device 70, the information processing device 70 does not need to include all of the components shown in Fig. 9, and some of the components may be omitted depending on the application or conditions. For example, when the software development support device 100 is configured using the information processing device 70, the communication I / F 76 may be omitted.
[0073] Next, the software development support process performed by the software development support device 100 will be described.
[0074] 10A and 10B are flowcharts showing the processing contents of an example of a software development support process. When the software development support device 100 is configured using an information processing device 70 having the hardware configuration shown in FIG. 9, a software development support program describing this process may be executed by the CPU 71.
[0075] When the software development support process is started, first, in S301 of FIG. 10A, the extraction unit 102 acquires one of the source files 40 input to the software development support device 100.
[0076] Next, in S302, a process is performed in which the source file classification list 50 input to the software development support device 100 is referenced to obtain a classification identifier associated with the file name of the source file 40 obtained by the process of S301 most recently executed. This process is performed by the determination unit 103.
[0077] In S303, the extraction unit 102 performs a process of extracting one block that declares "unsafe" from the source code stored in the source file 40 acquired by the process of S301 that was most recently executed.
[0078] In S304, the determination unit 103 performs a process of acquiring one line of description in the block extracted by the process of S303 which has been most recently executed.
[0079] In S305, the judgment unit 103 performs a process of acquiring one rule definition (a combination of “rule” and “attached condition” in the example of FIG. 6B) contained in the unsafe description rule 10 input to the software development support device 100.
[0080] In S306, the determination unit 103 performs a process of determining whether or not the description acquired by the most recently executed process of S304 corresponds to the definition of the unsafe description rule 10 acquired by the most recently executed process of S305. In this determination process, when it is determined that the description acquired by the process of S304 corresponds to the definition of the unsafe description rule 10 acquired by the process of S305 (when the determination result is YES), the process proceeds to S307. On the other hand, in this determination process, when it is determined that the description acquired by the process of S304 does not correspond to the definition of the unsafe description rule 10 acquired by the process of S305 (when the determination result is NO), the process proceeds to S310 in FIG. 10B.
[0081] In S307, the determination unit 103 performs a process of referring to the unsafe description rule 10 to determine whether the description acquired in the most recently executed process of S304 is prohibited or not.
[0082] The determination process of S307 is performed based on the software classification of the source file 40 obtained by the most recently executed process of S301. The software classification of the source file 40 is specified by the classification identifier obtained by the most recently executed process of S302. Therefore, in this determination process, in the unsafe description rule 10 illustrated in Fig. 6B, it is determined whether a description in the definition obtained by the most recently executed process of S305 is not permitted for software of the classification identified by the classification identifier.
[0083] In the judgment process of S307, if it is judged that the description acquired by the process of S304 is not permitted in the classification of the source file 40 acquired by the process of S301 (if the judgment result is YES), the process proceeds to S308. On the other hand, if it is judged that the description acquired by the process of S304 is permitted in the classification of the source file 40 acquired by the process of S301 (if the judgment result is NO), the process proceeds to S309.
[0084] In S308, the output unit 104 outputs information about the description determined to be disallowed by the determination process in S307 to the violation list, and then the process proceeds to S310 in Fig. 10B. On the other hand, in S309, the output unit 104 outputs information about the description determined to be allowed by the determination process in S307 to the permission list, and then the process proceeds to S310 in Fig. 10B.
[0085] The violation list and the permission list are specific examples of the judgment result list 60 shown in Fig. 3. Fig. 11 shows an example of the violation list, and Fig. 12 shows an example of the permission list.
[0086] As can be seen by comparing Figures 11 and 12, the violation list and the permission list have a similar structure, and have the following items: "file name," "classification identifier," "rule number," and "line number."
[0087] The "file name" item indicates the file name of the source file 40 obtained by the most recently executed process of S301.
[0088] The "classification identifier" item indicates the classification identifier obtained by the most recently executed process of S302.
[0089] The "Rule Number" item shows information identifying the rule definition obtained from unsafe description rule 10 by the most recently executed processing of S305 (in the example of Figure 6B, the "Rule No." information associated with the obtained rule definition).
[0090] The "line number" item indicates the line number that identifies the description position in source file 40 of the description acquired by the most recently executed process of S304.
[0091] In the processes of S308 and S309, the output unit 104 stores the information of each line described above in the violation list and the permission list, respectively.
[0092] Next, in S310 of Fig. 10B, the determination unit 103 performs a process of determining whether or not all rule definitions included in the unsafe description rule 10 have been acquired by the process of S305. In this determination process, when it is determined that all rule definitions have been acquired (when the determination result is YES), the process proceeds to S311. On the other hand, in this determination process, when it is determined that an unacquired rule definition remains (when the determination result is NO), the process returns to S305, and the determination unit 103 performs a process of acquiring one unacquired rule definition, and then the processes from S306 onwards are performed again.
[0093] In S311, the determination unit 103 performs a process of determining whether or not all of the descriptions in the block extracted by the most recently executed process of S303 have been acquired by the process of S304. In this determination process, when it is determined that all of the descriptions in the block have been acquired (when the determination result is YES), the process proceeds to S312. On the other hand, in this determination process, when it is determined that unacquired descriptions remain in the block (when the determination result is NO), the process returns to S304, where the determination unit 103 performs a process of acquiring one line of unacquired descriptions, and then the processes from S305 onwards are performed again.
[0094] In S312, extraction unit 102 performs a process of judging whether or not all blocks declaring unsafe have been extracted by the process of S303 from the source code stored in source file 40 acquired by the process of S301 executed most recently. If it is judged in this judgment process that all of the blocks have been extracted (if the judgment result is YES), the process proceeds to S313. On the other hand, if it is judged in this judgment process that an unextracted description remains in the block (if the judgment result is NO), the process returns to S303, and extraction unit 102 performs a process of extracting one of the unextracted blocks. Then, the processes from S304 onwards are performed again.
[0095] In S313, the extraction unit 102 performs a process of judging whether or not all of the source files 40 have been acquired by the process of S301. In this judgment process, if it is judged that all of the source files 40 have been acquired (if the judgment result is YES), the software development support process is terminated. On the other hand, in this judgment process, if it is judged that an unacquired source file 40 remains (if the judgment result is NO), the process returns to S301, and the extraction unit 102 performs a process of acquiring one of the unacquired source files 40. Then, the processes from S302 onwards are performed again.
[0096] The above-mentioned processing is the software development support processing.
[0097] Next, a more detailed procedure for correcting a program, which is the procedure of S203 in the rule check shown in Fig. 3, will be described with reference to Fig. 13. Fig. 13 is a diagram showing an example of a program correction procedure.
[0098] This procedure is started when the software development support process described above by the software development support device 100 ends, and first, a violation list created by the software development support device 100, as shown in Fig. 11, is acquired (S401). Then, it is determined whether or not there is a description that violates a description rule, which is a description that is prohibited by the unsafe description rule 10 (S402), and if there is no violating description (if S402 is NO), this program correction procedure ends.
[0099] On the other hand, if there is a description that violates the description rules and information about that description is shown in the violation list (if S402 is YES), the violation part in the source file 40 identified by that information is corrected (S403).
[0100] After that, the Rust language compiler is executed on the PC to compile the source file 40 after the violation has been corrected (S404).
[0101] It is determined whether an error is detected in compiling this program (S405). If an error is detected (YES in S405), the programmer re-corrects the program to eliminate the error (S406), and then the process returns to S404, where the process from compilation onwards is carried out again for the corrected program.
[0102] On the other hand, if no error is detected in compiling the program (NO in S405), it is re-determined whether the description in the block declaring unsafe in the program complies with the description rules (S407). In this re-determination, the source file 40 of the program is input to the software development support device 100, and the above-mentioned software development support process is performed. After that, the above-mentioned procedure from S401 onwards is repeated using the result of this process.
[0103] The program correction according to the procedure shown in FIG. 13 is carried out in the manner described above.
[0104] In the embodiment described above, description rules permitted in descriptions in an unsafe declaration block are defined in advance, and the software development support device 100 checks the source code of a program written in the Rust language according to these description rules. If a violation of a rule is detected by this check, the programmer makes a correction to eliminate the violation. Therefore, according to this embodiment, the burden of the work of the programmer to ensure memory safety is reduced.
[0105] Although the disclosed embodiments and their advantages have been described in detail above, it will be appreciated that those skilled in the art may make various modifications, additions, and omissions therein without departing from the scope of the present invention as clearly set forth in the claims.
[0106] For example, the software classification definition 20 illustrated in FIG. 4 defines classification according to the hierarchical structure of software, but the number of hierarchical levels in the software hierarchical structure does not have to be three as illustrated in FIG. [Explanation of symbols]
[0107] 10 Unsafe Description Rules 20 Software Classification Definitions 30 Unsafe Description Rule Definition 40 Source files 50 Source File Classification List 60 Judgment Result List 70 Information processing equipment 71 CPU 72 Memory 73 Input Devices 74 Display device 75 Auxiliary storage device 76 Communication I / F 77 Internal Bus 100 Software development support device 101 Storage section 102 Extraction part 103 Judgment section 104 Output section
Claims
1. A memory unit that stores description rules that define what is permitted in blocks that declare unsafe among descriptions written in the Rust language; An extractor that extracts blocks that are declared as unsafe from the source code of the target software written in the Rust language; a determination unit that determines whether or not a description included in the extracted block is permitted in accordance with the description rule; an output unit that outputs information that identifies the description that has been determined to be not permitted by the determination from the source code; A software development support device comprising:
2. The description rules define descriptions that are permitted in a block that declares unsafe among descriptions written in the Rust language for each type of software in which the block that declares unsafe is used, The determination unit determines whether or not the description included in the extracted block is permitted in accordance with the description rule corresponding to the type of the target software.
2. The software development support device according to claim 1.
3. the description rule is defined for each layer of a software hierarchy of the software in which the block declared as unsafe is used, The determination unit determines whether or not the description included in the extracted block is permitted in accordance with the description rule corresponding to the software layer of the target software.
3. The software development support device according to claim 2, wherein:
4. The software development support device according to claim 1, characterized in that the description rules include a definition that is a combination of description rules that are permitted only within a block that declares unsafe in the Rust language and additional conditions for the description rules.
5. 5. The software development support device according to claim 1, wherein the output unit further outputs information for identifying, from the source code, a description that has been determined to be permitted by the determination.
6. Extract blocks containing unsafe declarations from the source code of the target software written in the Rust language, A determination is made as to whether or not the description contained in the extracted block is permitted in accordance with a description rule that defines the description permitted in the block that declares unsafe among descriptions written in the Rust language; outputting information for identifying the description determined to be not permitted from the source code; A software development support method, comprising the steps of: executing processing by a computer.
7. Extract blocks containing unsafe declarations from the source code of the target software written in the Rust language, A determination is made as to whether or not the description contained in the extracted block is permitted in accordance with a description rule that defines the description permitted in the block that declares unsafe among descriptions written in the Rust language; outputting information for identifying the description determined to be not permitted from the source code; A software development support program that causes a computer to execute a process.
Citation Information
Patent Citations
Method and support system for analyzing source code
JP2010198522A
