Method and apparatus for shared variable dependency chain breakage detection

By disassembling and monitoring the program under optimized and non-optimized compilation configurations, and combining static and dynamic analysis, the system identifies and judges the breakpoints in the shared variable dependency chain, thus solving the program anomaly problem caused by compiler optimization and improving the accuracy and efficiency of detection.

CN120929339BActive Publication Date: 2025-12-12INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511464147.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-14
Publication Date
2025-12-12
Estimated Expiration
2045-10-14

AI Technical Summary

Technical Problem

In existing technologies, compiler optimization may cause shared variable dependency chains to break, leading to abnormal program execution. Dynamic analysis methods have high performance overhead, static analysis methods have limited automation, and formal verification methods have limited coverage and difficulty in reproducing complex race conditions in production environments.

Method used

By compiling and disassembling the program with optimized compilation configurations disabled and enabled, and combining the static disassembly channel and the dynamic PMU channel, suspicious breakpoints are identified, performance monitoring points are set, static and dynamic breakpoints are calculated, and it is determined whether the comprehensive breakpoint is greater than a threshold to identify dependency chain breakpoints.

Benefits of technology

It improves the accuracy and efficiency of dependency chain break detection, reduces dynamic detection overhead, can cover competitive conditions in real production environments, and enhances the accuracy and comprehensiveness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929339B_ABST
    Figure CN120929339B_ABST
Patent Text Reader

Abstract

The application discloses a shared variable dependency chain break detection method and device, relates to the technical field of multiprocessor programming, and comprises the following steps: coupling two detection channels of a static reverse assembly channel and a dynamic PMU channel, wherein the static reverse assembly channel utilizes the principle that the relevant reverse assembly code will change when the shared variable dependency chain breaks, the dynamic PMU channel utilizes the principle that the number of relevant PMU events in the program running process will change when the shared variable dependency chain breaks, a shared variable dependency chain break detection architecture is constructed, and the technical problems that the performance overhead of a dynamic analysis method is large, and the automation degree of a static analysis method is limited in the related art are solved. In addition, the coverage scene of a formal verification method is limited, and it is difficult to reproduce the complex competition conditions of a production environment, technical effects that the accuracy and efficiency of detection are effectively improved, the dynamic detection overhead is reduced, and the competition conditions in a real production environment can be covered are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of multi-processor programming, and particularly relates to a shared variable dependency chain breaking detection method and device. BACKGROUND

[0002] In some programming scenarios, the optimization mechanism of a compiler can have adverse effects. For example, in a multi-processor cooperative programming scenario, the optimization operation performed by the compiler to improve efficiency can break a shared variable dependency chain, and thus cause abnormal problems in program running.

[0003] Currently, the related art can detect harmful optimization of a compiler through dynamic analysis, static analysis, and formal verification methods.

[0004] However, in the related art, the dynamic analysis method has a large performance overhead, the automatic degree of the static analysis method is limited, and cannot accurately map to abnormal behaviors in program running; in addition, the formal verification method has a large limitation in coverage scenarios, and is difficult to reproduce complex competition conditions in a production environment, which needs to be solved urgently. SUMMARY

[0005] The present application provides a shared variable dependency chain breaking detection method and device to at least solve the technical problems in the related art that the dynamic analysis method has a large performance overhead, the automatic degree of the static analysis method is limited, and cannot accurately map to abnormal behaviors in program running; in addition, the formal verification method has a limited coverage scenario, and is difficult to reproduce complex competition conditions in a production environment.

[0006] The application provides a shared variable dependency chain breaking detection method, comprising the following steps: compiling and disassembling the program to be analyzed under the conditions of closing and opening the optimization compilation configuration respectively to obtain the disassembled files before and after optimization, and comparing and analyzing the disassembled files before and after optimization to obtain the corresponding analysis results; based on the analysis results, identifying the suspicious breaking points in the program to be analyzed that meet the preset dependency chain change requirements, determining the dependency chain change requirement type corresponding to the suspicious breaking points, and determining the requirement weight corresponding to different requirements in the preset dependency chain change requirements according to the dependency chain change requirement type, so as to calculate the static disassembled channel breaking score of the suspicious breaking points through the dependency chain change requirement type and the requirement weight; setting a performance monitoring point at the suspicious breaking point, and recompiling the program to be analyzed after setting the performance monitoring point to generate an execution program with the performance monitoring point, and running the execution program with the performance monitoring point to determine the occurrence number of the performance monitoring events that meet the preset dependency chain breaking correlation requirements occurring before and after optimization of the program to be analyzed, and calculating the dynamic performance monitoring channel breaking score of the suspicious breaking points according to the occurrence number; calculating the comprehensive breaking score of the suspicious breaking points according to the static disassembled channel breaking score and the dynamic performance monitoring channel breaking score, and judging whether the comprehensive breaking score is greater than a breaking threshold value, wherein when the comprehensive breaking score is greater than the breaking threshold value, the suspicious breaking point is determined as a dependency chain breaking point.

[0007] The application further provides a shared variable dependency chain breaking detection device, comprising: a reverse assembly module, configured to compile and perform reverse assembly operation on a program to be analyzed under the conditions of a closed optimization compilation configuration and an opened optimization compilation configuration, to obtain reverse assembly files before and after optimization, and perform comparative analysis on the reverse assembly files before and after optimization to obtain corresponding analysis results; an identification module, configured to identify suspicious breaking points in the program to be analyzed that meet preset dependency chain change requirements based on the analysis results, determine a dependency chain change requirement type corresponding to the suspicious breaking points, and determine requirement weights corresponding to different requirements in the preset dependency chain change requirements according to the dependency chain change requirement type, so as to calculate a static reverse assembly channel breaking score of the suspicious breaking points by using the dependency chain change requirement type and the requirement weights; a breaking score calculation module, configured to set a performance monitoring point at the suspicious breaking point, recompile the program to be analyzed after the performance monitoring point is set, to generate an execution program with the performance monitoring point, and run the execution program with the performance monitoring point, to determine the number of performance monitoring events that meet preset dependency chain breaking correlation requirements and occur before and after optimization of the program to be analyzed, and calculate a dynamic performance monitoring channel breaking score of the suspicious breaking points according to the number; and a judgment module, configured to calculate a comprehensive breaking score of the suspicious breaking points according to the static reverse assembly channel breaking score and the dynamic performance monitoring channel breaking score, and judge whether the comprehensive breaking score is greater than a breaking threshold, wherein, when the comprehensive breaking score is greater than the breaking threshold, the suspicious breaking point is determined to be a dependency chain breaking point.

[0008] The application further provides an electronic device, comprising: a memory configured to store a computer program; and a processor configured to execute the computer program to implement the steps of any of the shared variable dependency chain breaking detection methods.

[0009] The application further provides a non-volatile computer readable storage medium, wherein the non-volatile computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of any of the shared variable dependency chain breaking detection methods.

[0010] The application further provides a computer program product, comprising a computer program, and the computer program is executed by a processor to implement the steps of any of the shared variable dependency chain breaking detection methods.

[0011] By the present application, the to-be-analyzed program can be compiled and disassembled in the case of closing and opening the optimization compilation configuration respectively to obtain the disassembled files before and after optimization, and the disassembled files before and after optimization are compared and analyzed to obtain the corresponding analysis result; based on the analysis result, the suspicious breaking point in the to-be-analyzed program that meets the preset dependency chain change requirement is identified, and the dependency chain change requirement type corresponding to the suspicious breaking point is determined, and the requirement weight corresponding to different requirements in the preset dependency chain change requirement is determined according to the dependency chain change requirement type, so as to calculate the static disassembly channel breaking score of the suspicious breaking point through the dependency chain change requirement type and the requirement weight; the performance monitoring point is set at the suspicious breaking point, and the to-be-analyzed program after setting the performance monitoring point is recompiled to generate an execution program with the performance monitoring point, and the execution program with the performance monitoring point is run to determine the occurrence number of the performance monitoring event that meets the preset dependency chain breaking relevance requirement before and after optimization of the to-be-analyzed program, and the dynamic performance monitoring channel breaking score of the suspicious breaking point is calculated according to the occurrence number; the comprehensive breaking score of the suspicious breaking point is calculated according to the static disassembly channel breaking score and the dynamic performance monitoring channel breaking score, and it is judged whether the comprehensive breaking score is greater than the breaking threshold, wherein when the comprehensive breaking score is greater than the breaking threshold, the suspicious breaking point is determined as the dependency chain breaking point, therefore, the technical problem that the performance overhead of the dynamic analysis method is large, the automation degree of the static analysis method is limited, and the abnormal behavior of the program running cannot be accurately mapped in the related art can be solved; in addition, the formal verification method has a limited coverage scene, and it is difficult to reproduce the complex competition condition in the production environment, thereby achieving the technical effects of effectively improving the accuracy and efficiency of detection, reducing the dynamic detection overhead, and covering the competition condition in the real production environment. BRIEF DESCRIPTION OF DRAWINGS

