CN116225905A - Air judgment processing detection method, air judgment processing model training device and medium - Google Patents
Air judgment processing detection method, air judgment processing model training device and medium Download PDFInfo
- Publication number
- CN116225905A CN116225905A CN202211720722.5A CN202211720722A CN116225905A CN 116225905 A CN116225905 A CN 116225905A CN 202211720722 A CN202211720722 A CN 202211720722A CN 116225905 A CN116225905 A CN 116225905A
- Authority
- CN
- China
- Prior art keywords
- intelligent pointer
- pointer node
- standard
- detected
- node
- 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.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3604—Analysis of software for verifying properties of programs
- G06F11/3608—Analysis of software for verifying properties of programs using formal methods, e.g. model checking, abstract interpretation
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Machine Translation (AREA)
Abstract
The disclosure relates to a method for detecting air judgment processing, a method for training an air judgment processing model, a device and a medium, wherein the method comprises the following steps: generating an abstract syntax tree file from a source code file to be detected by adopting a lexical analyzer; extracting at least one intelligent pointer node from the abstract syntax tree file; step S1 is executed for each intelligent pointer node so as to determine the intelligent pointer node which does not perform null judgment processing; the step S1 comprises the following steps: stripping the current intelligent pointer node to obtain a stripped current intelligent pointer node; replacing the call object in the stripped current intelligent pointer node with a standard object to obtain an intelligent pointer node to be detected; matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement; and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing.
Description
Technical Field
The embodiment of the application relates to the technical field of computers. And more particularly, to a method for detecting a cavitation process, a method and apparatus for training a cavitation process model, and a computer-readable storage medium.
Background
Currently, no null pointer (null pointer) can exist in the process of writing a code file in software development, and once the null pointer exists, a program runs to the null pointer, and then crashes. During a crash of a null pointer exception, a code line that uses a null pointer variable is referred to as a null pointer crash code. Since there is a risk of causing program crash in the null pointer crash code, in order to avoid such a risk, it is generally required to perform a null judgment process, and the null judgment process generally includes: it is determined whether the value of the pointer variable is equal to null, if the value of the pointer variable is equal to null, the pointer variable is not used, and if it is not equal to null, the pointer variable is used.
However, in the process of writing a code file, the pointer is often forgotten to be subjected to the air-judging treatment, so that before the code file is executed, a manual check or a check tool is required to check whether the pointer which is not subjected to the air-judging treatment exists in the code file. The manual inspection mode is low in efficiency and easy to miss, and the existing inspection tool inspection mode cannot generally inspect whether the intelligent pointer in the code file is subjected to empty judgment.
Therefore, a method for automatically detecting whether the intelligent pointer is empty in the code file is needed.
Disclosure of Invention
In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present application provide a method for detecting cavitation processing, a method and apparatus for training cavitation processing model, and a computer readable storage medium, which can prevent program crash paralysis caused by that an intelligent pointer is empty.
In a first aspect, an embodiment of the present application provides a method for detecting empty judgment processing, including:
generating an abstract syntax tree file from a source code file to be detected by adopting a lexical analyzer;
extracting at least one intelligent pointer node from the abstract syntax tree file;
step S1 is executed for each intelligent pointer node so as to determine the intelligent pointer node which does not perform null judgment processing;
wherein, this step S1 includes:
stripping the current intelligent pointer node, removing statement or reference of the current intelligent pointer node, and obtaining the stripped current intelligent pointer node;
replacing the stripped calling object in the current intelligent pointer node with a standard object to obtain an intelligent pointer node to be detected;
Matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement;
and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing, wherein a calling object in each standard null operation statement is a standard object.
In a second aspect, an embodiment of the present application provides a training method for a detection model in air judgment processing, including:
constructing a void judgment processing detection model based on the void judgment processing detection method of the first aspect;
and respectively taking each target source code file in a plurality of target source code files marked with the manual checking record with the intelligent pointer not judged to be empty as the source code file to be detected, and training the judgment processing detection model to obtain a trained judgment processing detection model.
In a third aspect, an embodiment of the present application provides an empty judgment processing detection device, including: the device comprises a generation module, an extraction module and an execution module;
the generation module is used for generating an abstract syntax tree file from a source code file to be detected by adopting a lexical analyzer;
the extraction module is used for extracting at least one intelligent pointer node from the abstract syntax tree file generated by the generation module;
The execution module is used for executing step S1 aiming at each intelligent pointer node extracted by the extraction module so as to determine the intelligent pointer node which does not perform null judgment;
wherein, this step S1 includes:
stripping the current intelligent pointer node, removing statement or reference of the current intelligent pointer node, and obtaining the stripped current intelligent pointer node;
replacing the stripped calling object in the current intelligent pointer node with a standard object to obtain an intelligent pointer node to be detected;
matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement;
and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing, wherein a calling object in each standard null operation statement is a standard object.
In a fourth aspect, an embodiment of the present application provides a training device for detecting a model in air judgment processing, including: a building module and a training module;
the construction module is used for constructing a void judgment processing detection model by the void judgment processing detection method in the first aspect;
The training module is used for respectively taking each target source code file in a plurality of target source code files marked with the manual checking record of which the intelligent pointer is not empty as the source code file to be detected, and training the empty judgment processing detection model obtained by the construction module to obtain a trained empty judgment processing detection model.
In a fifth aspect, embodiments of the present application provide a computer-readable storage medium comprising: the computer readable storage medium stores thereon a computer program which, when executed by a processor, implements the cavitation process detection method as shown in the first aspect or the cavitation process detection model training method as shown in the second aspect.
In a sixth aspect, embodiments of the present application provide a computer program product comprising: the computer program product, when run on a computer, causes the computer to implement the void-handling detection method as shown in the first aspect or the void-handling detection model training method as shown in the second aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: in the embodiment of the application, the source code file to be detected is generated into an abstract syntax tree file by adopting a lexical analyzer; extracting at least one intelligent pointer node from the abstract syntax tree file; then stripping processing is carried out on each intelligent pointer node, and the stripped calling object in the current intelligent pointer node is replaced by a standard object to obtain an intelligent pointer node to be detected; then matching the intelligent pointer node to be detected with at least one standard null operation statement (the calling object in each standard null operation statement is a standard object); and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing. Therefore, the intelligent pointer node which does not perform the empty judgment processing in the source code file to be detected can be effectively judged, so that the situation that the intelligent pointer is empty due to the fact that the empty judgment processing is not performed, and a program runs to the empty intelligent pointer to break down is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present application or the implementation in the related art, a brief description will be given below of the drawings required for the embodiments or the related art descriptions, and it is apparent that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings for those of ordinary skill in the art.
FIG. 1 illustrates one of the flow diagrams of a void-determination process detection method in accordance with some embodiments;
FIG. 2 illustrates a second flow diagram of a method of detecting a void determination process in accordance with some embodiments;
FIG. 3 illustrates a third flow diagram of a void determination process detection method in accordance with some embodiments;
FIG. 4 illustrates a fourth flow diagram of a void determination process detection method in accordance with some embodiments;
FIG. 5 illustrates a fifth flow diagram of a void determination process detection method in accordance with some embodiments;
FIG. 6 illustrates a sixth flow diagram of a void determination process detection method in accordance with some embodiments;
FIG. 7 illustrates one of the flow diagrams of a void handling detection model training method in accordance with some embodiments;
FIG. 8 illustrates a second flow diagram of a void handling detection model training method in accordance with some embodiments;
FIG. 9 illustrates a frame diagram of a void handling detection device in accordance with some embodiments;
FIG. 10 illustrates a frame diagram of a void handling detection model training apparatus in accordance with some embodiments;
FIG. 11 illustrates a computer device hardware schematic, according to some embodiments.
Detailed Description
For purposes of clarity and implementation of the present application, the following description will make clear and complete descriptions of exemplary implementations of the present application with reference to the accompanying drawings in which exemplary implementations of the present application are illustrated, it being apparent that the exemplary implementations described are only some, but not all, of the examples of the present application.
It should be noted that the brief description of the terms in the present application is only for convenience in understanding the embodiments described below, and is not intended to limit the embodiments of the present application. Unless otherwise indicated, these terms should be construed in their ordinary and customary meaning.
The terms "first," second, "" third and the like in the description and in the claims and in the above-described figures are used for distinguishing between similar or similar objects or entities and not necessarily for limiting a particular order or sequence, unless otherwise indicated. It is to be understood that the terms so used are interchangeable under appropriate circumstances.
The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a product or apparatus that comprises a list of elements is not necessarily limited to all elements explicitly listed, but may include other elements not expressly listed or inherent to such product or apparatus.
Next, some of the terms and related techniques referred to in this application are explained for easy understanding by those skilled in the art.
The abstract syntax tree (abstract syntax code, AST) is a tree representation of the abstract syntax structure of the source code, each node on the tree representing a structure in the source code, which is abstract because the abstract syntax tree does not represent every detail of the actual syntax appearance, for example nested brackets are implicit in the tree structure and are not presented in the form of nodes. The abstract syntax tree does not depend on the grammar of the source language, that is, the context used in the grammar analysis stage is free of grammar, because when grammar is written, equivalent conversion (elimination of left recursion, backtracking, ambiguity, etc.) is often performed on the grammar, so that some redundant components are introduced into grammar analysis, which adversely affects the subsequent stage and even causes confusion of the stage. Therefore, many compilers often independently construct parse trees to create a clear interface for the front-end and the back-end.
It is known that each program has a pool of memory, in addition to static memory and stack memory, which is referred to as free space or heap. The program is used to heap dynamically allocated objects, i.e. those allocated at program runtime, and when dynamic objects are no longer used, our code must explicitly destroy them.
In c++, dynamic memory management is done with a pair of operators: new and delete, new, allocating a block of space for an object in dynamic memory and returning a pointer to the object, delete: and (3) pointing to a dynamic exclusive pointer, destroying the object and releasing the memory associated with the object.
Dynamic memory management often suffers from two problems: one is forgetting to release the memory, which can cause memory leakage; one is that if a pointer is released to reference memory, a pointer referencing illegal memory is generated.
In order to make use of dynamic memory easier (safer), the concept of intelligent pointers was introduced. The intelligent pointer behaves like a conventional pointer, the important difference being that it is responsible for automatically releasing the pointed object. The difference between the two intelligent pointers provided by the standard library is that the method for managing the bottom pointer is different, the shared_ptr allows multiple pointers to point to the same object, and the unique_ptr "monopolizes" the pointed object. The standard library also defines a companion class named weak_ptr, which is a weak reference pointing to objects managed by shared_ptr, and these three intelligent pointers are defined in the memory header file.
The role of the intelligent pointer is to manage one pointer, since there are the following situations: the space of the application forgets to release when the function ends, causing memory leakage. The use of an intelligent pointer can largely avoid this problem because the intelligent pointer is a class, and when the scope of an instance object of the class is exceeded, the object's destructor function is automatically called, and the destructor function automatically releases resources. The intelligent pointer has the function principle that the memory space is automatically released when the function is finished, and the memory space is not required to be manually released.
A null pointer is maintained in the default initialized smart pointer. The intelligent pointer is used in a similar way to a common pointer, and the intelligent pointer is used for dereferencing an object pointed by the intelligent pointer, and detecting whether the intelligent pointer is empty or not in a condition judgment. Dereferencing is returning a corresponding object in the memory address.
Null pointer: a pointer refers to a variable whose value is the memory address, and a null pointer refers to a pointer variable whose memory address is null.
Null pointer determination operation: the method refers to an operation of judging whether the memory address is empty or not, and is abbreviated as empty judgment.
Null pointer exception crashes or null pointer errors (NullPointer Exception): meaning that an object is declared, but the object is not properly initialized and a program crash is not determined in error.
The NULL pointer related detectors such as forward_null and null_return in the existing coverage detectors cannot effectively detect the condition that the intelligent pointer is NULL. Such as: boost: shared_ptr < lo:: port: ciModule > CiMod = m_portFactoy- > getCiModule ();
ciMod->suspendCiCam();
if m_portfactor- > getCiModule () returns a null object, then ciMod is a null pointer, and the following references cause dead halt, and the risk is not controllable.
The open source tool cppcheck, tscacode, etc. has no check for intelligent pointers. Therefore, a method for checking whether to empty the intelligent pointer is needed.
In order to solve the technical problems, in the embodiment of the application, an abstract syntax tree file is generated by adopting a lexical analyzer to generate a source code file to be detected; extracting at least one intelligent pointer node from the abstract syntax tree file; then stripping processing is carried out on each intelligent pointer node, and the stripped calling object in the current intelligent pointer node is replaced by a standard object to obtain an intelligent pointer node to be detected; then matching the intelligent pointer node to be detected with at least one standard null operation statement (the calling object in each standard null operation statement is a standard object); and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing. Therefore, the intelligent pointer node which does not perform the empty judgment processing in the source code file to be detected can be effectively judged, so that the situation that the intelligent pointer is empty due to the fact that the empty judgment processing is not performed, and a program runs to the empty intelligent pointer to break down is avoided.
The air judgment processing detection method in the embodiment of the application can be performed in electronic equipment, and the electronic equipment can comprise intelligent mobile phones, desktop computers, tablet computers, notebook computers, digital assistants, intelligent wearable equipment, vehicle-mounted equipment, sound boxes, televisions, robots and other entity equipment, and can also comprise software running in the entity equipment, such as virtual machines and the like. The air judgment processing detection method can also be carried out in a server, and the server can comprise a server which independently operates, or a distributed server or a server cluster formed by a plurality of servers.
Fig. 1 is a flowchart of steps for implementing a method for detecting a cavitation process according to one or more embodiments of the present invention, where an execution subject of the method for detecting a cavitation process may be a server or an electronic device, or may be a functional module or a functional entity in the server or the electronic device capable of implementing the method for detecting a cavitation process, which is not limited herein. In the embodiment of the present application, taking the execution body as a server as an example for exemplary explanation, the empty judgment processing detection method may include S101 to S103 described below.
S101, generating an abstract syntax tree file from a source code file to be detected by adopting a lexical analyzer.
S102, at least one intelligent pointer node is extracted from the abstract syntax tree file.
Each node in the abstract syntax tree file may be traversed to determine at least one intelligent pointer node.
S103, executing step S1 for each intelligent pointer node to determine the intelligent pointer node which does not perform null judgment processing.
As shown in fig. 2, the step S1 includes:
s11, stripping the current intelligent pointer node, and removing statement or reference of the current intelligent pointer node to obtain the stripped current intelligent pointer node.
It can be appreciated that the addressOf or castoperater in the current intelligent pointer node is stripped off, and the use type (dereferenced, invoked) statement in the intelligent pointer node is extracted.
S12, replacing the stripped calling object in the current intelligent pointer node with a standard object to obtain the intelligent pointer node to be detected.
It can be understood that the called object behind the "-" or "x" number in the stripped current intelligent pointer node is replaced by a standard object, so as to obtain the intelligent pointer node to be detected, namely the abstract extraction pointer statement, which is consistent with the standard null operation statement form.
And S13, matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement.
It can be understood that whether the to-be-detected intelligent pointer node is matched with the empty judgment operation statement consistent with each standard empty judgment operation statement is matched.
In some embodiments of the present application, the at least one standard nulling operation statement includes: if (ps |=null), if (ps), if (|ps), if (null+=ps), if (ps+=null), if (|ps. Get ()).
Where ps represents the name of the intelligent pointer, which can be arbitrarily defined, null or Null is indicated as Null. The at least one standard judgment operation statement is 7 standard judgment operation statements obtained after multiple sampling. Matching the 7 standard null operation sentences with the intelligent pointer node to be detected, and successfully indicating that the current intelligent pointer node is subjected to null judgment; and if the current intelligent pointer node is not matched, indicating that the current intelligent pointer node is empty judgment and alarming.
In some embodiments of the present application, the at least one standard nulling operation statement may further include: if (isEmpty (ps)).
The if (isEmpty (ps)) is a standard null operation statement in the 8 th step, and is a type of null judgment by using an isEmpty function. If the intelligent pointer node to be detected is not matched with the first 7 standard empty judgment operation sentences, and when the functional view appears at the back, the intelligent pointer node to be detected can be matched with if (isEmpty (ps)).
The at least one standard nulling operation statement may further include other standard nulling operation statements, which may specifically be determined according to actual situations, and is not limited herein.
Illustratively, in S12, the calling object in the current intelligent pointer node is replaced by the standard object, that is, the calling object is replaced by ps, so that the current intelligent pointer node consistent with the standard null operation statement form is abstracted.
S14, under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing.
The calling object in each standard empty judgment operation statement is a standard object.
It can be understood that if the intelligent pointer node to be detected does not include each standard null operation statement in at least one standard null operation statement, the current intelligent pointer node is indicated not to perform null processing; if the intelligent pointer node to be detected comprises one standard null operation statement in at least one standard null operation statement, the current intelligent pointer node is indicated to have undergone null judgment.
In the embodiment of the application, the source code file to be detected is generated into an abstract syntax tree file by adopting a lexical analyzer; extracting at least one intelligent pointer node from the abstract syntax tree file; then stripping processing is carried out on each intelligent pointer node, and the stripped calling object in the current intelligent pointer node is replaced by a standard object to obtain an intelligent pointer node to be detected; then matching the intelligent pointer node to be detected with at least one standard null operation statement (the calling object in each standard null operation statement is a standard object); and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing. Therefore, the intelligent pointer node which does not perform the empty judgment processing in the source code file to be detected can be effectively judged, so that the situation that the intelligent pointer is empty due to the fact that the empty judgment processing is not performed, and a program runs to the empty intelligent pointer to break down is avoided.
In some embodiments of the present application, as shown in fig. 3 in conjunction with fig. 2, the above S14 may be specifically implemented by the following S14a and S14 b.
S14a, determining whether the intelligent pointer node to be detected is dereferenced or not under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement.
And S14b, under the condition that the intelligent pointer node to be detected is dereferenced, determining that the current intelligent pointer node does not perform null judgment processing.
In the embodiment of the application, if one intelligent pointer is not dereferenced, the program is not crashed even if the intelligent pointer is empty, so that the intelligent pointer which is not dereferenced is not concerned, and whether empty judgment processing is performed is not needed. In this way, under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement and the intelligent pointer node to be detected is dereferenced, the current intelligent pointer node is determined to not perform null judgment. The number of alarms which are not subjected to the empty judgment treatment can be reduced, the difficulty of the open personnel in alarm analysis is reduced, and the false alarm rate is reduced.
In some embodiments of the present application, as shown in fig. 4, the above S13 may specifically be S13a to S13c described below.
And S13a, matching the intelligent pointer node to be detected with the current standard empty judgment operation statement.
And S13b, under the condition that the intelligent pointer node to be detected is matched with the current standard null operation statement, stopping the matching operation between the intelligent pointer node to be detected and the subsequent standard null operation statement, and executing the step S1 for the next intelligent pointer node.
And S13c, under the condition that the intelligent pointer node to be detected is not matched with the current standard null operation statement, matching the intelligent pointer node to be detected with the next standard null operation statement.
The current standard null operation sentence and the next standard null operation sentence are two adjacent standard null operation sentences in the at least one standard null operation sentence, and in the at least one standard null operation sentence, the current standard null operation sentence is arranged in front of the next standard null operation sentence, and the arrangement sequence of the at least one standard null operation sentence is determined according to the counted use frequency of the corresponding standard null operation sentence.
In some embodiments of the present application, the arrangement sequence of the at least one standard nulling operation statement may be dynamically adjusted according to the counted real-time frequency of use of each standard nulling operation statement.
It can be understood that, according to the arrangement sequence of the at least one standard null operation sentence, a standard null operation sentence is sequentially obtained from the at least one standard null operation sentence as the current standard null operation sentence, and the above steps S13a to S13c are executed to determine whether the to-be-detected intelligent pointer node matches with one standard null operation sentence in the at least one standard null operation sentence.
The higher the use frequency of one standard null operation statement is counted, the more important the standard null operation statement is, the higher the priority of the standard null operation statement with high use frequency is, namely the intelligent pointer node to be detected is preferentially matched with the standard null operation statement with high use frequency, and the matching efficiency can be improved.
In some embodiments of the present application, as shown in fig. 5 in conjunction with fig. 1, the above S102 may be specifically implemented by the following S102 a.
S102a, extracting intelligent pointer nodes with pointers matched with target intelligent pointers in the source code file to be detected from the abstract syntax tree file, and obtaining at least one intelligent pointer node.
Wherein the target smart pointer may be at least one of: the smart_ptr, boost are shared_ptr, auto_ptr, shared_ptr, weak_ptr, unique_ptr, and the target smart pointer may be other smart pointers, which are not limited herein.
Illustratively, a source code file of a manual checking record marked as intelligent pointer not empty is collected in the gerrit at regular intervals, a source code file of which the intelligent pointer of false alarm (won't fixed) is empty is collected in the static code checking defect management platform at regular intervals, and the source code file of which the intelligent pointer of false alarm (won't fixed) is empty is collected in the static code checking defect management platform at regular intervals is screened out from the source code file of the manual checking record marked as intelligent pointer not empty, so as to obtain a plurality of source code files to be detected. Generating an abstract syntax tree file from a source code file to be detected, extracting pointer names after the gerit and static code inspection platform are marked as smart_ptr, or matching pointer names defined by shared_ptr with corresponding names in the abstract syntax tree file, and storing leaf nodes successfully matched in the abstract syntax tree file to obtain an intelligent pointer node.
In the embodiment of the application, the intelligent pointer node with the pointer matched with the target intelligent pointer in the source code file to be detected is extracted from the abstract syntax tree file, so that the at least one intelligent pointer node is obtained, and the extraction efficiency of the intelligent pointer node can be improved.
In some embodiments of the present application, referring to fig. 5, as shown in fig. 6, after S103, the method for detecting the empty judgment processing provided in the embodiments of the present application may further include S104 described below.
S104, reporting the indication information of the non-empty judgment, wherein the indication information of the non-empty judgment is used for indicating that the current intelligent pointer node does not perform the empty judgment.
In the embodiment of the application, by reporting the indication information of non-empty judgment, a developer can timely check the source code file to be detected according to the indication information of non-empty judgment so as to judge whether the empty judgment is not performed, and under the condition that the empty judgment is not performed, the source code file to be checked can be timely modified, so that the modified source code file does not have an empty intelligent pointer, and the source code can be ensured not to crash and paralysis due to the fact that the empty intelligent pointer is operated in the operation process.
According to the embodiment of the application, the requirement that whether the intelligent pointer is empty or not needs to be checked before the intelligent pointer is unreferenced is met, the intelligent pointer empty pointer application problem is exposed in advance, and the quality risk and the false alarm rate are reduced.
The training method of the air judgment processing detection model in the embodiment of the application can be performed in electronic equipment, wherein the electronic equipment can comprise intelligent mobile phones, desktop computers, tablet computers, notebook computers, digital assistants, intelligent wearable equipment, vehicle-mounted equipment, sound boxes, televisions, robots and other types of entity equipment, and can also comprise software running in the entity equipment, such as virtual machines and the like. The air judgment processing detection model training method can also be carried out in a server, and the server can comprise a server which independently operates, or a distributed server or a server cluster formed by a plurality of servers.
Fig. 7 is a flowchart of steps for implementing a method for training a diagnostic test model according to one or more embodiments of the present invention, where an execution body of the method for training a diagnostic test model may be a server or an electronic device, or may be a functional module or a functional entity in the server or the electronic device that can implement the method for training a diagnostic test model, which is not limited herein. In the embodiment of the present application, taking the execution body as a server as an example for illustration, the method for training the detection model in the air judgment processing may include S201 to S202 described below.
S201, constructing a judgment processing detection model based on the judgment processing detection method.
S202, respectively taking each target source code file in a plurality of target source code files marked with the manual checking record that the intelligent pointer is not empty as the source code file to be detected, and training the empty judging processing detection model to obtain a trained empty judging processing detection model.
In this embodiment, the air-judging process detection model is trained based on a plurality of target source code files, in the training process, according to the judgment accuracy of the air-judging process detection model on the intelligent pointer which does not perform air-judging process in each target source code, at least one of the processes of stripping process, standard object replacement, standard air-judging operation statement matching (may include modification, deletion, addition, sequence adjustment, and the like of the standard air-judging operation statement), dereferencing judgment and the like of the air-judging process detection model is adjusted, so as to obtain a trained air-judging process detection model with higher judgment accuracy and higher judgment efficiency on the intelligent pointer which does not perform air-judging process in each target source code, and the specific process can be determined according to actual conditions.
According to the embodiment of the application, the intelligent pointer which is reported by the empty judgment processing detection model and is not subjected to the empty judgment processing can be checked, whether the false alarm is caused or not is analyzed, and then the closed loop correction is carried out on the empty judgment processing detection model, so that the trained empty judgment processing detection model is obtained.
In the embodiment of the application, the detection accuracy and the detection efficiency of whether the intelligent pointer of the source code is subjected to the null judgment processing can be improved by constructing and training the null judgment processing detection model.
In some embodiments of the present application, as shown in fig. 8 in conjunction with fig. 7, before S202, the training method for the empty handling detection model provided in the embodiments of the present application may further include S203 described below.
S203, acquiring the plurality of target source code files, wherein each target source code file is a source code file of a collected manual check record marked as the intelligent pointer is not empty, and each target source code file is not a source code file marked as the intelligent pointer with erroneous judgment is empty.
In the embodiment of the application, the collected source code files marked with erroneous judgment are screened out from all the source code files marked with the non-judgment-empty manual check records of the intelligent pointers, so that the obtained manual check records marked with the non-judgment-empty intelligent pointers in the plurality of target source code files are accurate, further training of the judgment-empty processing detection model is facilitated, and the accuracy of the judgment-empty processing detection model can be improved.
Illustratively, periodically collecting source code files of manual check records marked as intelligent pointers not empty in a gerrit; the source code files with the intelligent pointers of the won't fixed empty are collected in the static code inspection defect management platform regularly. And screening out the source code files in which the intelligent pointers of the won't fixed are empty in the static code inspection defect management platform periodically from the source code files of the manual inspection records marked as the intelligent pointers are not empty in the gerrit, so as to obtain a plurality of target source code files.
In some embodiments of the present application, each target source code file may also be a collected source code file marked as a manual check record with an intelligent pointer not empty, where the source code file with the erroneous judgment is not removed, and may specifically be determined according to an actual situation, which is not limited herein.
In the embodiment of the application, the trained empty judgment processing detection model can be embedded into a currently used static code inspection tool platform or compiler to enable to be effective.
Fig. 9 is a block diagram of a device for detecting empty handling according to an embodiment of the present disclosure, and as shown in fig. 9, the device includes: a generation module 301, an extraction module 302 and an execution module 303; wherein,,
The generating module 301 is configured to generate an abstract syntax tree file from a source code file to be detected by using a lexical analyzer; the extracting module 302 is configured to extract at least one intelligent pointer node from the abstract syntax tree file generated by the generating module 301; the executing module 303 is configured to execute step S1 for each intelligent pointer node extracted by the extracting module 302, so as to determine an intelligent pointer node that does not perform null judgment processing; wherein, this step S1 includes: stripping the current intelligent pointer node, removing statement or reference of the current intelligent pointer node, and obtaining the stripped current intelligent pointer node; replacing the stripped calling object in the current intelligent pointer node with a standard object to obtain an intelligent pointer node to be detected; matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement; and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing, wherein a calling object in each standard null operation statement is a standard object.
In some embodiments of the present application, the executing module 303 is specifically configured to determine whether the to-be-detected intelligent pointer node is dereferenced if the to-be-detected intelligent pointer node is not matched with each standard null operation statement in at least one standard null operation statement; and under the condition that the intelligent pointer node to be detected is dereferenced, determining that the current intelligent pointer node does not perform null judgment.
In some embodiments of the present application, the execution module 303 is specifically configured to match the to-be-detected intelligent pointer node with a current standard null operation statement; under the condition that the intelligent pointer node to be detected is matched with the current standard null operation statement, stopping the matching operation between the intelligent pointer node to be detected and the subsequent standard null operation statement, and executing the step S1 aiming at the next intelligent pointer node; under the condition that the intelligent pointer node to be detected is not matched with the current standard null operation statement, matching the intelligent pointer node to be detected with the next standard null operation statement; the current standard null operation sentence and the next standard null operation sentence are two adjacent standard null operation sentences in the at least one standard null operation sentence, and in the at least one standard null operation sentence, the current standard null operation sentence is arranged in front of the next standard null operation sentence, and the arrangement sequence of the at least one standard null operation sentence is determined according to the counted use frequency of the corresponding standard null operation sentence.
In some embodiments of the present application, the extracting module 302 is specifically configured to extract, from the abstract syntax tree file, an intelligent pointer node with a pointer matched with a target intelligent pointer in the source code file to be detected, so as to obtain the at least one intelligent pointer node.
In some embodiments of the present application, the apparatus further comprises: and the reporting module is used for reporting the non-empty judgment indication information which is used for indicating that the current intelligent pointer node does not perform the empty judgment processing after determining that the current intelligent pointer node does not perform the empty judgment processing under the condition that the intelligent pointer node to be detected is not matched with each standard empty judgment operation statement in at least one standard empty judgment operation statement.
In this embodiment of the present application, each module of the air-judging processing detection device may implement the air-judging processing detection method provided in the foregoing method embodiment, and may achieve the same technical effect, so that repetition is avoided, and no further description is provided herein.
Fig. 10 is a block diagram of a training device for detecting a model in air judgment processing according to an embodiment of the present disclosure, and as shown in fig. 10, the device includes: a building module 401 and a training module 402; wherein,,
the construction module 401 is configured to construct a void-determination processing detection model based on the void-determination processing detection method described above; the training module 402 is configured to train the empty judgment processing detection model obtained by the building module 401 by using each of a plurality of target source code files of the manual inspection record marked with the intelligent pointer and not empty judgment as the source code file to be detected, to obtain a trained empty judgment processing detection model.
In some embodiments of the present application, the apparatus further comprises: the acquisition module is used for acquiring the plurality of target source code files after training the empty judgment processing detection model to obtain the trained good empty judgment processing detection model, wherein each target source code file is a source code file of collected manual check records marked as intelligent pointers which are not empty judgment, and each target source code file is not a source code file marked as the collected intelligent pointers which are not empty judgment by mistake.
In this embodiment of the present application, each module of the training device for the air-judging processing detection model may implement the training method for the air-judging processing detection model provided in the foregoing method embodiment, and may achieve the same technical effect, so that repetition is avoided, and no further description is given here.
As shown in fig. 11, the embodiment of the present application further provides a computing device 500, where the computing device 500 may be the electronic device or the server described above. The computer device 500 includes: the processor 501, the memory 502, and the computer program stored in the memory 502 and capable of running on the processor 501, when executed by the processor 501, implement the processes executed by the above-mentioned air-judging process detection method or the air-judging process detection model training method, and achieve the same technical effects, and for avoiding repetition, the description is omitted herein.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements each process executed by the above-mentioned air-judging processing detection method or the air-judging processing detection model training method, and can achieve the same technical effect, so that repetition is avoided, and no further description is provided herein.
The computer readable storage medium may be a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, an optical disk, or the like.
The present invention provides a computer program product comprising: when the computer program product runs on a computer, the computer is enabled to realize the above air judgment processing detection method or the air judgment processing detection model training method.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.
The foregoing description, for purposes of explanation, has been presented in conjunction with specific embodiments. However, the illustrative discussions above are not intended to be exhaustive or to limit the embodiments to the precise forms disclosed above. Many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles and the practical application, to thereby enable others skilled in the art to best utilize the embodiments and various embodiments with various modifications as are suited to the particular use contemplated.
Claims (10)
1. The empty judgment processing detection method is characterized by comprising the following steps of:
generating an abstract syntax tree file from a source code file to be detected by adopting a lexical analyzer;
extracting at least one intelligent pointer node from the abstract syntax tree file;
step S1 is executed for each intelligent pointer node so as to determine the intelligent pointer node which does not perform null judgment processing;
wherein, the step S1 includes:
stripping the current intelligent pointer node, removing statement or reference of the current intelligent pointer node, and obtaining the stripped current intelligent pointer node;
replacing the stripped calling object in the current intelligent pointer node with a standard object to obtain an intelligent pointer node to be detected;
Matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement;
and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing, wherein a calling object in each standard null operation statement is a standard object.
2. The method according to claim 1, wherein the determining that the current intelligent pointer node does not perform the null process if the intelligent pointer node to be detected does not match each of at least one standard null operation statement comprises:
determining whether the intelligent pointer node to be detected is dereferenced under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement;
and under the condition that the intelligent pointer node to be detected is dereferenced, determining that the current intelligent pointer node does not perform null judgment processing.
3. The method of claim 1, wherein said matching the intelligent pointer node to be detected with at least one standard nulling statement comprises:
Matching the intelligent pointer node to be detected with a current standard empty judgment operation statement;
stopping the matching operation between the intelligent pointer node to be detected and the subsequent standard null operation statement under the condition that the intelligent pointer node to be detected is matched with the current standard null operation statement, and executing the step S1 aiming at the next intelligent pointer node;
under the condition that the intelligent pointer node to be detected is not matched with the current standard null operation statement, matching the intelligent pointer node to be detected with the next standard null operation statement;
the current standard null operation statement and the next standard null operation statement are two adjacent standard null operation statements in the at least one standard null operation statement, the current standard null operation statement is arranged in front of the next standard null operation statement in the at least one standard null operation statement, and the arrangement sequence of the at least one standard null operation statement is determined according to the counted use frequency of the corresponding standard null operation statement.
4. The method of claim 1, wherein said extracting at least one intelligent pointer node from said abstract syntax tree file comprises:
And extracting intelligent pointer nodes with pointers matched with the target intelligent pointers in the source code file to be detected from the abstract syntax tree file, and obtaining at least one intelligent pointer node.
5. The method according to any one of claims 1 to 4, wherein in a case where the to-be-detected intelligent pointer node does not match each of at least one standard nulling operation statement, after determining that the current intelligent pointer node is not nulled, the method further comprises:
and reporting the indication information of non-empty judgment, wherein the indication information of non-empty judgment is used for indicating that the current intelligent pointer node does not perform empty judgment.
6. The empty judgment processing detection model training method is characterized by comprising the following steps of:
constructing a void-determination process detection model based on the void-determination process detection method of any one of claims 1 to 5;
and respectively taking each target source code file in a plurality of target source code files marked with the manual checking record with the intelligent pointer not judged to be empty as the source code file to be detected, and training the judgment processing detection model to obtain a trained judgment processing detection model.
7. The method of claim 6, wherein the training the empty-handling detection model is further performed before the training the empty-handling detection model, the method further comprises:
and acquiring the plurality of target source code files, wherein each target source code file is a source code file of a collected manual check record marked as the intelligent pointer is not empty, and each target source code file is not a source code file marked as the intelligent pointer with the false judgment is empty.
8. An empty judgment processing detection device is characterized by comprising: the device comprises a generation module, an extraction module and an execution module;
the generation module is used for generating an abstract syntax tree file from the source code file to be detected by adopting a lexical analyzer;
the extraction module is used for extracting at least one intelligent pointer node from the abstract syntax tree file generated by the generation module;
the execution module is used for executing step S1 aiming at each intelligent pointer node extracted by the extraction module so as to determine the intelligent pointer node which does not perform null judgment processing;
wherein, the step S1 includes:
stripping the current intelligent pointer node, removing statement or reference of the current intelligent pointer node, and obtaining the stripped current intelligent pointer node;
Replacing the stripped calling object in the current intelligent pointer node with a standard object to obtain an intelligent pointer node to be detected;
matching the intelligent pointer node to be detected with at least one standard empty judgment operation statement;
and under the condition that the intelligent pointer node to be detected is not matched with each standard null operation statement in at least one standard null operation statement, determining that the current intelligent pointer node does not perform null processing, wherein a calling object in each standard null operation statement is a standard object.
9. The utility model provides a judge empty processing detection model trainer which characterized in that includes: a building module and a training module;
the construction module is used for constructing a cavitation treatment detection model based on the cavitation treatment detection method of any one of claims 1 to 5;
and the training module is used for respectively taking each target source code file in a plurality of target source code files marked with the manual checking record of which the intelligent pointer is not empty as the source code file to be detected, and training the empty judgment processing detection model obtained by the construction module to obtain a trained empty judgment processing detection model.
10. A computer-readable storage medium, comprising: a computer program is stored on a computer readable storage medium, which when executed by a processor implements the air-handling detection method according to any one of claims 1 to 5 or the air-handling detection model training method according to claim 6 or 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211720722.5A CN116225905A (en) | 2022-12-30 | 2022-12-30 | Air judgment processing detection method, air judgment processing model training device and medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202211720722.5A CN116225905A (en) | 2022-12-30 | 2022-12-30 | Air judgment processing detection method, air judgment processing model training device and medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN116225905A true CN116225905A (en) | 2023-06-06 |
Family
ID=86585095
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202211720722.5A Pending CN116225905A (en) | 2022-12-30 | 2022-12-30 | Air judgment processing detection method, air judgment processing model training device and medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116225905A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116860639A (en) * | 2023-07-11 | 2023-10-10 | 深圳依时货拉拉科技有限公司 | Memory leakage detection method, detection device, computer equipment and storage medium |
-
2022
- 2022-12-30 CN CN202211720722.5A patent/CN116225905A/en active Pending
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN116860639A (en) * | 2023-07-11 | 2023-10-10 | 深圳依时货拉拉科技有限公司 | Memory leakage detection method, detection device, computer equipment and storage medium |
| CN116860639B (en) * | 2023-07-11 | 2024-03-29 | 深圳依时货拉拉科技有限公司 | Memory leakage detection method, detection device, computer equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN104182320B (en) | A kind of method and device for monitoring memory overflow | |
| KR101979329B1 (en) | Method and apparatus for tracking security vulnerable input data of executable binaries thereof | |
| US8881107B2 (en) | Automatic memory leak detection | |
| US20130014093A1 (en) | Code inspection executing system for performing a code inspection of abap source codes | |
| US20090248721A1 (en) | System And Method for Stack Crawl Testing and Caching | |
| CN109583200A (en) | A kind of program exception analysis method based on dynamic tainting | |
| Kawrykow et al. | Improving api usage through automatic detection of redundant code | |
| Kirbas et al. | The relationship between evolutionary coupling and defects in large industrial software | |
| US10956298B2 (en) | Methods and apparatus to detect memory leaks in computing systems | |
| CN112069052A (en) | Abnormal object detection method, device, equipment and storage medium | |
| CN114579203A (en) | Script file checking method and device, electronic equipment and storage medium | |
| CN112445706A (en) | Program abnormal code acquisition method and device, electronic equipment and storage medium | |
| WO2022114486A1 (en) | Automated annotation examination system | |
| CN116225905A (en) | Air judgment processing detection method, air judgment processing model training device and medium | |
| US7698690B2 (en) | Identifying code that wastes time performing redundant computation | |
| CN112099838B (en) | Method, device and storage medium for determining version difference | |
| CN119322733A (en) | Code analysis method, device, equipment and storage medium based on artificial intelligence | |
| US20130152053A1 (en) | Computer memory access monitoring and error checking | |
| US11886589B2 (en) | Process wrapping method for evading anti-analysis of native codes, recording medium and device for performing the method | |
| CN113220302A (en) | Code defect static detection method and system for operating system of Internet of things | |
| US8930420B2 (en) | Orphan object tracking for objects having acquire-release semantics | |
| CN118940266A (en) | Data testing method and device, and electronic equipment | |
| Pomorova et al. | Assessment of the source code static analysis effectiveness for security requirements implementation into software developing process | |
| Yamaoka et al. | Comparing execution trace using merkle-tree to detect backward incompatibilities | |
| Hagberg et al. | Using Program Analysis to Identify the Use of Vulnerable Functions. |
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 |