Configuration method, dynamic detection method for array subscript out-of-bounds, distributed control system

By establishing an array memory model in the ST compiler of the decentralized control system and adding dynamic inspection code, the problem of array subscripts is solved, and effective memory protection and data integrity are achieved.

CN113849395BActive Publication Date: 2025-03-11SUPCON TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110914676.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-10
Publication Date
2025-03-11
Estimated Expiration
2041-08-10

AI Technical Summary

Technical Problem

The prior art cannot effectively detect and prevent the problem of array subscripts crossing boundaries in decentralized control systems, resulting in serious memory data corruption.

Method used

By establishing an array memory model in the ST compiler and adding code snippets for dynamic checking of array subscripts out of bounds during the compilation and conversion process, the tri-item condition operator is used to check whether the array subscript is out of bounds when the controller is running.

Benefits of technology

It realizes dynamically detecting whether the memory is out of bounds when the control program is running, avoiding the memory data integrity of other variables in the data area due to out-of-bounds access of the array, thereby effectively protecting memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113849395B_ABST
    Figure CN113849395B_ABST
Patent Text Reader

Abstract

The present application relates to a configuration method for array subscript out-of-bounds check, including: an ST editor generates a control program written in a structured text language; an ST compiler establishes a corresponding array memory model for each array object in the control program; the ST compiler compiles the control program into C language code, and during the compilation and conversion process, for array elements with non-constant expressions in the subscript, a code snippet for dynamic array subscript out-of-bounds check is added, and the C language code address expression of the array element is embedded into the code snippet; the code snippet is implemented using a ternary conditional operator; the C compiler compiles the C language code containing the code snippet into a corresponding binary file and downloads it to the target controller, so that the target controller can check whether the array subscript is out of bounds according to the conditional expression in the ternary conditional operator when the target controller is running. The present application method can dynamically detect whether the memory is out of bounds when the control program is running.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of industrial control technology, and specifically relates to a dynamic detection method for configuration methods and array subscript out-of-bounds. Background Art

[0002] The Structured Text (ST) language can be used to write control programs for distributed control system (DCS) controllers. During the configuration process of the DCS system, the control program written in ST language is compiled and converted into a binary file, and then downloaded to the controller together with the initial data values ​​of the program. The process of compiling and converting the control program written in ST language into a binary file includes:

[0003] The ST compiler allocates a continuous memory space for the variable (including array) according to its size (array size is the size of a single array element × the number of elements in the array), including the starting offset address and storage space size.

[0004] Convert the program written in ST language into C language code, and compile the C language code into the corresponding binary file through the C compiler corresponding to the controller.

[0005] The size of the array object in the ST language is specified by the user when writing the ST program. In the C code after the ST code is converted, the elements of the array are accessed and operated through the starting offset address (pointer) of the array in the memory and the array subscript.

[0006] Since out-of-bounds access to an array may modify the memory values ​​of other addresses in the data area and thus cause serious consequences, it is necessary to perform out-of-bounds checks on array subscript operation statements: when the subscript used in array access is a constant expression, such as A

[15] , B[3,11], A[5+3], the ST compiler can statically detect whether the array subscript access is out-of-bounds by analyzing the syntax tree of the ST code; but when the subscript used in array access is a variable, such as access to array element A[x], the value of the array subscript variable x can only be determined at runtime, and the existing out-of-bounds check cannot confirm whether the subscript x of A[x] exceeds the bounds of array A, thereby achieving memory out-of-bounds checking and protection. Summary of the invention

[0007] 1. Technical issues to be resolved

[0008] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present application provides a method for dynamically detecting a configuration method and an array subscript out-of-bounds condition.

[0009] (II) Technical solution

[0010] In order to achieve the above purpose, this application adopts the following technical solutions:

[0011] In a first aspect, an embodiment of the present application provides a configuration method for array subscript out-of-bounds checking, the method comprising:

[0012] The ST editor generates control programs written in structured text language;

[0013] The ST compiler establishes a corresponding array memory model for each array object in the control program, wherein the array memory model includes the total number of dimensions of the array, the number of elements in each dimension, and all elements of the array;

[0014] The ST compiler compiles and converts the control program into C language code. During the compilation and conversion process, for array elements with non-constant expressions in the subscripts, a code snippet for dynamic check of array subscript out-of-bounds is added, and the C language code address expression of the array element is embedded in the code snippet; the code snippet is implemented using a ternary conditional operator;

[0015] The C compiler compiles the C language code containing the code snippet into a corresponding binary file and downloads it to the target controller, so that when the target controller runs, it checks whether the array subscript is out of bounds according to the conditional expression in the ternary conditional operator.

