Method, system and equipment for solving context-independent grammar reachability problem between program processes and storage medium
By constructing a hypergraph and generating a feasible path diagram of a hierarchical graph structure, the high false positive rate and complexity limitations of the context-free grammar reachability problem between program procedures in static analysis are solved, and accurate solutions and efficient queries are achieved, which is suitable for query-intensive application scenarios.
Patent Information
- Application Number
- CN202510517357.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-09-12
AI Technical Summary
Existing static analysis cannot accurately resolve the context-free grammar reachability problem between program procedures, resulting in a high false positive rate. In addition, existing technologies are limited in time complexity and space complexity when analyzing large programs, making it impossible to achieve an accurate solution.
Construct a hypergraph and solve the fact propagation summary to generate a hierarchical graph structure with empty application stack layers and non-empty application stack layers. Through the fact propagation summary set and the reachable propagation summary set, connect the feasible paths that conform to the context-free grammar rules, and output them as a feasible path graph.
It achieves the precise solution of the context-free grammar reachability problem between program procedures, reduces the time complexity, supports multiple queries, adapts to query-intensive application scenarios, and generates a graph model that can be used for subsequent analysis.
Smart Images

Figure CN120631728A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of program analysis, and in particular to a method, system, device, and storage medium for solving a context-free grammar reachability problem between program procedures. Background Art
[0002] Program analysis is a technique for automatically analyzing computer programs. Static analysis, a form of program analysis, verifies programs in advance without running the code through a series of lexical analysis, syntax analysis, control flow analysis, and data analysis, and promptly reports potential problems in the program. Currently, static analysis is widely used in compilers, code generation, and other scenarios.
[0003] Because static analysis cannot obtain the specific execution path information generated during actual program execution, it cannot accurately resolve the specific values of the variables being analyzed, resulting in a large number of false positives in the results. Context-free grammar reachability analysis is a key property that static analysis must consider to improve accuracy. It requires that within a feasible program execution path, function call points and function return points must conform to bracket matching rules to prevent mismatched call points and function return points when the same function is called from multiple locations. Therefore, solving the problem of context-free grammar reachability between program procedures has become a focus of attention. Summary of the Invention
[0004] The present disclosure aims to solve one of the technical problems in the related art at least to a certain extent.
[0005] To this end, the first objective of the present disclosure is to propose a method for solving the context-free grammar reachability problem between program procedures, so as to achieve an accurate solution to the context-free grammar reachability problem between program procedures.
[0006] The second objective of the present disclosure is to propose a system for solving the context-free grammar reachability problem between program procedures.
[0007] A third objective of the present disclosure is to provide an electronic device.
[0008] A fourth object of the present disclosure is to provide a computer-readable storage medium.
[0009] A fifth object of the present disclosure is to provide a computer program product.
[0010] To achieve the above objectives, the first embodiment of the present disclosure proposes a method for solving the context-free grammar reachability problem between program procedures, including:
[0011] Constructing a hypergraph corresponding to the program to be solved, and solving the fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set;
[0012] Not retaining the edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer; not retaining the edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer;
[0013] The empty call stack function call point is connected with the non-empty call stack function entry that is reachable by the non-empty call stack function call point corresponding to the empty call stack function call point to obtain a feasible path graph, wherein the empty call stack function call point is the empty call stack function call point in the empty call stack layer, the non-empty call stack function call point is the empty call stack function call point in the non-empty call stack layer, and the non-empty call stack function entry is the function entry in the non-empty call stack layer, and the feasible path graph only includes feasible paths that conform to the context-free grammar rules corresponding to the program to be solved.
[0014] Optionally, solving the fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set includes:
[0015] The propagation reachability of the fact from any point in each function body in the hypergraph to the function exit and the propagation reachability between the function call point and the function call return point are reversely iterated to obtain a fact propagation summary set.
[0016] Optionally, performing reverse iterative solution on the propagation reachability from any point in each function body in the hypergraph to the function exit and the propagation reachability between the function call point and the function call return point includes:
[0017] For each function body in the hypergraph, if there is a point in the function body that can reach a function exit of the function body, determining the identity of the point in the function body;
[0018] If the point in the function body is a function entry, and there is a target function call point in the hypergraph that can reach the point, and there is a target function call return point that can be reached by a function exit that is reachable by the point, then the target function call point that can directly reach the target function call return point is put into the fact propagation summary set as a fact propagation summary.
[0019] Optionally, after determining the identity of the point in the function body, the method further comprises:
[0020] If there is a new fact propagation summary in the fact propagation summary set, the new target function call return point corresponding to the new fact propagation summary that is directly reachable to the function exit reachable by the new target function call return point, and the new target function call point that is directly reachable to the function exit reachable by the new target function call return point are respectively put into the reachable propagation summary set as reachable propagation summaries;
[0021] If the point in the function body is a function call return point, determining an associated function call point corresponding to the point and associated in the fact propagation summary set, and putting a function exit directly reachable from the associated function call point to the reachable propagation summary into the reachable propagation summary set as a reachable propagation summary;
[0022] If the identity of the point in the function body is not the function entry or the function call return point, and there is a target node that can reach the point, then the function exit that is directly reachable from the target node and can reach the point is put into the reachable propagation summary set as a reachable propagation summary.
[0023] Optionally, not retaining the edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retaining the edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer, includes:
[0024] In the case where the fact propagation direction corresponding to the program to be solved is the forward propagation direction, the edges between the forward function entries and the forward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the forward function exits and the forward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer; wherein, the forward function entry is the function entry of the program to be solved in the forward propagation direction, the forward function call point is the function call point of the program to be solved in the forward propagation direction, the forward function exit is the function exit of the program to be solved in the forward propagation direction, and the forward function call return point is the function call return point of the program to be solved in the forward propagation direction.
[0025] Optionally, not retaining the edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retaining the edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer, includes:
[0026] In the case where the fact propagation direction corresponding to the program to be solved is the backward propagation direction, the edges between the backward function entries and the backward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the backward function exits and the backward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer; wherein, the backward function entry is the function exit of the program to be solved in the backward propagation direction, the backward function call point is the function call return point of the program to be solved in the backward propagation direction, the backward function exit is the function entry of the program to be solved in the backward propagation direction, and the backward function call return point is the function call point of the program to be solved in the backward propagation direction.
[0027] Optionally, constructing a hypergraph corresponding to the program to be solved includes:
[0028] Obtaining a flow graph corresponding to the program to be solved, wherein the flow graph includes a control flow graph and a data flow graph;
[0029] On the basis of the flow graph, function call points are set to reach function entries of all function bodies corresponding to the function call points, and function exits of function bodies are set to reach function call return points corresponding to the function bodies, so as to obtain a hypergraph corresponding to the program to be solved.
[0030] To achieve the above objectives, a second embodiment of the present disclosure proposes a system for solving the context-free grammar reachability problem between program procedures, including:
[0031] a relation solving unit, configured to construct a hypergraph corresponding to the program to be solved, and solve a fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set;
[0032] A layer construction unit is configured to not retain edges between function entries and function call points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retain edges between function exits and function call return points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer;
[0033] A path construction unit is used to connect an empty call stack function call point with a non-empty call stack function entry that is reachable from a non-empty call stack function call point corresponding to the empty call stack function call point to obtain a feasible path graph, wherein the empty call stack function call point is an empty call stack function call point in the empty call stack layer, the non-empty call stack function call point is an empty call stack function call point in the non-empty call stack layer, and the non-empty call stack function entry is a function entry in the non-empty call stack layer, and the feasible path graph only includes feasible paths that comply with context-free grammar rules corresponding to the program to be solved.
[0034] To achieve the above-mentioned objectives, a third embodiment of the present disclosure provides an electronic device, including:
[0035] a memory for storing executable program code;
[0036] The processor is used to call and run the executable program code from the memory, so that the electronic device executes the method shown in any one of the first aspects above.
[0037] To achieve the above-mentioned purpose, the fourth aspect of the present disclosure provides a computer-readable storage medium, which stores a computer program. When the computer program is executed, it implements the method shown in any one of the above-mentioned first aspects.
[0038] To achieve the above-mentioned objectives, an embodiment of the fifth aspect of the present disclosure proposes a computer program product, including a computer program, which implements the method shown in any one of the above-mentioned first aspects when executed by a processor.
[0039] In summary, the method, system, device and storage medium provided by the present disclosure output the solution result of the context-free grammar reachability problem between program procedures as a specific feasible path graph, and the feasible path graph only includes feasible paths that comply with the context-free grammar rules corresponding to the program to be solved. It is possible to directly apply other existing control flow / data flow graph analysis algorithms on it to analyze only feasible paths, eliminating the influence of redundant infeasible paths. Secondly, by designing the feasible path graph as a hierarchical graph structure with a total of two layers, it no longer relies on maintaining a specific function call stack, and will not cause a decrease in accuracy due to call stack depth limitations or loops in the hypergraph, and has better time complexity; and only a single initialization of the same time complexity is required to additionally adapt to query-intensive application scenarios where data sources frequently change, and can achieve accurate solutions to the context-free grammar reachability problem between program procedures.
[0040] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above and / or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0042] Figure 1 A flowchart of a method for solving the context-free grammar reachability problem between program procedures provided by an embodiment of the present disclosure;
[0043] Figure 2 A forward feasible path diagram provided by an embodiment of the present disclosure;
[0044] Figure 3 A backward feasible path diagram provided by an embodiment of the present disclosure;
[0045] Figure 4 A schematic diagram of the structure of a system for solving the context-free grammar reachability problem between program procedures provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0046] The following describes in detail embodiments of the present disclosure, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present disclosure, and should not be construed as limiting the present disclosure.
[0047] It should be noted that there are two main algorithms for solving the context-free grammar reachability problem between existing program procedures. The first one is to maintain the function call stack to determine whether the call point and the function call return point match; the second one is the IFDS (Interprocedural, Finite, Distributive, Subset) framework, which constructs a hypergraph and iteratively calculates the reachability transfer relationship through the tabulation algorithm.
[0048] In the first technique, the context-free grammar reachability problem in static analysis is solved by directly maintaining the function call stack. This technique is also widely used in context-sensitive pointer analysis. Specifically, when the program analyzes to a function call point, the call point is pushed into the maintained stack. When returning from the call point, it is determined whether the function call return point matches the call point at the top of the stack. If it does not match, the function does not return. The problem with the first technique is obvious. Due to the runtime complexity and space complexity limitations when analyzing large programs, the depth limit of the call stack is often a relatively small value. In many static analysis implementations, it is set to 3. If there is a deep function recursion, the call point record at the bottom of the stack will be popped out due to stack space overflow during the stack push operation. This results in the inability to restore the previously popped call point record at the bottom of the stack during backtracing analysis, and can only conservatively match all function call return points, resulting in false positives. Raising the call stack depth limit exponentially increases the time complexity of static analysis. Furthermore, if loops appear in the control flow graph, even with a very high call stack depth, all previously saved call point records will be popped during the infinite recursion of the analysis loop, and backtracking will still only be able to conservatively match all function call return points. In other words, the first technique can only produce accurate results when the maintained function call stack depth is infinite, which is clearly impossible with current computer technology. Therefore, the first technique suffers from significant deficiencies in both efficiency and accuracy, demonstrating that maintaining a specific call stack is not an ideal solution.
[0049] In the second technology, the IFDS framework is currently the most advanced method for data flow analysis. Its essence is to calculate the feasible propagation path of a specified data source point in the program. First, IFDS converts the program into a hypergraph. Specifically, based on the control flow graph, the call point is connected to the entry of the function body, and the exit of the function body is connected to the function call return point, to obtain a cross-procedural control flow graph, that is, a hypergraph. Next, the data flow is modeled, the specific data flow is split into several independent data facts, and its propagation flow function is set, and the hypergraph is expanded to obtain an exploded hypergraph. Then, based on the original edge, two types of extended edges are maintained: (1) Path Edge from the function entry to any point in the function body; (2) Summary Edge from the function call point to the corresponding function call return point. The Tabulation algorithm is run, and the associative law of data flow propagation is used to solve these two types of extended edges. The Path Edge combination is connected, and finally the feasible propagation path of the data source point in the program that conforms to the context-free grammar can be obtained. The final time complexity is O(ED 3), where E is the number of edges in the exploded hypergraph and D is the number of data facts to be solved. The second technique significantly outperforms the first in both efficiency and accuracy for single queries against a specific data source, achieving a highly competitive level. However, since the calculated data flow propagation segments, Path Edges, all start at the function entry point, data flow propagation can only be analyzed from that point. To calculate a program slice starting from any point in the program, the framework must be initialized and rerun at that location. In scenarios with multiple queries and frequently changing data sources, the IFDS framework must be rerun for each analysis, which undoubtedly incurs significant overhead. Furthermore, neither the final IFDS output nor the intermediate Path Edges can serve as a new model for subsequent analysis. Furthermore, since this solution only outputs the final data flow contamination point and indirect propagation Path Edges, it is difficult to perform additional effective analysis, such as applying graph theory algorithms to a hypergraph variant containing only feasible paths. This clearly demonstrates the limitations of the existing IFDS framework.
[0050] The present disclosure is described in detail below with reference to specific embodiments.
[0051] In the first embodiment, if Figure 1 As shown, Figure 1 This is a flowchart of a method for solving the context-free grammar reachability problem between program procedures, provided by an embodiment of the present disclosure. The method can be implemented using a computer program and run on a system that solves the context-free grammar reachability problem between program procedures. The computer program can be integrated into an application or run as a standalone tool application.
[0052] The method for solving the context-free grammar reachability problem between program processes can be executed by an electronic device.
[0053] Among them, the method for solving the context-free grammar reachability problem between program procedures provided by the embodiment of the present disclosure combines the advantages of the first and second technologies. The advantage of the first technology is that if the function call stack obtained by the current analysis is bound to the analyzed statement position, a node can be obtained. At this time, whether entering a new function call point, returning to the upper function from the return point, or executing the next statement, the essence is to connect a directed edge between the two nodes. In this way, a context-sensitive hypergraph can be obtained, in which the path between any two nodes is a feasible path that conforms to the context-free grammar rules. Although the hypergraph is relatively large and its total number of nodes is exponentially related to the depth of the function call stack, it shows that it is possible to establish a feasible path graph. The advantage of the second technology is that it cleverly utilizes the property that data flow propagation has an associative law. Through the tabulation algorithm, the data flow can be propagated from the call point to the corresponding return point, and then the result is expanded to both ends to ensure that the data flow passing through the called function will not flow out from the other return point.
[0054] For example, the method for solving the context-free grammar reachability problem between program procedures includes the following steps:
[0055] S101, constructing a hypergraph corresponding to the program to be solved, and solving the fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set;
[0056] According to some embodiments, the program to be solved refers to a program that requires solving the context-free grammar reachability problem between program procedures.
[0057] In some embodiments, a fact propagation summary in the fact propagation summary set is used to indicate a transitive relationship between a function call point and a function call return point.
[0058] It should be noted that the fact propagation summary set is the key to constructing the feasible path graph. All feasible paths can be composed of the edges indicated by the fact propagation summary set and the edges in the hypergraph.
[0059] S102: not retaining the edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer; not retaining the edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer;
[0060] It should be noted that in order to ensure that the feasible path graph only includes feasible paths that conform to the context-free grammar rules corresponding to the program to be solved, the edges from the function exits to the return points of all called function bodies should be deleted from the hypergraph and the edges in the set of all fact propagation summaries should be added. At the same time, it should be noted that the new graph established in this way cannot take into account the control flow / data flow that does not initially enter any function call but directly returns to the upper-level function call (i.e., the case where the function call stack is empty in the first technique, in which case all function return points should be conservatively matched). Therefore, this embodiment designs the feasible path graph as a hierarchical graph structure with a total of two layers, and the empty call stack layer and the non-empty call stack layer are both variants of the original hypergraph.
[0061] That is to say, in the layered graph, the nodes in the empty application stack layer are recorded as empty application stack nodes, and the nodes in the non-empty application stack layer are recorded as non-empty application stack nodes. It can also be said that for the original graph G<V,E> Each node u in the feasible path graph corresponds to both an empty application stack node and a non-empty application stack node.
[0062] S103: Connect the empty call stack function call point with the non-empty call stack function entry reachable from the non-empty call stack function call point corresponding to the empty call stack function call point to obtain a feasible path graph.
[0063] According to some embodiments, the feasible path graph only includes feasible paths corresponding to the program to be solved that comply with context-free grammar rules.
[0064] In some embodiments, the empty call stack function call point is an empty call stack function call point in the empty call stack layer; the non-empty call stack function call point is an empty call stack function call point in the non-empty call stack layer; and the non-empty call stack function entry is a function entry in the non-empty call stack layer.
[0065] It should be noted that the air-conditioning application stack layer is connected to the non-air-conditioning application stack layer, and the propagation relationship between the air-conditioning application stack layer and the non-air-conditioning application stack layer is one-way. Facts can only be propagated from the air-conditioning application stack layer to the non-air-conditioning application stack layer, and are connected through the propagation edge from the function call point to the entrance of the called function.
[0066] In summary, the method provided in this embodiment outputs the solution result of the context-free grammar reachability problem between program processes as a specific feasible path graph, and the feasible path graph only includes feasible paths that conform to the context-free grammar rules corresponding to the program to be solved. Compared with the second technology, it can directly apply other existing control flow / data flow graph analysis algorithms to it to analyze only feasible paths, eliminating the influence of redundant infeasible paths. Secondly, by designing the feasible path graph as a hierarchical graph structure with a total of two layers, compared with the first technology, it no longer relies on maintaining a specific function call stack, and will not cause accuracy to decrease due to call stack depth limitations or loops in the hypergraph, and has better time complexity; compared with the second technology, only a single initialization of the same time complexity is required to additionally adapt to query-intensive application scenarios with frequent changes in data sources. The time complexity required for each query is much less than the time complexity of a single run of IFDS, and can achieve the same analysis accuracy.
[0067] This embodiment also provides another method for solving the context-free grammar reachability problem between program procedures. The method can be executed by an electronic device.
[0068] For example, the method for solving the context-free grammar reachability problem between program procedures may include the following steps:
[0069] S201, obtaining a flow graph corresponding to the program to be solved, and based on the flow graph, setting function call points to reach function entry points of all function bodies corresponding to the function call points, and setting function exit points of the function bodies to reach function call return points corresponding to the function bodies, thereby obtaining a hypergraph corresponding to the program to be solved;
[0070] Among them, flow graphs include but are not limited to control flow graphs, data flow graphs, etc.
[0071] S202, performing reverse iterative solution on the propagation reachability of facts from any point in each function body in the hypergraph to the function exit, and the propagation reachability between the function call point and the function call return point, to obtain a fact propagation summary set;
[0072] According to some embodiments, for each function body in the hypergraph, if there is a point in the function body that is connected to the function exit of the function body, the identity of the point in the function body can be determined; wherein,
[0073] If the point's identity in the function body is a function entry, and there is a target function call point in the hypergraph that is reachable, and there is a target function call return point that is reachable from the function exit that is reachable from the point, then the target function call return point that is directly reachable from the target function call point is put into the fact propagation summary set as a fact propagation summary.
[0074] In some embodiments, after determining the identity of a point in a function body, a reachable propagation summary set may be further determined based on the integration of the fact propagation summary set.
[0075] If there is a new fact propagation summary in the fact propagation summary set, the newly added target function call return point corresponding to the newly added fact propagation summary is directly reachable to the function exit reachable by the newly added target function call return point, and the newly added target function call point is directly reachable to the function exit reachable by the newly added target function call return point, respectively, as reachable propagation summaries and put them into the reachable propagation summary set;
[0076] If the point in the function body is a function call return point, determine the associated function call point that corresponds to the point and is associated in the fact propagation summary set, and put the function exits that are directly reachable from the associated function call point into the reachable propagation summary set as reachable propagation summaries;
[0077] If the point's identity in the function body is not a function entry or a function call return point, and there is a target node of the reachable point, then the function exit that is directly reachable from the target node is put into the reachable propagation summary set as a reachable propagation summary.
[0078] It should be noted that, unlike the implementation of IFDS, the Path Edge in IFDS indicates the specific location to which the data flow is propagated. In order to support multiple queries, the edges in the reachable propagation summary set in this embodiment indicate that there is at least one reachable propagation summary from its starting point to its end point.
[0079] Taking a scenario as an example, for the establishment of a forward feasible path graph suitable for forward propagation analysis, first, given a hypergraph G<V,E> On this basis, the reachable propagation summary set (reach set) of the fact from a point in the function body to the function exit, and the fact propagation summary set (shortcut set) from the function call point to the function call return point are reversely iterated and solved.
[0080] Among them, for an edge in the reach set<u,d1> →<FunExit(p),d2> , where u is in the function body of function p, FunExit(p) is the function exit of function p, and the following three different transfer relationships are applied according to the different identities of u:
[0081] The first transfer relationship is that if u is the function entry FunEntry(p) of function p, consider the function call point-function call return point pair of function p<c,r> , if the hypergraph G<V,E> There exists in the edge set E of<c,d3> →<FunEntry(p),d1> and<FunExit(p),d2> →<r,d4> , then<c,d3> →<r,d4> Add to the shortcut set and consider all the existing in the reach set<r,d4> →<FunExit(ProcOf(r),d5)> ,Will<c,d3> →<FunExit(ProcOf(r),d5)> Add to the reach set, where ProcOf(r) represents the function name of the function body where r is located;
[0082] The second transfer relationship is that if u is the function call return point r, and its corresponding function call point is c, for each shortcut in the set<c,d3> →<u,d1> ,Will<c,d3> →<FunExit(p),d2> Join the reach collection;
[0083] The third transfer relationship is that if u is not the function entry FunEntry(p) of function p, nor is it the function call return point r, for the hypergraph G<V,E> Every edge in the edge set E<v,d3> →<u,d1> ,Will<v,d3> →<FunExit(p),d2> Add to the reach collection.
[0084] S203: not retaining the edges between the function entry points and the function call points of all function bodies in the hypergraph, and adding all the fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer; not retaining the edges between the function exit points and the function call return points of all function bodies in the hypergraph, and adding all the fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer;
[0085] According to some embodiments, when the fact propagation direction corresponding to the program to be solved is the forward propagation direction, the edges between the forward function entries and the forward function call points of all function bodies in the hypergraph may not be retained and all fact propagation summaries in the fact propagation summary set may be added to obtain an empty call stack layer, and the edges between the forward function exits and the forward function call return points of all function bodies in the hypergraph may not be retained and all fact propagation summaries in the fact propagation summary set may be added to obtain a non-empty call stack layer.
[0086] Among them, the forward function entry is the function entry of the program to be solved in the forward propagation direction, the forward function call point is the function call point of the program to be solved in the forward propagation direction, the forward function exit is the function exit of the program to be solved in the forward propagation direction, and the forward function call return point is the function call return point of the program to be solved in the forward propagation direction.
[0087] Taking a scenario as an example, the original hypergraph G<V,E> Replicate in two, G1<V1,E1> and G2<V2,E2> , let the corresponding node of node v in G in E1 be V1(v), and the corresponding node in G2 be V2(v), where G1<V1,E1> As the base layer for building the air conditioning stack, G2<V2,E2> Serves as a base layer for building non-empty application stack layers. Figure 2 A forward feasible path diagram provided by the embodiment of the present disclosure. For simplicity, Figure 2 Only one kind of fact is shown in the transmission; Figure 2 As shown, consider all<c,d1> →<FunEntry(p),d2> ,disconnect<V1(c),d1> →<V1(FunEntry(p)),d2> , add all the edges in the shortcut set to get the empty call stack layer; consider all<FunExit(p),d3> →<r,d4> ,disconnect<V2(FunExit(p)),d3> →<V2(r),d4> , add all the edges in the shortcut set to get the non-empty call stack. At the same time, consider all the edges in the edge set E.<FunEntry(p),d5> →<FunExit(p),d6> Edge, in G1<V1,E1> Middle Connection<V1(FunEntry(p)),d5> →<V1(FunExit(p)),d6> , in G2<V2,E2> Middle Connection<V2(FunEntry(p)),d5> →<V2(FunExit(p)),d6> .
[0088] According to some embodiments, when the fact propagation direction corresponding to the program to be solved is the backward propagation direction, the edges between the backward function entries and the backward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the backward function exits and the backward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer.
[0089] Among them, the forward function entry is the function entry of the program to be solved in the forward propagation direction, the forward function call point is the function call point of the program to be solved in the forward propagation direction, the forward function exit is the function exit of the program to be solved in the forward propagation direction, and the forward function call return point is the function call return point of the program to be solved in the forward propagation direction.
[0090] Take a scenario as an example, Figure 3 A backward feasible path diagram provided by the embodiment of the present disclosure. For simplicity, Figure 3 Only one kind of fact is shown in the transmission; Figure 3 As shown, consider all<FunExit(p),d3> →<r,d4> ,disconnect<V1(FunExit(p)),d3> →<V1(r),d4> , add all the edges corresponding to the shortcut set to get the empty call stack layer; consider all<c,d1> →<FunEntry(p),d2> ,disconnect<V2(c),d1> →<V2(FunEntry(p)),d2> , add all the edges corresponding to the shortcut set to obtain a non-empty call stack. At the same time, consider all the edges in the edge set E.<FunEntry(p),d5> →<FunExit(p),d6> Edge, in G1<V1,E1> Middle Connection<V1(FunEntry(p)),d5> →<V1(FunExit(p)),d6> , in G2<V2,E2> Middle Connection<V2(FunEntry(p)),d5> →<V2(FunExit(p)),d6> .
[0091] S204 , connecting the empty call stack function call point with the non-empty call stack function entry reachable from the non-empty call stack function call point corresponding to the empty call stack function call point to obtain a feasible path graph.
[0092] Taking a scenario as an example, when the fact propagation direction corresponding to the program to be solved is the forward propagation direction, you can connect<V1(c),d1> →<V2(FunEntry(p)),d2> , and obtain the forward feasible path graph, such as Figure 2 As shown. When the fact propagation direction corresponding to the program to be solved is the backward propagation direction, it can be achieved by connecting<V1(r),d1> →<V2(FunExit(p)),d2> , and obtain the backward feasible path graph, such as Figure 3 shown.
[0093] In some embodiments, the forward feasible path graph and the backward feasible path graph can be used to analyze the two propagation directions of control flow and data flow in static analysis - forward propagation and backward propagation, respectively, to meet the needs of different application scenarios. During execution, this embodiment can consider the propagation of control flow / data flow facts, adopt a similar idea to the Tabulation algorithm, calculate feasible paths from the bottom up, and output a cross-process control flow / data flow graph variant, and ensure that any path in the graph is a feasible path that conforms to the context-free grammar rules, so as to facilitate subsequent use of graph theory algorithms for deeper analysis.
[0094] It should be noted that an excellent property of the feasible path graph constructed in this embodiment is that when a fact propagates into a function call point and reaches the called function, since the return edges of non-empty call stack layer functions are all deleted, it can only propagate to the return point matching the call point through the shortcut edge and will not propagate to the unmatched return point. And since the calculation of the shortcut edge adopts a method similar to that in IFDS, it can be proven to be complete, that is, the feasible path graph proposed in this embodiment contains all and only all feasible paths.
[0095] Secondly, the feasible path graph proposed in this embodiment has the same time complexity O(ED 3 ) as the IFDS framework when initially calculating the shortcut edge, but it supports multiple queries. Subsequently, the control flow / data flow propagation starting from any point can be regarded as a graph traversal, and the complexity is the number of points plus the number of edges of the new graph, which is equal to O(N + E + |ShortCut|), where N and E are the number of points and edges of the original graph, and |ShortCut| is the size of the shortcut set. Obviously, |ShortCut| < C·D 2 , where C is the number of function call points in the program. In large programs, C << N < E is often true. Therefore, the complexity T query of each subsequent query satisfies query T << O(ED 2 ) < O(ED 3 ). It can achieve a good time complexity in query-intensive static analysis application scenarios and can effectively adapt to query-intensive application scenarios.
[0096] In summary, the method provided by the embodiments of the present disclosure proposes a more efficient solution compared with the prior art for the context-free grammar reachability problem in program analysis, and is oriented to query-intensive application scenarios, and at the same time has relatively excellent accuracy. Among them, compared with the previous technologies, it can not only output the analysis results of a single time, but also additionally generate a graph model, which can be applied to the control flow / data flow graph constructed by any existing static analysis framework to obtain a variant that only contains feasible paths and directly replace the use of the original graph for subsequent more accurate analysis, and has good scalability. Secondly, the output graph model has good properties and can retain all forward / backward control flow / data flow propagation relationships, and most existing graph theory algorithms can be applied based on it.
[0097] To implement the above embodiments, the present disclosure also proposes a solution system for the context-free grammar reachability problem of program interprocedural.
[0098] Exemplarily, Figure 4This is a schematic diagram of the structure of a system for solving the context-free grammar reachability problem between program processes provided by an embodiment of the present disclosure. Figure 4 As shown, the system 400 for solving the context-free grammar reachability problem between program processes includes:
[0099] The relationship solving unit 401 is used to construct a hypergraph corresponding to the program to be solved, and solve the fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set;
[0100] A layer construction unit 402 is configured to not retain edges between function entry points and function call points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retain edges between function exit points and function call return points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer;
[0101] The path construction unit 403 is used to connect the empty call stack function call points with the non-empty call stack function entries that are reachable from the non-empty call stack function call points corresponding to the empty call stack function call points to obtain a feasible path graph, wherein the empty call stack function call points are the empty call stack function call points in the empty call stack layer, the non-empty call stack function call points are the empty call stack function call points in the non-empty call stack layer, and the non-empty call stack function entries are the function entries in the non-empty call stack layer. The feasible path graph only includes feasible paths that comply with the context-free grammar rules corresponding to the program to be solved.
[0102] Optionally, the relationship solving unit 401 is used to solve the fact propagation summary between each pair of function call points and function call return points in the hypergraph, and when obtaining the fact propagation summary set, specifically to:
[0103] The propagation reachability of the fact from any point in each function body in the hypergraph to the function exit and the propagation reachability between the function call point and the function call return point are solved by reverse iteration to obtain a fact propagation summary set.
[0104] Optionally, when the relationship solving unit 401 is used to perform reverse iterative solution on the propagation reachability from any point in each function body in the hypergraph to the function exit and the propagation reachability between the function call point and the function call return point, it is specifically used to:
[0105] For each function body in the hypergraph, if there is a point in the function body that can reach the function exit of the function body, then determine the identity of the point in the function body;
[0106] If the point's identity in the function body is a function entry, and there is a target function call point in the hypergraph that is reachable, and there is a target function call return point that is reachable from the function exit that is reachable from the point, then the target function call return point that is directly reachable from the target function call point is put into the fact propagation summary set as a fact propagation summary.
[0107] Optionally, after determining the identity of the point in the function body, the relationship solving unit 401 is further configured to:
[0108] If there is a new fact propagation summary in the fact propagation summary set, the newly added target function call return point corresponding to the newly added fact propagation summary is directly reachable to the function exit reachable by the newly added target function call return point, and the newly added target function call point is directly reachable to the function exit reachable by the newly added target function call return point, respectively, as reachable propagation summaries and put them into the reachable propagation summary set;
[0109] If the point in the function body is a function call return point, determine the associated function call point that corresponds to the point and is associated in the fact propagation summary set, and put the function exits that are directly reachable from the associated function call point into the reachable propagation summary set as reachable propagation summaries;
[0110] If the point's identity in the function body is not a function entry or a function call return point, and there is a target node of the reachable point, then the function exit that is directly reachable from the target node is put into the reachable propagation summary set as a reachable propagation summary.
[0111] Optionally, the layer construction unit 402 is configured to not retain the edges between the function entries and the function call points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retain the edges between the function exits and the function call return points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer, specifically for:
[0112] When the fact propagation direction corresponding to the program to be solved is the forward propagation direction, the edges between the forward function entries and the forward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the forward function exits and the forward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer; wherein, the forward function entry is the function entry of the program to be solved in the forward propagation direction, the forward function call point is the function call point of the program to be solved in the forward propagation direction, the forward function exit is the function exit of the program to be solved in the forward propagation direction, and the forward function call return point is the function call return point of the program to be solved in the forward propagation direction.
[0113] Optionally, the layer construction unit 402 is configured to not retain the edges between the function entries and the function call points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retain the edges between the function exits and the function call return points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer, specifically for:
[0114] When the fact propagation direction corresponding to the program to be solved is the backward propagation direction, the edges between the backward function entries and the backward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the backward function exits and the backward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer; wherein, the backward function entry is the function exit of the program to be solved in the backward propagation direction, the backward function call point is the function call return point of the program to be solved in the backward propagation direction, the backward function exit is the function entry of the program to be solved in the backward propagation direction, and the backward function call return point is the function call point of the program to be solved in the backward propagation direction.
[0115] Optionally, when the relationship solving unit 401 is used to construct a hypergraph corresponding to the program to be solved, it is specifically used to:
[0116] Obtaining a flow graph corresponding to the program to be solved, wherein the flow graph includes a control flow graph and a data flow graph;
[0117] On the basis of the flow graph, the function call point is set to reach the function entry of all function bodies corresponding to the function call point, and the function exit of the function body is set to reach the function call return point corresponding to the function body, so as to obtain the hypergraph corresponding to the program to be solved.
[0118] It should be noted that the above explanation of the embodiment of the method for solving the context-free grammar reachability problem between program procedures is also applicable to the system for solving the context-free grammar reachability problem between program procedures in this embodiment, and will not be repeated here.
[0119] In summary, the system provided by the embodiment of the present disclosure outputs the solution result of the context-free grammar reachability problem between program procedures as a specific feasible path graph, and the feasible path graph only includes feasible paths that comply with the context-free grammar rules corresponding to the program to be solved. It can directly apply other existing control flow / data flow graph analysis algorithms on it to analyze only feasible paths, eliminating the influence of redundant infeasible paths. Secondly, by designing the feasible path graph as a hierarchical graph structure with a total of two layers, it no longer relies on maintaining a specific function call stack, and will not cause a decrease in accuracy due to the call stack depth limit or the appearance of loops in the hypergraph, and has better time complexity; and only requires a single initialization of the same time complexity to additionally adapt to query-intensive application scenarios where data sources frequently change, and can achieve accurate solutions to the context-free grammar reachability problem between program procedures.
[0120] In order to implement the above embodiments, the present disclosure also proposes an electronic device, including: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided by the above embodiments.
[0121] In order to implement the above embodiments, the present disclosure further proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the methods provided by the above embodiments.
[0122] In order to implement the above embodiments, the present disclosure further provides a computer program product, including a computer program, which implements the methods provided in the above embodiments when executed by a processor.
[0123] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this disclosure are in compliance with relevant laws and regulations and do not violate public order and good morals.
[0124] It is important to note that personal information collected from users should be used for legitimate and reasonable purposes and should not be shared or sold beyond these legitimate uses. Furthermore, such collection / sharing should be conducted only after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign an agreement / authorization that includes the relevant user information before using the feature. Furthermore, any necessary steps must be taken to safeguard and secure access to such personal information and ensure that others with access to personal information comply with its privacy policy and procedures.
[0125] This disclosure contemplates providing implementations that allow users to selectively block the use or access of personal information data. Specifically, this disclosure contemplates providing hardware and / or software to prevent or block access to such personal information data. Risks can be minimized by limiting data collection and deleting data once it is no longer needed. Furthermore, where applicable, such personal information can be de-identified to protect user privacy.
[0126] In the descriptions of the aforementioned embodiments, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are mutually inconsistent.
[0127] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.
[0128] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.
[0129] The logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or flash memory, a fiber optic device, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering, or processing in another suitable manner as necessary, and then stored in a computer memory.
[0130] It should be understood that various parts of the present disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used to implement the present invention: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application-specific integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0131] Those skilled in the art will appreciate that all or part of the steps in the method for implementing the above-mentioned embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.
[0132] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing module, each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.
[0133] The storage medium mentioned above may be a read-only memory, a magnetic disk, or an optical disk, etc. Although the embodiments of the present disclosure have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. A person of ordinary skill in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A method for solving the context-free grammar reachability problem between program procedures, characterized in that: include: Constructing a hypergraph corresponding to the program to be solved, and solving the fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set; Not retaining the edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer; not retaining the edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer; The empty call stack function call point is connected with the non-empty call stack function entry that is reachable by the non-empty call stack function call point corresponding to the empty call stack function call point to obtain a feasible path graph, wherein the empty call stack function call point is the empty call stack function call point in the empty call stack layer, the non-empty call stack function call point is the empty call stack function call point in the non-empty call stack layer, and the non-empty call stack function entry is the function entry in the non-empty call stack layer, and the feasible path graph only includes feasible paths that conform to the context-free grammar rules corresponding to the program to be solved.
2. The method according to claim 1, characterized in that The fact propagation summary between each pair of function call points and function call return points in the hypergraph is solved to obtain a fact propagation summary set, including: The propagation reachability of the fact from any point in each function body in the hypergraph to the function exit and the propagation reachability between the function call point and the function call return point are reversely iterated to obtain a fact propagation summary set.
3. The method according to claim 2, characterized in that The reverse iterative solution of the propagation reachability of the fact at any point in each function body in the hypergraph to the function exit and the propagation reachability between the function call point and the function call return point includes: For each function body in the hypergraph, if there is a point in the function body that can reach a function exit of the function body, determining the identity of the point in the function body; If the point in the function body is a function entry, and there is a target function call point in the hypergraph that can reach the point, and there is a target function call return point that can be reached by a function exit that is reachable by the point, then the target function call point that can directly reach the target function call return point is put into the fact propagation summary set as a fact propagation summary.
4. The method according to claim 3, characterized in that After determining the identity of the point in the function body, the method further comprises: If there is a new fact propagation summary in the fact propagation summary set, the new target function call return point corresponding to the new fact propagation summary that is directly reachable to the function exit reachable by the new target function call return point, and the new target function call point that is directly reachable to the function exit reachable by the new target function call return point are respectively put into the reachable propagation summary set as reachable propagation summaries; If the point in the function body is a function call return point, determining an associated function call point corresponding to the point and associated in the fact propagation summary set, and putting a function exit directly reachable from the associated function call point to the reachable propagation summary into the reachable propagation summary set as a reachable propagation summary; If the identity of the point in the function body is not the function entry or the function call return point, and there is a target node that can reach the point, then the function exit that is directly reachable from the target node and can reach the point is put into the reachable propagation summary set as a reachable propagation summary.
5. The method according to claim 1, wherein The steps of not retaining edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retaining edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer include: In the case where the fact propagation direction corresponding to the program to be solved is the forward propagation direction, the edges between the forward function entries and the forward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the forward function exits and the forward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer; wherein, the forward function entry is the function entry of the program to be solved in the forward propagation direction, the forward function call point is the function call point of the program to be solved in the forward propagation direction, the forward function exit is the function exit of the program to be solved in the forward propagation direction, and the forward function call return point is the function call return point of the program to be solved in the forward propagation direction.
6. The method according to claim 1, characterized in that The steps of not retaining edges between function entries and function call points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retaining edges between function exits and function call return points of all function bodies in the hypergraph and adding all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer include: In the case where the fact propagation direction corresponding to the program to be solved is the backward propagation direction, the edges between the backward function entries and the backward function call points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain an empty call stack layer, and the edges between the backward function exits and the backward function call return points of all function bodies in the hypergraph are not retained and all fact propagation summaries in the fact propagation summary set are added to obtain a non-empty call stack layer; wherein, the backward function entry is the function exit of the program to be solved in the backward propagation direction, the backward function call point is the function call return point of the program to be solved in the backward propagation direction, the backward function exit is the function entry of the program to be solved in the backward propagation direction, and the backward function call return point is the function call point of the program to be solved in the backward propagation direction.
7. The method according to claim 1, characterized in that The constructing of a hypergraph corresponding to the program to be solved includes: Obtaining a flow graph corresponding to the program to be solved, wherein the flow graph includes a control flow graph and a data flow graph; On the basis of the flow graph, function call points are set to reach function entries of all function bodies corresponding to the function call points, and function exits of function bodies are set to reach function call return points corresponding to the function bodies, so as to obtain a hypergraph corresponding to the program to be solved.
8. A system for solving the context-free grammar reachability problem between program procedures, characterized by: include: a relation solving unit, configured to construct a hypergraph corresponding to the program to be solved, and solve a fact propagation summary between each pair of function call points and function call return points in the hypergraph to obtain a fact propagation summary set; A layer construction unit is configured to not retain edges between function entries and function call points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain an empty call stack layer, and not retain edges between function exits and function call return points of all function bodies in the hypergraph and add all fact propagation summaries in the fact propagation summary set to obtain a non-empty call stack layer; A path construction unit is used to connect an empty call stack function call point with a non-empty call stack function entry that is reachable from a non-empty call stack function call point corresponding to the empty call stack function call point to obtain a feasible path graph, wherein the empty call stack function call point is an empty call stack function call point in the empty call stack layer, the non-empty call stack function call point is an empty call stack function call point in the non-empty call stack layer, and the non-empty call stack function entry is a function entry in the non-empty call stack layer, and the feasible path graph only includes feasible paths that comply with context-free grammar rules corresponding to the program to be solved.
9. An electronic device, characterized in that: The electronic device comprises: a memory for storing executable program code; A processor is configured to call and run the executable program code from the memory, so that the electronic device executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.