[0012] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creating laborious work.

[0013] Figure 1 A flow chart of a shared variable dependency chain breaking detection method according to an embodiment of the present application is provided.

[0014] Figure 2 A logic architecture schematic diagram of a shared variable dependency chain breaking detection method according to an embodiment of the present application is provided.

[0015] Figure 3 An execution logic schematic diagram of a shared variable dependency chain breaking detection method according to an embodiment of the present application is provided.

[0016] Figure 4 This is an example diagram of a shared variable dependency chain breakage detection device according to an embodiment of this application.

[0017] Among them, 10-shared variable dependency chain break detection device, 100-disassembly module, 200-identification module, 300-break calculation module, and 400-judgment module. Detailed Implementation

[0018] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0019] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0020] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0021] The specific application environment architecture or specific hardware architecture on which the shared variable dependency chain break detection method depends is described here.

[0022] The embodiments of this application provide a method for detecting broken shared variable dependency chains.

[0023] like Figure 1 The diagram shown is a flowchart of a shared variable dependency chain break detection method according to an embodiment of this application. The shared variable dependency chain break detection method includes the following steps:

[0024] In step S101, the program to be analyzed is compiled and disassembled with the optimization compilation configuration turned off and with the optimization compilation configuration turned on, respectively, to obtain disassembled files before and after optimization. The disassembled files before and after optimization are compared and analyzed to obtain the corresponding analysis results.

[0025] Those skilled in the art should appreciate that in the related art, the harmful optimization detection technology based on the decoder and the encoder mainly includes three types of dynamic analysis, static analysis and formal verification.

[0026] Among them, the dynamic analysis technology generally needs to be combined with the instrumentation technology to detect the defect code during the program running, such as the Valgrind tool and the ThreadSanitizer tool. Although this technology can capture abnormal behaviors at runtime with high precision, the performance overhead introduced by the instrumentation is large.

[0027] The static analysis technology detects the defect code during the compilation and can be roughly divided into the following two types:

[0028] 1. Identification class:

[0029] The identification class can identify the defect code during the compilation according to the prompt, for example, by declaring the data dependency relationship through code annotation, the compiler verifies the dependency logic, or based on symbolic execution analysis of data flow, the identification class identifies the violation behavior. Although this type of technology has low runtime overhead, it relies too much on manual annotation or configuration, has low automation degree, and cannot accurately map to abnormal behaviors at runtime.

[0030] 2. Comparison class:

[0031] The comparison class can compare the results before and after the optimization of the same source code, and inject check instructions at the difference points, such as the DiffKemp tool. Although this method can overcome the problem of low automation degree of the identification method to a certain extent, it still has the problem of being unable to accurately map to abnormal behaviors at runtime.

[0032] The formal verification method can verify whether the execution result conforms to the memory model expectation by constructing the benchmark concurrent code, and can directly preserve the behavior of the hardware / compilers violating the memory model. However, the design of the test case depends on experience, the coverage scene is limited, and it is difficult to reproduce the complex competition conditions in the production environment.

[0033] Therefore, in order to solve the problems in the related art, the embodiments of the present application can construct a shared variable dependency chain break detection architecture including a static disassembly channel and a dynamic PMU (Performance Monitor Unit) channel, as shown in Figure 2 The static disassembly channel utilizes the principle that the disassembled code will change when the shared variable dependency chain is broken, and the dynamic PMU channel utilizes the principle that the number of related PMU events will change when the shared variable dependency chain is broken during the program running.

[0034] Therefore, the embodiments of the present application can couple the static disassembly channel and the dynamic PMU channel, thereby effectively improving the accuracy and efficiency of the dependency chain break detection.

[0035] Optionally, in an embodiment of the present application, the compiling and disassembling operations are performed on the program to be analyzed to obtain the disassembled files before and after optimization, including: compiling the program to be analyzed under the condition that the optimization compiling configuration is closed to obtain the compiled file before optimization, and compiling the program to be analyzed under the condition that the optimization compiling configuration is opened to obtain the compiled file after optimization; and performing the disassembling operations on the compiled file before optimization and the compiled file after optimization respectively to generate the corresponding disassembled files before and after optimization.

[0036] It should be noted that the embodiments of the present application can use different compiling options (such as closing or opening the optimization compiling configuration) to compile the program to be analyzed to obtain the execution programs of different optimization levels, specifically the binary executable programs. Among them, the different optimization levels mainly represent whether the optimization compiling configuration is opened or closed. If the optimization compiling configuration is closed, it means that the program to be analyzed is not optimized and compiled, and the optimization level is the lowest, at this time the compiled file before optimization is obtained; if the optimization compiling configuration is opened, a plurality of different optimization level compiling options can be opened, at this time the compiled file after optimization is obtained.

[0037] For example, the embodiments of the present application can use GCC (GNU Compiler Collection, GNU compiler suite) -O0 to compile to obtain the binary executable program bin_O0 before optimization, and use GCC -O2 to compile to obtain the binary executable program bin_O2 after optimization; secondly, the embodiments of the present application can disassemble bin_O0 and bin_O2 to obtain the disasm_O0 disassembled file (disassembled file before optimization) and the disasm_O2 disassembled file (disassembled file after optimization) respectively.

[0038] Therefore, the embodiments of the present application can compare the binary programs and their disassembled files generated by different compiling options, so as to intuitively show the optimization effect of the compiler, which is helpful to understand the optimization mechanism.

[0039] Optionally, in an embodiment of the present application, the disassembled files before and after optimization are compared and analyzed to obtain the corresponding analysis results, including: inputting the disassembled files before and after optimization into a preset static disassembling channel to perform code structure analysis on the disassembled files respectively to generate structured code data containing instruction type, operation object and code location information; based on the structured code data, the code segments in the disassembled files before and after optimization are compared and analyzed to obtain the corresponding comparison data, and the code location in the code segment that meets the preset dependency chain change requirement is analyzed according to the comparison data to obtain the analysis results.

[0040] As an implementable manner, the embodiment of the present application can input the disassembled files before and after optimization, disasm_O0 and disasm_O2, into a static disassembling channel when processing the disassembled files before and after optimization, and the embodiment of the present application can introduce a multi-level analysis framework through the static disassembling channel. Specifically, the embodiment of the present application can first disassemble each instruction through an instruction tokenizer, and extract basic information such as operation code and operation number; secondly, a control flow graph generation module is used to associate code location and jump logic, and finally structured code data containing instruction types (such as arithmetic operation and memory access), operation objects (register / memory address), code location and control flow relationship are generated.

[0041] After that, the embodiment of the present application can use a bidirectional tracing comparison method to compare the dependency chain, on the one hand, the embodiment of the present application can start from the instruction of the code segment after optimization, and trace back the corresponding dependent instruction before optimization; on the other hand, the embodiment of the present application can start from the starting point of the dependency chain before optimization, and verify the dependency inheritance relationship of the instruction after optimization in a forward direction. In the embodiment of the present application, the comparison data not only contains the increase and decrease of the dependent instruction, but also can mark the change of the dependency strength (such as the change from strong dependency to weak dependency).