[0016] Optionally, a custom CheckInd function is used in the conditional expression to determine whether each non-constant expression has an out-of-bounds subscript, and the parameters of the CheckInd function include: the starting address ADDR of the array object, the dimension number i, and the non-constant subscript expression IND_EXPi of the i-th dimension.

[0017] Optionally, the non-constant subscript expression IND_EXPi of the i-th dimension contains array elements.

[0018] Optionally, in the ternary conditional operator:

[0019] The first expression embeds the C language code address expression of the array element;

[0020] The second expression is a preset code block that is executed when the subscript is out of bounds.

[0021] Optionally, the execution result of the code block executed when the subscript is out of bounds is a preset memory address.

[0022] Optionally, the code snippet also includes the data types of the array elements.

[0023] In a second aspect, an embodiment of the present application provides a method for dynamically detecting array subscript out-of-bounds in a control program, the method comprising:

[0024] The controller receives a control program sent by an engineering station, wherein the control program is obtained by the configuration method for array subscript out-of-bounds check as described in any one of the first aspects above;

[0025] When the controller is running, the ternary conditional operation in the control program is executed to check whether the array index is out of bounds.

[0026] In a third aspect, an embodiment of the present application provides a distributed control system, comprising an engineer station and a controller, wherein the engineer station configures the distributed control system using the configuration method for array subscript out-of-bounds check as described in any one of the first aspects above, and the control program performs dynamic check for array subscript out-of-bounds using the steps of the dynamic detection method for array subscript out-of-bounds in the control program described in the second aspect above.

[0027] In a fourth aspect, an embodiment of the present application provides a controller, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the dynamic detection method for array subscript out-of-bounds in the control program as described in the second aspect above.

[0028] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the dynamic detection method for array subscript out-of-bounds in the control program as described in the second aspect above are implemented.

[0029] (III) Beneficial effects

[0030] The beneficial effects of the present application are as follows: the present application proposes a configuration method for array subscript out-of-bounds checking, including: the ST editor generates a control program written in a structured text language; the ST compiler establishes a corresponding array memory model for each array object in the control program; the ST compiler compiles the control program into C language code, and during the compilation and conversion process, for array elements with non-constant expressions in the subscript, a code snippet for dynamic checking of array subscript out-of-bounds is added, and the C language code address expression of the array element is embedded into the code snippet; the code snippet is implemented using a ternary conditional operator; the C compiler compiles the C language code containing the code snippet into a corresponding binary file and downloads it to the target controller, so that the target controller can check whether the array subscript is out of bounds according to the conditional expression in the ternary conditional operator when it is running. The method of the present application can dynamically detect whether the memory is out of bounds when the control program is running.

[0031] Furthermore, when the subscript is out of bounds, a preset code block is executed to avoid damaging the memory data integrity of other variables in the data area due to out-of-bounds access to the array, thereby achieving effective protection against subscript out-of-bounds. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The present application is described with the aid of the following drawings:

[0033] Figure 1 A schematic diagram of a configuration method flow for array subscript out-of-bounds checking in one embodiment of the present application is shown;

[0034] Figure 2 A schematic diagram of the memory model structure of an array object in one embodiment of the present application is shown;

[0035] Figure 3 An example diagram of a memory model structure of a 3×4 two-dimensional array in one embodiment of the present application is shown;

[0036] Figure 4 An example diagram of an array element C code expression template with out-of-bounds detection and protection in one embodiment of the present application is shown;

[0037] Figure 5 This is a flow chart of a method for dynamically detecting array subscript out-of-bounds in a control program in another embodiment of the present application;

[0038] Figure 6 This is a schematic diagram of the structure of a distributed control system in another embodiment of the present application;

[0039] Figure 7 It is a schematic diagram of the architecture of a controller in yet another embodiment of the present application. DETAILED DESCRIPTION

[0040] In order to better explain the present invention and facilitate understanding, the present invention is described in detail below in conjunction with the accompanying drawings through specific implementation methods. It is understood that the specific embodiments described below are only used to explain the relevant inventions, rather than to limit the invention. It should also be noted that the embodiments and features in the embodiments of this application can be combined with each other in the absence of conflict; for ease of description, only the parts related to the invention are shown in the accompanying drawings.

[0041] Figure 1 FIG. 1 is a flow chart of a configuration method for array subscript out-of-bounds checking in one embodiment of the present application. Figure 1 As shown, the method of this embodiment includes:

[0042] S10, ST editor generates control programs written in structured text language;