[0042] It should be noted that the embodiment of the present application can analyze the code location in the code segment that meets the preset dependency chain change requirement based on the comparison data, to obtain an analysis result in the form of a structured table of “code location-change type-risk level”. Among them, the dependency chain change requirement in the embodiment of the present application includes but is not limited to: whether the mov instruction sequence (data copy) is replaced by independent memory access, whether the intermediate variable is optimized and eliminated, and whether the memory access order is changed. In actual execution, the embodiment of the present application can refine the dependency chain change requirement into three levels: core dependency chain breakage (which needs to be urgently investigated), non-core dependency chain addition (which needs to be evaluated for impact), and dependency order adjustment (which needs to verify the logic consistency).

[0043] Therefore, the embodiment of the present application accurately captures the change of the dependency chain after code optimization through multi-level analysis and bidirectional tracing comparison, thereby clearly identifying the risk points, and providing efficient support for verifying the rationality of optimization and investigating potential problems.

[0044] In step S102, based on the analysis result, a suspicious break point in the to-be-analyzed program that meets the preset dependency chain change requirement is identified, and a dependency chain change requirement type corresponding to the suspicious break point is determined, and a requirement weight corresponding to different requirements in the preset dependency chain change requirement is determined according to the dependency chain change requirement type, so as to calculate a static disassembling channel breakage score of the suspicious break point through the dependency chain change requirement type and the requirement weight.

[0045] Further, the embodiment of the present application detects whether there is a suspicious position of dependency chain breakage in the program to be analyzed according to the analysis result, and if there is, the embodiment of the present application can mark the corresponding position as a suspicious breakage point, and determine a dependency chain change requirement type corresponding to the suspicious breakage point, and determine a requirement weight corresponding to different requirements (such as a data copy instruction sequence being replaced by independent memory access, an intermediate variable being optimized and eliminated, a memory access order being changed, etc.) in the preset dependency chain change requirement according to the dependency chain change requirement type, so as to calculate the static reverse assembly channel breakage score of the suspicious breakage point by means of the dependency chain change requirement type and the requirement weight.

[0046] Therefore, the embodiment of the present application can accurately locate the potential risk point of the program by detecting the suspicious position of dependency chain breakage according to the analysis result and calculating the corresponding static reverse assembly channel breakage score, so as to quantify the risk degree and provide clear guidance for investigating the program problem and ensuring the stability of the optimized program.

[0047] Optionally, in an embodiment of the present application, based on the analysis result, a suspicious breakage point meeting the preset dependency chain change requirement in the program to be analyzed is identified, and a dependency chain change requirement type corresponding to the suspicious breakage point is determined, and a requirement weight corresponding to different requirements in the preset dependency chain change requirement is determined according to the dependency chain change requirement type, so as to calculate the static reverse assembly channel breakage score of the suspicious breakage point by means of the dependency chain change requirement type and the requirement weight, including: based on the analysis result, a code position meeting the preset dependency chain change requirement in the code segment of the reverse assembly file before and after optimization corresponding to the program to be analyzed is determined, and the code position is taken as the corresponding suspicious breakage point, wherein the preset dependency chain change requirement includes that a data copy instruction sequence is replaced by independent memory access, an intermediate variable is optimized and eliminated, and a memory access order is changed; a dependency chain change requirement type to which the current suspicious breakage point belongs is judged, and a preset dependency chain change index is valued according to the dependency chain change requirement type; based on the dependency chain change requirement type, a data copy instruction sequence weight, an intermediate variable weight and a memory access order weight corresponding to the suspicious breakage point are determined, and the static reverse assembly channel breakage score is calculated according to the data copy instruction sequence weight, the intermediate variable weight, the memory access order weight and the valued dependency chain change index.

[0048] In actual execution, the embodiment of the application compares the disassembled codes before and after optimization (such as -O0 and -O2) based on the static disassembled channel, detects the code positions where the dependency chain changes exist in the code segment, and marks them as suspicious breaking points; secondly, the embodiment of the application can judge the dependency chain change requirement type (such as the data copy instruction sequence being replaced by the independent memory access type, the intermediate variable being optimized and eliminated type, the memory access order being changed type) to which the current suspicious breaking point belongs, so as to assign values to the preset dependency chain change indicators; further, the embodiment of the application can calculate the static disassembled channel breaking score of each suspicious breaking point according to the analysis result and the dependency chain change indicators.

[0049] As an implementable manner, the calculation expression of the static disassembled channel breaking score of the embodiment of the application is as follows:

[0050]

[0051] Among them, represents the data copy instruction sequence weight, which can measure the relative importance in the case of "whether the mov instruction sequence is replaced by the independent memory access" when calculating the breaking score, and can be obtained by historical experience training; represents the data copy instruction sequence being replaced by the independent memory access type, which represents whether the case of "whether the mov instruction sequence is replaced by the independent memory access" occurs at the current detection point, if yes, then is assigned a value of 1, otherwise, a value of 0 is assigned; represents the intermediate variable weight; represents the intermediate variable being optimized and eliminated type; represents the memory access order weight; represents the memory access order change type.

[0052] Therefore, the embodiment of the application calculates the static disassembled channel breaking score by combining the weight assignment according to the different dependency chain change requirements, so as to quantitatively evaluate the risk of the suspicious breaking point and accurately locate the potential problems after code optimization, thereby providing quantifiable data basis for verifying the optimization rationality and ensuring the program stability.

[0053] In step S103, a performance monitoring point is set at the suspicious breaking point, and the program to be analyzed after the performance monitoring point is set is recompiled to generate an execution program with the performance monitoring point, and the execution program with the performance monitoring point is run to determine the occurrence number of the performance monitoring events that meet the preset dependency chain breaking correlation requirement before and after optimization of the program to be analyzed, and the dynamic performance monitoring channel breaking score of the suspicious breaking point is calculated according to the occurrence number.

[0054] Afterwards, the embodiment of the present application can set a PMU monitoring point (i.e. performance monitoring point) at a suspicious break point of the program to be analyzed, and recompile the program to be analyzed, such as -O0 and -O2, after the performance monitoring point is set, to generate binary executable programs bin_O0_PMU and bin_O2_PMU with the PMU monitoring point. Furthermore, the embodiment of the present application can input the binary executable programs bin_O0_PMU and bin_O2_PMU with the PMU monitoring point into a dynamic PMU channel (i.e. dynamic performance monitoring channel) to run, and count the occurrence number of PMU events (i.e. performance monitoring events) related to the break of the dependency chain before and after optimization, so as to calculate the dynamic PMU channel break score (i.e. dynamic performance monitoring channel break score) of each suspicious break point according to the occurrence number.

[0055] Therefore, the embodiment of the present application sets a PMU monitoring point at a suspicious break point and recompiles the program, counts the occurrence number of related events by running in a dynamic PMU channel, and calculates the dynamic performance monitoring channel break score, so as to quantify the risk of break of the dependency chain from the running level, supplement static analysis, and improve the comprehensiveness and accuracy of program problem detection.

[0056] Optionally, in an embodiment of the present application, a performance monitoring point is set at a suspicious break point, and the program to be analyzed after the performance monitoring point is set is recompiled to generate an execution program with the performance monitoring point, and the execution program with the performance monitoring point is run to determine the occurrence number of performance monitoring events meeting the preset dependency chain break relatedness requirement before and after optimization of the program to be analyzed, and calculate the dynamic performance monitoring channel break score of the suspicious break point according to the occurrence number, including: setting a performance monitoring point at a suspicious break point to generate a corresponding program intermediate code; compiling the program intermediate code by using different compilation options to generate an execution program with the performance monitoring point; running the execution program with the performance monitoring point in a preset dynamic performance monitoring channel to monitor the performance monitoring events meeting the preset dependency chain break relatedness requirement before and after optimization; counting the occurrence number of the performance monitoring events meeting the preset dependency chain break relatedness requirement, wherein the performance monitoring events include the first-level cache hit number or miss number, the second-level cache hit number or miss number, and the number of consumed instruction cycles; and calculating the dynamic performance monitoring channel break score of the suspicious break point based on the occurrence number.