[0043] S20, the ST compiler establishes a corresponding array memory model for each array object in the control program, where the array memory model includes the total number of dimensions of the array, the number of elements in each dimension, and all elements of the array;

[0044] S30, ST compiler compiles and converts the control program into C language code. During the compilation and conversion process, for array elements with non-constant expressions in the subscript, a code snippet for dynamic check of array subscript out of bounds is added, and the C language code address expression of the array element is embedded in the code snippet; the code snippet is implemented using a ternary conditional operator;

[0045] S40. The C compiler compiles the C language code containing the code snippet into a corresponding binary file and downloads it to the target controller, so that when the target controller runs, it checks whether the array subscript is out of bounds according to the conditional expression in the ternary conditional operator.

[0046] The configuration method for array subscript out-of-bounds checking of this embodiment can dynamically detect whether the memory is out of bounds when the control program is running.

[0047] In order to better understand the present invention, each step in this embodiment is described below.

[0048] In S10, the control program may be obtained by engineers through configuration programming in control logic configuration software, and specifically, may be a control program written in a structured text language.

[0049] In S20, the array memory model includes the total number of array dimensions, the number of elements in each dimension, and all elements of the array. Figure 2 A schematic diagram of the memory model structure of an array object in an embodiment of the present application is shown. Figure 2 As shown in the figure, in the continuous memory allocated for the array object, the first part is the total dimension size of the array, followed by the size of each dimension of the array, and finally all the elements of the array. The multi-dimensional array elements are linearly expanded from low to high according to the address. The total number of array dimensions and the number of memory bytes allocated for the size of each dimension are allocated according to the limitations of the specific system. Only its logical model is described here. Figure 3 An example diagram of the memory model structure of a 3×4 two-dimensional array in one embodiment of the present application is shown.

[0050] In S30, the code snippet for dynamic checking of array subscript out of bounds is implemented using a ternary conditional operator. The ternary conditional operator is: conditional expression? first expression: second expression. When executing, the conditional expression is calculated first, and then a judgment is made. If the value of the conditional expression is true, the value of the first expression is calculated, and the result of the operation is the value of the first expression; otherwise, the value of the second expression is calculated, and the result of the operation is the value of the second expression.

[0051] In this embodiment, a custom CheckInd function is used in the conditional expression to determine whether the subscript of each non-constant expression is out of bounds. The parameters of the CheckInd function include: the starting address ADDR of the array object, the dimension number i, and the non-constant subscript expression IND_EXPi of the i-th dimension.

[0052] It should be noted that the non-constant subscript expression IND_EXPi of the i-th dimension can also contain array elements.

[0053] In this embodiment, the first expression embeds the C language code address expression of the array element;

[0054] In this embodiment, the second expression is a preset code block for execution when the subscript is out of bounds. Specifically, the execution result of the code block for execution when the subscript is out of bounds is a preset memory address.

[0055] In this embodiment, the code snippet also includes the data type of the array element.

[0056] The present invention aims to improve the memory allocation method of an array and add a runtime dynamic array subscript check during code compilation to avoid out-of-bounds access and operation of array subscripts during runtime.

[0057] A specific example is given below.

[0058] In the existing method, after the ST statement for array element subscript access is converted into C language code, the C code directly accesses the array elements in the manner of (array first address + subscript offset). If the subscript offset is not a constant, this method may cause out-of-bounds memory access at runtime.

[0059] In this example, according to the array dimension information provided by the aforementioned array object memory model, during the ST code compilation and conversion process, when traversing to the array element node of the ST syntax tree, if there is a non-constant expression in the subscript of the current array element node, the converted C code address expression of the ordinary array element is embedded in the out-of-bounds protection code fragment. The out-of-bounds protection code can be implemented by the ternary conditional operator of the C language.

[0060] Figure 4 An example diagram of an array element C code expression template with cross-bounds detection and protection in one embodiment of the present application is shown. The C code expression of the protected array element will be converted into the following Figure 4 The form shown.

[0061] The following is a description of each code block in the expression.

[0062] (1)DataType

[0063] The data type of the array element, such as integer int, floating point float. This is used for address (pointer) type conversion.

[0064] (2) CheckIndices code block

[0065] The CheckIndices code block is a collection of out-of-bounds checks for each non-constant index. The C code is in the form of formula (1):

[0066] (CheckInd(ADDR,DIM_SIZE1,IND_EXP1)&&...CheckInd(ADDR,DIM_SIZEn,IND_EXPn)) (1)

[0068] The CheckIndices code block performs an out-of-bounds check for each non-constant subscript, where the CheckInd function is based on Figure 2 The memory model shown performs subscript out-of-bounds checks, where the function parameters are:

[0069] ADDR is the starting address of the array object;

[0070] DIM_SIZEi represents the ordinal number of the dimension (starting from 0);

[0071] IND_EXPi is the non-constant subscript expression of the i-th dimension;

[0072] CheckInd(ADDR,DIM_SIZEi,IND_EXPi) means checking whether the subscript IND_EXPi of the DIM_SIZEith dimension of the array object starting from ADDR is legal (i.e. the subscript is not out of bounds). Only when all non-constant subscripts pass the out-of-bounds check, that is, the expression in formula (1) is true, the expression of the current array element (the code of ArrayElementExp) can be used. Note that since IND_EXPi may contain array elements, IND_EXPi may be recursively nested. Figure 4 The C code snippet shown.

[0073] (3)ArrayElementExp code block

[0074] This code block is a C language expression of the array element converted according to the array object starting address + array first element offset + array element subscript offset. Since the subscript of an array element may also be an array element, this code segment may be recursively nested. Figure 4 The C code snippet shown.

[0075] (4) ErrorHandler code block

[0076] ErrorHandler is an error handler. When the CheckIndices result fails (the value is 0), the error handler will be called. The ErrorHandler expression can return a safe memory address, which can be used for operation when the program runs incorrectly. The error handler has different processing methods in different applications, which will not be described in detail in this embodiment.

[0077] Memory out-of-bounds access during ST program runtime is often caused by programming errors, which are generally difficult to detect and test during the programming stage, and errors in memory out-of-bounds access during runtime often bring serious consequences. The configuration method provided in this embodiment can dynamically detect whether the subscript access of an array is out of bounds during runtime, avoiding the destruction of the memory data integrity of other variables in the data area due to array out-of-bounds access.

[0078] In a second aspect, the present application provides a method for dynamically detecting array subscript out-of-bounds in a control program. Figure 5 FIG. 1 is a flow chart of a method for dynamically detecting array subscript out-of-bounds in a control program in another embodiment of the present application. Figure 5 As shown, the method includes:

[0079] S100, the controller receives a control program sent by an engineering station, where the control program is obtained by any configuration method for array subscript out-of-bounds check in the first aspect above;

[0080] S200, when the controller is running, executes the ternary conditional operation in the control program to check whether the array index is out of bounds.

[0081] In this embodiment, the controller is responsible for collecting data from the field, executing control logic operations, outputting control instructions to the input / output devices, and performing data exchange with the host computer operator station.

[0082] Furthermore, the method further comprises:

[0083] S300: Access a corresponding array element or access a preset memory address according to the detection result.

[0084] This embodiment provides a method for detecting and protecting ST program array element runtime out-of-bounds operations. Compared with the existing compile-time static memory out-of-bounds detection method, it adds protection for program data in memory during program execution.

[0085] In a third aspect, an embodiment of the present application provides a distributed control system; Figure 6 FIG. 1 is a schematic diagram of a distributed control system structure in another embodiment of the present application. Figure 6As shown, the system includes an engineer station and a controller. The engineer station uses any configuration method for array subscript out-of-bounds check in the first aspect above to configure the distributed control system, and the control program uses the steps of the dynamic detection method for array subscript out-of-bounds in any control program in the second aspect above to dynamically check for array subscript out-of-bounds.

[0086] This embodiment discloses a distributed control system, which improves the memory allocation method of the array during the configuration process on the engineer station, and adds a runtime dynamic array subscript check during the code compilation process, thereby preventing array out-of-bounds operations when the controller is running. The runtime array out-of-bounds detection and protection can effectively prevent illegal memory access caused by human errors during ST program writing, and avoid controller operation errors caused by this.

[0087] In a fourth aspect, an embodiment of the present application provides a controller, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the dynamic detection method for array subscript out-of-bounds in the control program as described in the second aspect above are implemented.

[0088] Figure 7 It is a schematic diagram of the architecture of a controller in yet another embodiment of the present application.

[0089] Figure 7 The controller shown may include: at least one processor 101, at least one memory 102, at least one network interface 104 and other user interfaces 103. The various components in the controller are coupled together via a bus system 105. It is understood that the bus system 105 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 105 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the bus system 105 is not described in detail. Figure 7 Various buses are labeled as bus system 105 .

[0090] The user interface 103 may include a display, a keyboard, or a pointing device (eg, a mouse, a trackball, or a touch pad).