[0057] It should be noted that in the program dependency chain breakage detection scenario, the embodiments of the present application first implement a precise monitoring point implantation operation for the suspicious breakage point of the program to be analyzed, which is different from the traditional rough implantation. The performance monitoring point (PMU monitoring point) is bound with the instruction logic depth of the suspicious breakage point, to ensure that the monitoring point only captures the position dependency chain related behavior, avoids irrelevant instruction interference, and generates program intermediate code containing precise monitoring logic. Secondly, the embodiments of the present application can use multi-dimensional compilation options to compile the intermediate code differently: in addition to the conventional no optimization (-O0), two-level optimization (-O2) options, additional options for memory access optimization (-O3 -ftree-vectorize), for instruction scheduling optimization (-Os -fschedule-insns) and the like are introduced, to generate multiple groups of binary executable programs (such as bin_O0_PMU, bin_O2_PMU, bin_O3_PMU, etc.) with PMU monitoring points, to cover the dependency chain change possibility under different optimization scenarios.

[0058] In the dynamic performance monitoring channel running stage, the embodiments of the present application can construct an "event-scenario" mapping model: the PMU events (first level cache hit / miss times (L1 HIT / L1 MISS), second level cache hit / miss times (L2 HIT / L2 MISS), consumed instruction cycle numbers (CYCLES) and the like) are associated with dependency chain breakage types (such as data dependency breakage, control dependency breakage). For example, when the number of L1 cache misses is suddenly increased, the embodiments of the present application can preferentially associate the "memory access order change" type dependency chain breakage scenario. At the same time, the channel built-in real-time data filtering module automatically removes invalid PMU event (i.e. performance monitoring event) data generated due to system resource competition (such as CPU (Central Processing Unit, Central Processing Unit) preemption), to ensure the accuracy of the monitoring result.

[0059] Finally, in the PMU event statistics link, the embodiments of the present application can use a time slice segmentation statistics strategy combined with a weighted aggregation strategy. Specifically, the embodiments of the present application can divide the program running period into multiple equal length time slices, respectively count the number of occurrences of the target PMU event in each time slice, and then calculate the total number of occurrences of the weighted events according to the importance of the program business logic in different time slices (such as setting the time slice weight of the core calculation module to 1.2 and the auxiliary function module to 0.8), to provide more actual running scenario data support for subsequent dynamic performance monitoring channel breakage calculation.

[0060] Therefore, by coupling the static reverse assembly channel and the dynamic PMU channel, the suspicious breakpoint identified by the static reverse assembly channel is used as a monitoring point of the dynamic PMU channel, so that the range and overhead of dynamic detection are effectively reduced, and the detection efficiency is improved. In addition, by means of accurate instrumentation, multi-compilation option adaptation and intelligent event monitoring, the accuracy of PMU event capture related to dependent chain breakage is improved, and reliable data is provided for dynamic breakage calculation.

[0061] Optionally, in an embodiment of the present application, the dynamic performance monitoring accuracy can also be improved in the following way:

[0062] 1. Based on the cross verification of the program static dependent chain analysis result and the control flow graph and the data flow graph, a suspicious breakpoint priority evaluation model is constructed, and the abstract syntax tree traversal technology is used to set the monitoring points of performance monitoring before and after the code block for the top 30% of the breakpoints in priority, and the initial and post-execution phasor states are recorded.

[0063] 2. A compilation option and monitoring demand mapping relationship library is established, the optimal compilation parameter combination is selected for different measurement targets, a multi-version binary program with monitoring points is generated, and a post-compilation optimization technique is introduced to trim redundant code and rearrange instructions.

[0064] 3. A master-slave distributed monitoring channel architecture is constructed, the master channel collects core phasor data in real time, the slave channel asynchronously collects secondary data, an event filtering engine is embedded to filter raw data according to preset rules, effective events are classified by machine learning algorithm, and the number of event occurrences is counted by sliding time window.

[0065] Therefore, the embodiments of the present application can accurately locate the key monitoring points, optimize the compilation and channel design, reduce the interference data, and improve the data acquisition accuracy and integrity.

[0066] Optionally, in an embodiment of the present application, based on the number of occurrences, the dynamic performance monitoring channel breakage score of the suspicious breakpoint is calculated, including: calculating the difference values of the first level cache hit number, the first level miss number, the second level cache hit number, the second level miss number and the consumed instruction cycle number before and after optimization, and based on the difference values of the first level cache hit number, the first level miss number, the second level cache hit number, the second level miss number and the consumed instruction cycle number, a breakage feature matrix is constructed; determining the weights of different performance monitoring events, and based on the breakage feature matrix and the weights of different performance monitoring events, calculating the dynamic performance monitoring channel breakage score.

[0067] In actual execution, when the dynamic performance monitoring channel breakage score is calculated, the breakage feature matrix can be established first, as shown in the following formula:

[0068]

[0069] wherein, represents a fracture feature matrix, represents a difference value of the first-level cache hit number before and after optimization; represents a difference value of the first-level miss number before and after optimization; represents a difference value of the second-level cache hit number before and after optimization; represents a difference value of the second-level miss number before and after optimization.

[0070] Secondly, the embodiment of the present application can calculate the dynamic performance monitoring channel fracture score according to the fracture feature matrix, as shown in the following formula:

[0071]

[0072] wherein, represents the weight of different performance monitoring events, which can measure the relative importance of each PMU event in calculating the fracture score, and the parameter can be trained according to historical experience; represents the dynamic performance monitoring channel fracture score; represents the difference value of each PMU event before and after optimization in the fracture feature matrix.

[0073] Therefore, the embodiment of the present application only needs to configure the key detection point and the fracture feature matrix, so as to identify the difference points before and after the same source code optimization, and effectively improve the accuracy and reliability of the automatic calculation of the dynamic PMU channel fracture score.

[0074] In step S104, the comprehensive fracture score of the suspicious fracture point is calculated according to the static reverse assembly channel fracture score and the dynamic performance monitoring channel fracture score, and it is judged whether the comprehensive fracture score is greater than the fracture threshold value, wherein when the comprehensive fracture score is greater than the fracture threshold value, the suspicious fracture point is determined as the dependency chain fracture point.

[0075] Further, the embodiment of the present application can rely on the dependency chain fracture analysis engine to calculate the comprehensive fracture score of the suspicious fracture point according to the detection results (i.e. the static reverse assembly channel fracture score and the dynamic performance monitoring channel fracture score) of the two channels, and when the comprehensive fracture score exceeds the fracture threshold value, the suspicious fracture point is determined as the dependency chain fracture point.

[0076] It should be noted that the entire dependency chain fracture detection process of the embodiment of the present application is performed for specific source code, so as to be able to cover the race conditions in the real production environment.

[0077] Optionally, in an embodiment of the present application, the comprehensive fracture score of the suspicious fracture point is calculated according to the static disassembly channel fracture score and the dynamic performance monitoring channel fracture score, and it is judged whether the comprehensive fracture score is greater than the fracture threshold value, wherein when the comprehensive fracture score is greater than the fracture threshold value, the suspicious fracture point is determined to be a dependent chain fracture point, comprising: fusing and calculating the static disassembly channel fracture score and the dynamic performance monitoring channel fracture score to obtain the comprehensive fracture score of the suspicious fracture point, and comparing the comprehensive fracture score with the preset fracture threshold value; when the comprehensive fracture score is less than or equal to the fracture threshold value, it is determined that the corresponding suspicious fracture point is not a dependent chain fracture point; when the comprehensive fracture score is greater than the fracture threshold value, it is determined that the corresponding suspicious fracture point is a dependent chain fracture point, and the dependent chain fracture point information corresponding to the dependent chain fracture point is collected, so as to generate a corresponding detection report according to the dependent chain fracture point information.

[0078] It should be noted that the embodiments of the present application can introduce a hierarchical weighted fusion algorithm, a scene adaptive weight factor, a baseline dynamic calibration mechanism and a multi-level information collection mechanism to calculate the comprehensive fracture score of the suspicious fracture point and generate a corresponding detection report, as described below:

[0079] 1. First, the embodiments of the present application can standardize the static disassembly channel fracture score (focusing on the risk of code structure level) and the dynamic performance monitoring channel fracture score (focusing on the actual performance at runtime), and unify the values of the two to the [0, 1] interval, so as to avoid the influence of dimension difference on the fusion result.

[0080] 2. Secondly, when the suspicious fracture point is located in the program core computing module (such as data encryption, high-frequency loop segment), considering that the static code structure has greater influence on the stability of the dependent chain, the embodiments of the present application can give the static score a weight of 0.6 and the dynamic score a weight of 0.4; when the suspicious fracture point is located in the auxiliary function module (such as log printing, configuration reading), the embodiments of the present application can focus on the runtime data, give the dynamic score a weight of 0.6 and the static score a weight of 0.4, so as to ensure that the fusion result is consistent with the actual role scene of the code.

[0081] 3. The embodiments of the present application take the mean value of the comprehensive fracture scores of the historical programs without fracture risk as the initial threshold value (such as 0.5), then periodically collect the comprehensive fracture score data of the normal code segments of the new detection programs, and update the threshold value by the sliding average method, so as to avoid the threshold value adaptation deviation caused by the difference between the program types (such as real-time program, batch processing program).

[0082] 4. After determining the dependency chain breakpoint, in addition to collecting the conventional code location and breakpoint value, this application embodiment can also additionally associate the instruction sequence differences in static disassembly and the abnormal data of PMU events in dynamic monitoring (such as the period of sudden increase in L1 cache misses), and integrate this information into the detection report in a structured manner. The report also includes breakpoint impact prediction information, which, based on the code logic where the breakpoint is located, infers the possible program abnormalities (such as data calculation errors and running lag).

[0083] Therefore, the embodiments of this application can accurately calculate the comprehensive break score through hierarchical weighted fusion and dynamic threshold calibration, thereby improving the accuracy of dependency chain break point determination, providing clear and accurate data guidance for subsequent positioning and repair, and ensuring the stability of the optimized program.

[0084] Optionally, in one embodiment of this application, the static disassembly channel break score and the dynamic performance monitoring channel break score are fused to obtain a comprehensive break score for suspected breakpoints. This includes: collecting dependency chain break annotation data of historical program samples under different compilation scenarios and corresponding historical static disassembly channel break scores and historical dynamic performance monitoring channel break scores; training a pre-built dependency chain break analysis model based on the dependency chain break annotation data, historical static disassembly channel break scores, and historical dynamic performance monitoring channel break scores; inputting the static disassembly channel break scores and dynamic performance monitoring channel break scores into the trained dependency chain break analysis model to output the static disassembly channel weights corresponding to the static disassembly channel break scores, the dynamic performance monitoring channel weights corresponding to the dynamic performance monitoring channel break scores, and the break threshold; and calculating a comprehensive break score based on the static disassembly channel break scores, static disassembly channel weights, dynamic performance monitoring channel break scores, and dynamic performance monitoring channel weights.

[0085] In the specific implementation process, the embodiments of this application can be classified and stored according to the compilation scenario. Each piece of data contains manually annotated dependency chain break tags, static break scores, dynamic break scores, and compilation parameter metadata to build a multi-dimensional sample library.

[0086] Secondly, the dependency chain breakage analysis model in this application embodiment can adopt a dual-output neural network architecture. Its input layer receives static and dynamic breakage scores, the hidden layer learns the feature importance under different compilation scenarios through an attention mechanism, and the output layer generates static weights, dynamic weights, and breakage thresholds simultaneously, achieving collaborative optimization of the three.

[0087] In the training process of the dependency chain rupture analysis model, the contrast learning strategy can be introduced, that is, the same sample in different compilation scenarios is associated and constrained by the embodiment of the application, the adaptability of the model to the scene difference is enhanced, and the early stopping mechanism is used to prevent overfitting. In the model application, the static disassembly channel rupture score and the dynamic performance monitoring channel rupture score calculated in real time can be input into the dependency chain rupture analysis model to obtain the scene-adapted weight and threshold, and the comprehensive rupture score is obtained by weighted summation, thereby improving the consistency of cross-scene analysis. The calculation expression of the comprehensive rupture score is as follows:

[0088]

[0089] wherein, represents the static disassembly channel weight, which measures the influence degree of the static disassembly channel on the comprehensive rupture score, and can be obtained according to historical experience training; represents the dynamic performance monitoring channel weight, which measures the influence degree of the dynamic PMU channel on the comprehensive rupture score, and can also be obtained according to historical experience training; represents the comprehensive rupture score; represents the static disassembly channel rupture score; represents the dynamic performance monitoring channel rupture score.

[0090] Therefore, the embodiment of the application can train the model based on historical data, dynamically generate the weight and threshold adapted to the scene, thereby improving the accuracy and generalization ability of the comprehensive rupture score calculation, and enhancing the intelligent level of the dependency chain rupture detection.

[0091] Optionally, in an embodiment of the application, the specific process of training the dependency chain rupture analysis model is as follows:

[0092] 1. Data preprocessing: The collected dependency chain rupture annotation data is converted by encoding, the historical static disassembly channel rupture score and the historical dynamic performance monitoring channel rupture score are normalized, and the training set, the validation set and the test set are divided in the ratio of 7:2:1. Over-sampling or weighted loss function is used to balance the samples;

[0093] 2. Training process optimization: the Adam (Adaptive Moment Estimation, adaptive moment estimation) optimization algorithm is used, the multi-task loss function (that is, the fusion of MSE (Mean Squared Error, mean squared error) and MAE (Mean Absolute Error, mean absolute error)) is designed, and the model is trained combined with Dropout, L2 regularization and early stopping strategy. The hyperparameters are optimized through the validation set;

[0094] 3. Model verification: by evaluating the prediction accuracy of the model with the test set, ensure that the output channel weight, fracture threshold meet the error requirements.

[0095] Therefore, the embodiments of the present application can efficiently utilize multi-dimensional data, improve the capture ability of the model for dependency chain fracture features, avoid overfitting, ensure the accuracy of the output channel weight and fracture threshold, and provide reliable model support for subsequent dependency chain fracture analysis.

[0096] Optionally, in an embodiment of the present application, after generating the corresponding detection report according to the dependency chain fracture point information, it further includes: obtaining the dependency chain fracture point information of the detection report, and constructing a standardized analysis data set according to the dependency chain fracture point information; based on the standardized analysis data set, the static disassembly channel and the dynamic performance monitoring channel are subjected to dependency chain fracture point detection performance evaluation to obtain the corresponding evaluation result; based on the evaluation result, the defect information in the dependency chain fracture point detection process is identified, and the static disassembly channel weight and the dynamic performance monitoring channel weight are adjusted according to the defect information, and the new comprehensive fracture score is calculated by using the adjusted static disassembly channel weight and dynamic performance monitoring channel weight, so as to re-perform the dependency chain fracture point judgment operation through the new comprehensive fracture score.

[0097] As a kind of can be realized mode, the specific process of the embodiment of the present application for standardized analysis data set construction, performance evaluation, defect information identification and optimization adjustment is as follows:

[0098] 1. In constructing the standardized analysis data set, the embodiment of the present application can decompose the dependency chain fracture point information into core feature field and associated scene field, wherein the core feature field covers the fracture point code position, static / dynamic fracture score, comprehensive fracture score and judgment result, to ensure the standardization of basic data; the associated scene field supplements the code module type (such as calculation module, IO module) where the fracture point is located, the compilation option (such as -O0 / -O2) and the program running environment parameter (such as CPU model, memory size), to provide the scene analysis dimension for subsequent performance evaluation, and the JSON-LD (JavaScript Object Notation for Linked Data, JSON linked data) format is used to unify the data structure, to facilitate cross-tool calling and analysis.

[0099] 2. In the performance evaluation process, the embodiment of the present application can design a double-dimension multi-index evaluation system:

[0100] (1) The first dimension is "accuracy index", which calculates the true positive rate (the number of correctly detected fracture points / the number of actual fracture points), the false positive rate (the number of misjudged fracture points / the total number of non-fracture points) and the F1 score (the harmonic mean of the comprehensive true positive rate and the precision) of the static disassembly channel and the dynamic performance monitoring channel;

[0101] (2) The second dimension is an "efficiency index", and the average time consumption and resource occupation rate (such as CPU usage and memory consumption) of the two-channel detection of a single dependency chain are counted.

[0102] During the evaluation, the embodiments of the present application can be grouped according to the associated scene field, and the index values under different compilation options and different code modules are calculated respectively to accurately locate the performance short board of the detection in each scene.

[0103] 3. In the process of identifying defect information, the embodiments of the present application can introduce a defect root cause mapping model. Specifically, the embodiments of the present application can match the abnormal index (such as the dynamic channel false positive rate under a certain compilation option is more than 30%) in the evaluation result with the preset defect type library (such as inaccurate dynamic monitoring event filtering and missing static dependency chain comparison logic), and locate the defect root cause by combining historical optimization cases. For example, if the true positive rate of the static channel in the I / O (Input / Output, input / output) intensive module is low, it is determined that "the IO instruction dependency characteristics are not fully considered in the static code structure analysis"; if the dynamic channel consumes too much time in the high-frequency loop module, it is determined that "the PMU monitoring point sampling frequency does not match the cycle period".

[0104] 4. In the process of optimization and adjustment, the embodiments of the present application can adopt a scene-based parameter iterative optimization strategy. Specifically, for the static channel defect, if the IO instruction dependency analysis is insufficient, the static breakage calculation logic is optimized, and the IO instruction dependency weight coefficient is increased; for the dynamic channel defect, if the sampling frequency is not adaptive, the PMU monitoring point sampling interval is dynamically adjusted (such as the sampling interval of the high-frequency loop module is shortened to 1 / 2 of the original interval).

[0105] In addition, the embodiments of the present application can use the iterative process of "small batch verification-feedback adjustment-large scale application" after optimization to ensure that the breakage calculation of the two channels after adjustment is more suitable for the actual detection scene, and to improve the detection accuracy of the actual dependency chain breakage point.

[0106] Therefore, the embodiments of the present application can improve the detection accuracy and efficiency by decomposing the breakage point information to construct a standardized data set and evaluating the detection performance by double-dimensional indexes, and can adapt to different scenes to provide a scientific and accurate optimization path for dependency chain breakage point detection.

[0107] The logic architecture and execution logic of the shared variable dependency chain breakage detection method of the present application are described below by combining the accompanying drawings.

[0108] Figure 2 The logic architecture of the shared variable dependency chain breakage detection method of the present application is shown in the figure. Figure 2As shown, the application can perform instruction sequence detection through the static disassembly channel of the target system to determine suspicious breakpoints in the program to be analyzed, and send the suspicious breakpoints to the dynamic performance monitoring channel for event stream detection, so as to obtain detection results corresponding to the instruction sequence detection and the event stream detection (i.e. static disassembly channel breakpoint score and dynamic performance monitoring channel breakpoint score); then, the embodiments of the application can calculate the comprehensive breakpoint score of the suspicious breakpoints according to the detection results by using the dependency chain breakpoint analysis engine, and determine the dependency chain breakpoints according to the comprehensive breakpoint score, and generate a detection report containing information related to the dependency chain breakpoints.

[0109] Figure 3 The execution logic diagram of the shared variable dependency chain breakpoint detection method of the application is shown in FIG. 3. Figure 3 As shown, the execution process of the shared variable dependency chain breakpoint detection method of the application is as follows:

[0110] S301: The program to be analyzed is compiled using different compilation options to obtain binary executable programs before and after optimization, and the binary executable programs before and after optimization are disassembled to obtain disassembly files before and after optimization, respectively;

[0111] S302: The disassembly files before and after optimization are input into the static disassembly channel for comparative analysis to detect whether there is a suspicious position of dependency chain breakpoint, and if there is, the corresponding position is marked as a suspicious breakpoint;

[0112] S303: The static disassembly channel breakpoint score of each suspicious breakpoint is calculated;

[0113] S304: Performance monitoring points are set at the suspicious breakpoints of the program to be analyzed, and the program to be analyzed after setting the performance monitoring points is recompiled to generate an execution program with performance monitoring points;

[0114] S305: The binary executable program with performance monitoring points is input into the dynamic performance monitoring channel for running, and the occurrence frequency of performance monitoring events related to the dependency chain breakpoint before and after optimization is counted;

[0115] S306: The dynamic performance monitoring channel breakpoint score of each suspicious breakpoint is calculated;

[0116] S307: The dependency chain breakpoint analysis engine calculates the comprehensive breakpoint score of the suspicious breakpoints according to the static disassembly channel breakpoint score and the dynamic performance monitoring channel breakpoint score, and when the comprehensive breakpoint score exceeds the breakpoint threshold, the suspicious breakpoint is determined as a dependency chain breakpoint, and a detection report containing information related to the dependency chain breakpoint is generated.

[0117] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software on a general hardware platform as necessary, and of course can also be realized by hardware, but in many cases the former is a better embodiment.

[0118] Embodiments of the present application also provide a shared variable dependency chain break detection device.

[0119] As shown in Figure 4 The shared variable dependency chain break detection device 10 comprises: a disassembly module 100, an identification module 200, a break score calculation module 300, and a determination module 400.

[0120] The disassembly module 100 is configured to compile and disassemble the program to be analyzed under the conditions of turning off the optimization compilation configuration and turning on the optimization compilation configuration, to obtain the disassembled files before and after optimization, and to compare and analyze the disassembled files before and after optimization to obtain corresponding analysis results.

[0121] The identification module 200 is configured to identify suspicious break points in the program to be analyzed that meet preset dependency chain change requirements based on the analysis results, to determine the dependency chain change requirement types corresponding to the suspicious break points, and to determine the requirement weights of different requirements in the preset dependency chain change requirements according to the dependency chain change requirement types, so as to calculate the static disassembly channel break scores of the suspicious break points by means of the dependency chain change requirement types and the requirement weights.

[0122] The break score calculation module 300 is configured to set performance monitoring points at the suspicious break points, to recompile the program to be analyzed after the performance monitoring points are set, to generate an execution program with the performance monitoring points, and to run the execution program with the performance monitoring points, so as to determine the occurrence numbers of performance monitoring events that meet preset dependency chain break correlation requirements occurring before and after optimization of the program to be analyzed, and to calculate the dynamic performance monitoring channel break scores of the suspicious break points according to the occurrence numbers.

[0123] The determination module 400 is configured to calculate the comprehensive break scores of the suspicious break points according to the static disassembly channel break scores and the dynamic performance monitoring channel break scores, and to determine whether the comprehensive break scores are greater than a break threshold value, wherein when the comprehensive break scores are greater than the break threshold value, the suspicious break points are determined to be dependency chain break points.

[0124] Optionally, in an embodiment of the present application, the disassembly module 100 comprises a first compilation unit and a generation unit.

[0125] The first compiling unit is configured to compile the program to be analyzed to obtain a pre-optimization compiling file when the optimization compiling configuration is closed, and compile the program to be analyzed to obtain a post-optimization compiling file when the optimization compiling configuration is opened.

[0126] The generating unit is configured to perform a disassembly operation on the pre-optimization compiling file and the post-optimization compiling file respectively to generate corresponding pre-optimization and post-optimization disassembly files.

[0127] Optionally, in an embodiment of the present application, the disassembly module 100 further comprises an analyzing unit and a comparing unit.

[0128] The analyzing unit is configured to input the pre-optimization and post-optimization disassembly files into a preset static disassembly channel to perform code structural analysis on the disassembly files respectively to generate structural code data containing instruction types, operation objects and code location information.

[0129] The comparing unit is configured to perform dependency chain comparison on code segments in the pre-optimization and post-optimization disassembly files based on the structural code data to obtain corresponding comparison data, and analyze code locations in the code segments that meet preset dependency chain change requirements according to the comparison data to obtain an analysis result.

[0130] Optionally, in an embodiment of the present application, the identifying module 200 comprises a determining unit, a judging unit and a first calculating unit.