[0091] It can be understood that the memory 102 in this embodiment can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct memory bus random access memory (DRRAM). The memory 62 described herein is intended to include, but is not limited to, these and any other suitable types of memory.

[0092] In some implementations, the memory 102 stores the following elements, executable units or data structures, or a subset thereof, or an extended set thereof: an operating system 1021 and application programs 1022 .

[0093] The operating system 1021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic services and process hardware-based tasks. The application program 622 includes various application programs, which are used to implement various application services. The control program for implementing the method of the embodiment of the present invention can be included in the application program 1022.

[0094] In the embodiment of the present invention, the processor 101 calls the program or instructions stored in the memory 102, specifically, the program or instructions stored in the application 1022, and the processor 101 is used to execute the method steps provided in the first aspect.

[0095] The method disclosed in the above embodiment of the present invention can be applied to the processor 101, or implemented by the processor 101. The processor 101 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 101 or the instruction in the form of software. The above processor 101 can be a general processor, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or the hardware and software units in the decoding processor can be executed. The software unit can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 102, and the processor 101 reads the information in the memory 102 and completes the steps of the above method in combination with its hardware.

[0096] In addition, in combination with the dynamic detection method for array subscript out-of-bounds in the control program in the above-mentioned embodiment, an embodiment of the present invention may provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the dynamic detection method for array subscript out-of-bounds in the control program in any one of the above method embodiments are implemented.

[0097] It should be noted that in the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention may be implemented by means of hardware comprising several distinct components and by means of a suitably programmed computer. The use of the words first, second, third, etc., is for convenience of expression only and does not imply any order. These words may be understood as part of the component name.

[0098] In addition, it should be noted that, in the description of this specification, the description of the terms "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0099] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments after knowing the basic creative concept. Therefore, the claims should be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.

[0100] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include these modifications and variations.

Claims

1. A configuration method for array subscript out-of-bounds checking, characterized in that: The method includes: The ST editor generates control programs written in structured text language; The ST compiler establishes a corresponding array memory model for each array object in the control program, wherein the array memory model includes the total number of dimensions of the array, the number of elements in each dimension, and all elements of the array; The ST compiler compiles and converts the control program into C language code. During the compilation and conversion process, for array elements with non-constant expressions in the subscripts, a code snippet for dynamic check of array subscript out-of-bounds is added, and the C language code address expression of the array element is embedded in the code snippet; the code snippet is implemented using a ternary conditional operator; The C compiler compiles the C language code containing the code snippet into a corresponding binary file and downloads it to the target controller, so that when the target controller is running, it checks whether the array subscript is out of bounds according to the conditional expression in the ternary conditional operator; In the conditional expression, a custom CheckInd function is used to determine whether each non-constant expression has a subscript out of bounds. The parameters of the CheckInd function include: the starting address ADDR of the array object, the dimension number i, and the non-constant subscript expression IND_EXPi of the i-th dimension; The non-constant subscript expression IND_EXPi of the i-th dimension contains array elements.

2. The configuration method for array subscript out-of-bounds checking according to claim 1, characterized in that: In the ternary conditional operator: The first expression embeds the C language code address expression of the array element; The second expression is a preset code block that is executed when the subscript is out of bounds.

3. The configuration method for array subscript out-of-bounds checking according to claim 2, characterized in that: The code block executed when the subscript is out of bounds will have a preset memory address as the execution result.

4. The configuration method for array subscript out-of-bounds checking according to claim 1, characterized in that: The code snippet also includes the data types of the array elements.

5. A dynamic detection method for array subscript out-of-bounds in a control program, characterized in that: The method includes: The controller receives a control program sent by an engineering station, wherein the control program is obtained by the configuration method for array subscript out-of-bounds checking according to any one of claims 1 to 4; When the controller is running, the ternary conditional operation in the control program is executed to check whether the array index is out of bounds.

6. A distributed control system, characterized in that: It includes an engineer station and a controller. The engineer station uses the configuration method for array subscript out-of-bounds checking described in any one of claims 1 to 4 to configure the distributed control system. The control program uses the steps of the dynamic detection method for array subscript out-of-bounds in the control program described in claim 5 to dynamically check for array subscript out-of-bounds.

7. A controller, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for dynamically detecting array subscript out-of-bounds in a control program as described in claim 5 above.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the steps of the method for dynamically detecting array subscript out-of-bounds in the control program as described in claim 5 above are implemented.

Citation Information

Patent Citations

  • Automatic detection and correction method for array out-of-bound errors

    CN103778061A

  • Memory overflow processing method, device and equipment, and readable storage medium

    CN110472411A