[0131] The determining unit is configured to determine, based on the analysis result, code locations in the code segments of the pre-optimization and post-optimization disassembly files corresponding to the program to be analyzed that meet preset dependency chain change requirements, and take the code locations as corresponding suspicious breakpoints, wherein the preset dependency chain change requirements include that a data copy instruction sequence is replaced by independent memory access, an intermediate variable is optimized and eliminated, and memory access order is changed.

[0132] The judging unit is configured to judge a dependency chain change requirement type to which a current suspicious breakpoint belongs, and assign values to preset dependency chain change indicators according to the dependency chain change requirement type.

[0133] The first calculating unit is configured to determine, based on the dependency chain change requirement type, a data copy instruction sequence weight, an intermediate variable weight and a memory access order weight corresponding to the suspicious breakpoint, and calculate a static disassembly channel breaking score according to the data copy instruction sequence weight, the intermediate variable weight, the memory access order weight and the assigned dependency chain change indicators.

[0134] Optionally, in an embodiment of the present application, the breaking score calculating module 300 comprises a setting unit, a second compiling unit, a monitoring unit, a statistical unit and a second calculating unit.

[0135] The setting unit is configured to set a performance monitoring point at the suspicious breaking point to generate corresponding program intermediate code.

[0136] The second compiling unit is configured to compile the program intermediate code by using different compiling options to generate an execution program with the performance monitoring point.

[0137] The monitoring unit is configured to run the execution program with the performance monitoring point in a preset dynamic performance monitoring channel to monitor a performance monitoring event that meets a preset dependence chain breaking correlation requirement before and after optimization.

[0138] The statistical unit is configured to count a number of occurrences of the performance monitoring event that meets the preset dependence chain breaking correlation requirement, wherein the performance monitoring event includes a first-level cache hit number or a miss number, a second-level cache hit number or a miss number, and a number of consumed instruction cycles.

[0139] The second calculating unit is configured to calculate a dynamic performance monitoring channel breaking score of the suspicious breaking point based on the number of occurrences.

[0140] Optionally, in an embodiment of the present application, the second calculating unit includes a matrix calculating subunit and a weight calculating subunit.

[0141] The matrix calculating subunit is configured to calculate a first-level cache hit number difference, a first-level miss number difference, a second-level cache hit number difference, a second-level miss number difference, and a number of consumed instruction cycle differences before and after optimization, and construct a breaking feature matrix based on the first-level cache hit number difference, the first-level miss number difference, the second-level cache hit number difference, the second-level miss number difference, and the number of consumed instruction cycle differences.

[0142] The weight calculating subunit is configured to determine weights of different performance monitoring events, and calculate the dynamic performance monitoring channel breaking score based on the breaking feature matrix and the weights of the different performance monitoring events.

[0143] Optionally, in an embodiment of the present application, the determining module 400 includes a comparison unit, a first analysis unit, and a second analysis unit.

[0144] The comparison unit is configured to perform fusion calculation on the static reverse assembly channel breaking score and the dynamic performance monitoring channel breaking score to obtain a comprehensive breaking score of the suspicious breaking point, and compare the comprehensive breaking score with a preset breaking threshold.

[0145] The first analysis unit is configured to determine that the corresponding suspicious breaking point is not a dependence chain breaking point when the comprehensive breaking score is less than or equal to the breaking threshold.

[0146] The second analysis unit is configured to determine that the corresponding suspicious breaking point is a dependency chain breaking point when the comprehensive breaking score is greater than the breaking threshold, and collect dependency chain breaking point information corresponding to the dependency chain breaking point, so as to generate a corresponding detection report according to the dependency chain breaking point information.

[0147] Optionally, in an embodiment of the present application, the comparison unit comprises a collection subunit, a training subunit, an input subunit and an operation subunit.

[0148] The collection subunit is configured to collect dependency chain breaking label data of the historical program sample under different compilation scenarios and historical static reverse assembly channel breaking scores and historical dynamic performance monitoring channel breaking scores corresponding to the dependency chain breaking label data.

[0149] The training subunit is configured to train a pre-constructed dependency chain breaking analysis model based on the dependency chain breaking label data, the historical static reverse assembly channel breaking scores and the historical dynamic performance monitoring channel breaking scores.

[0150] The input subunit is configured to input the static reverse assembly channel breaking score and the dynamic performance monitoring channel breaking score into the trained dependency chain breaking analysis model, so as to output a static reverse assembly channel weight corresponding to the static reverse assembly channel breaking score, a dynamic performance monitoring channel weight corresponding to the dynamic performance monitoring channel breaking score and a breaking threshold.

[0151] The operation subunit is configured to calculate a comprehensive breaking score based on the static reverse assembly channel breaking score, the static reverse assembly channel weight, the dynamic performance monitoring channel breaking score and the dynamic performance monitoring channel weight.

[0152] Optionally, in an embodiment of the present application, the shared variable dependency chain breaking detection device 10 further comprises an acquisition module, an evaluation module and an optimization module.

[0153] The acquisition module is configured to acquire the dependency chain breaking point information of the detection report after the corresponding detection report is generated according to the dependency chain breaking point information, and construct a standardized analysis data set according to the dependency chain breaking point information.

[0154] The evaluation module is configured to perform dependency chain breaking point detection performance evaluation on the static reverse assembly channel and the dynamic performance monitoring channel based on the standardized analysis data set, so as to obtain a corresponding evaluation result.

[0155] The optimization module is configured to identify defect information in the dependency chain breaking point detection process based on the evaluation result, adjust the static reverse assembly channel weight and the dynamic performance monitoring channel weight according to the defect information, and calculate a new comprehensive breaking score by using the adjusted static reverse assembly channel weight and the dynamic performance monitoring channel weight, so as to perform a dependency chain breaking point determination operation again by using the new comprehensive breaking score.

[0156] The features of the embodiments of the shared variable dependency chain breaking detection device can be referred to the related descriptions of the embodiments of the shared variable dependency chain breaking detection method, which will not be repeated here.

[0157] The embodiments of the present application also provide an electronic device, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above-mentioned embodiments of the shared variable dependency chain breaking detection method.

[0158] The embodiments of the present application also provide a non-volatile computer readable storage medium, which stores a computer program, wherein the computer program is configured to perform the steps in any of the above-mentioned embodiments of the shared variable dependency chain breaking detection method when running.

[0159] In an example embodiment, the above-mentioned non-volatile computer readable storage medium can include but is not limited to: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.

[0160] The embodiments of the present application also provide a computer program product, which comprises a computer program, and the computer program is executed by a processor to implement the steps in any of the above-mentioned embodiments of the shared variable dependency chain breaking detection method.

[0161] The embodiments of the present application also provide another computer program product, which comprises a non-volatile computer readable storage medium, and the non-volatile computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in any of the above-mentioned embodiments of the shared variable dependency chain breaking detection method.

[0162] The skilled person can further realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the above description. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0163] The above describes in detail a shared variable dependency chain breaking detection method, device, equipment and medium provided by the present application. The principles and implementation modes of the present application are described by applying specific examples, and the above description of the embodiments is only used to help understand the method of the present application and its core idea. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, the present application can be improved and modified in several ways, and these improvements and modifications also fall within the protection scope of the claims of the present application.

Claims

1. A method for detecting broken shared variable dependency chains, characterized in that, The method comprises the following steps: compiling and disassembling the program to be analyzed under the condition of closing and opening the optimization compilation configuration respectively to obtain the disassembled files before and after optimization, and comparing and analyzing the disassembled files before and after optimization to obtain the corresponding analysis result; based on the analysis result, identifying the suspicious breaking point in the program to be analyzed that meets the preset dependency chain change requirement, determining the dependency chain change requirement type corresponding to the suspicious breaking point, and determining the requirement weight corresponding to different requirements in the preset dependency chain change requirement according to the dependency chain change requirement type, to calculate the static disassembled channel breaking score of the suspicious breaking point through the dependency chain change requirement type and the requirement weight; setting a performance monitoring point at the suspicious breaking point, and recompiling the program to be analyzed after setting the performance monitoring point to generate an execution program with a performance monitoring point, and running the execution program with a performance monitoring point to determine the occurrence number of the performance monitoring event that meets the preset dependency chain breaking relevance requirement before and after optimization of the program to be analyzed, and calculating the dynamic performance monitoring channel breaking score of the suspicious breaking point according to the occurrence number; calculating the comprehensive breaking score of the suspicious breaking point according to the static disassembled channel breaking score and the dynamic performance monitoring channel breaking score, and judging whether the comprehensive breaking score is greater than the breaking threshold, wherein when the comprehensive breaking score is greater than the breaking threshold, the suspicious breaking point is determined as a dependency chain breaking point.

2. The shared variable dependency chain breakage detection method of claim 1, wherein, The method of compiling and disassembling the program to be analyzed to obtain the disassembled files before and after optimization comprises: compiling the program to be analyzed under the condition of closing the optimization compilation configuration to obtain the compiled file before optimization, and compiling the program to be analyzed under the condition of opening the optimization compilation configuration to obtain the compiled file after optimization; respectively performing disassembling operation on the compiled file before optimization and the compiled file after optimization to generate the corresponding disassembled files before and after optimization.

3. The shared variable dependency chain breakage detection method of claim 2, wherein, The method of comparing and analyzing the disassembled files before and after optimization to obtain the corresponding analysis result comprises: inputting the disassembled files before and after optimization into the preset static disassembled channel to respectively perform code structure analysis on the disassembled files to generate structured code data containing instruction type, operation object and code location information; based on the structured code data, comparing the code segments in the disassembled files before and after optimization to obtain the corresponding comparison data, and analyzing the code location in the code segment that meets the preset dependency chain change requirement according to the comparison data to obtain the analysis result.

4. The shared variable dependency chain breakage detection method of claim 3, wherein, The suspicious breaking point meeting the preset dependency chain change requirement is identified based on the analysis result, and a dependency chain change requirement type corresponding to the suspicious breaking point is determined, and a requirement weight corresponding to different requirements in the preset dependency chain change requirement is determined according to the dependency chain change requirement type, so as to calculate a static reverse assembly channel breaking score of the suspicious breaking point by using the dependency chain change requirement type and the requirement weight, including: Based on the analysis result, code positions meeting the preset dependency chain change requirement in code segments of the reverse assembly files before and after optimization corresponding to the program to be analyzed are determined, and the code positions are taken as corresponding suspicious breaking points, wherein the preset dependency chain change requirement includes that a data copy instruction sequence is replaced by independent memory access, an intermediate variable is optimized and eliminated, and a memory access order is changed; A dependency chain change requirement type to which the current suspicious breaking point belongs is judged, and a preset dependency chain change index is valued according to the dependency chain change requirement type; Based on the dependency chain change requirement type, a data copy instruction sequence weight, an intermediate variable weight and a memory access order weight corresponding to the suspicious breaking point are determined, and a static reverse assembly channel breaking score is calculated according to the data copy instruction sequence weight, the intermediate variable weight, the memory access order weight and the valued dependency chain change index.

5. The shared variable dependency chain breakage detection method of claim 1, wherein, The performance monitoring point is set at the suspicious breaking point, and the program to be analyzed after the performance monitoring point is set is recompiled to generate an execution program with the performance monitoring point, and the execution program with the performance monitoring point is run to determine a number of performance monitoring events meeting a preset dependency chain breaking relevance requirement occurring before and after optimization of the program to be analyzed, and a dynamic performance monitoring channel breaking score of the suspicious breaking point is calculated according to the number, including: The performance monitoring point is set at the suspicious breaking point to generate corresponding program intermediate code; The program intermediate code is compiled by using different compilation options to generate the execution program with the performance monitoring point; The execution program with the performance monitoring point is run in a preset dynamic performance monitoring channel to monitor the performance monitoring events meeting the preset dependency chain breaking relevance requirement before and after optimization; The number of performance monitoring events meeting the preset dependency chain breaking relevance requirement is counted, wherein the performance monitoring events include a first-level cache hit number or a missing number, a second-level cache hit number or a missing number, and a consumed instruction cycle number; Based on the number, the dynamic performance monitoring channel breaking score of the suspicious breaking point is calculated.

6. The shared variable dependency chain breakage detection method of claim 5, wherein, The dynamic performance monitoring channel breaking score of the suspicious breaking point is calculated based on the number, including: The first-level cache hit number difference, the first-level miss number difference, the second-level cache hit number difference, the second-level miss number difference, and the consumed instruction cycle number difference before and after the calculation are calculated, and a break feature matrix is constructed based on the first-level cache hit number difference, the first-level miss number difference, the second-level cache hit number difference, the second-level miss number difference, and the consumed instruction cycle number difference. The weights of different performance monitoring events are determined, and the dynamic performance monitoring channel break score is calculated based on the break feature matrix and the weights of the different performance monitoring events.

7. The shared variable dependency chain breakage detection method of claim 1, wherein, The comprehensive break score of the suspicious break point is calculated according to the static disassembly channel break score and the dynamic performance monitoring channel break score, and it is judged whether the comprehensive break score is greater than a break threshold value, wherein when the comprehensive break score is greater than the break threshold value, the suspicious break point is determined to be a dependency chain break point, comprising: The static disassembly channel break score and the dynamic performance monitoring channel break score are fused and calculated to obtain the comprehensive break score of the suspicious break point, and the comprehensive break score is compared with a preset break threshold value; When the comprehensive break score is less than or equal to the break threshold value, it is determined that the corresponding suspicious break point is not a dependency chain break point; When the comprehensive break score is greater than the break threshold value, it is determined that the corresponding suspicious break point is a dependency chain break point, and the dependency chain break point information corresponding to the dependency chain break point is collected to generate a corresponding detection report according to the dependency chain break point information.

8. The shared variable dependency chain breakage detection method of claim 7, wherein, The static disassembly channel break score and the dynamic performance monitoring channel break score are fused and calculated to obtain the comprehensive break score of the suspicious break point, comprising: The dependency chain break labeling data of historical program samples under different compilation scenarios and the historical static disassembly channel break score and the historical dynamic performance monitoring channel break score corresponding to the dependency chain break labeling data are collected; A pre-constructed dependency chain break analysis model is trained based on the dependency chain break labeling data, the historical static disassembly channel break score, and the historical dynamic performance monitoring channel break score; The static disassembly channel break score and the dynamic performance monitoring channel break score are input into the trained dependency chain break analysis model to output the static disassembly channel weight corresponding to the static disassembly channel break score, the dynamic performance monitoring channel weight corresponding to the dynamic performance monitoring channel break score, and the break threshold value; The comprehensive break score is calculated based on the static disassembly channel break score, the static disassembly channel weight, the dynamic performance monitoring channel break score, and the dynamic performance monitoring channel weight.

9. The shared variable dependency chain breakage detection method of claim 7, wherein, After generating the corresponding detection report according to the dependency chain break point information, it further comprises: The dependency chain break point information of the detection report is obtained, and a standardized analysis data set is constructed according to the dependency chain break point information; The dependency chain break point detection performance of the static disassembly channel and the dynamic performance monitoring channel is evaluated based on the standardized analysis data set to obtain a corresponding evaluation result; Based on the evaluation result, a defect information in the dependency chain breaking point detection process is identified, and the static reverse assembly channel weight and the dynamic performance monitoring channel weight are adjusted according to the defect information, and a new comprehensive breaking score is calculated by using the adjusted static reverse assembly channel weight and the dynamic performance monitoring channel weight, so as to re-perform the dependency chain breaking point judgment operation through the new comprehensive breaking score.

10. An electronic device, comprising: The method comprises the steps of: a memory for storing a computer program; a processor for implementing the steps of the shared variable dependency chain breaking detection method according to any one of claims 1 to 9 when executing the computer program.

Citation Information

Patent Citations

  • Software vulnerability detection method based on static analysis and dynamic analysis

    CN116049831A

  • Vulnerability identification method based on semantic learning of slice code dependency graph

    CN116305158A