CN114048465A - Stack state detection method, device, equipment and storage medium - Google Patents

Stack state detection method, device, equipment and storage medium Download PDF

Info

Publication number
CN114048465A
CN114048465A CN202210039845.6A CN202210039845A CN114048465A CN 114048465 A CN114048465 A CN 114048465A CN 202210039845 A CN202210039845 A CN 202210039845A CN 114048465 A CN114048465 A CN 114048465A
Authority
CN
China
Prior art keywords
value
read
stack
preset value
initial preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210039845.6A
Other languages
Chinese (zh)
Other versions
CN114048465B (en
Inventor
费卫宏
李瑞东
钟戟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202210039845.6A priority Critical patent/CN114048465B/en
Publication of CN114048465A publication Critical patent/CN114048465A/en
Application granted granted Critical
Publication of CN114048465B publication Critical patent/CN114048465B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/52Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems during program execution, e.g. stack integrity ; Preventing unwanted data erasure; Buffer overflow

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application discloses a stack state detection method, a device, equipment and a storage medium, comprising the following steps: determining a storage position of a target stack, and distributing a memory space with a preset size at a preset position of the target stack; writing the initial preset value into a memory space, and directly reading the initial preset value in the memory space to obtain a corresponding first read-back value; judging whether the first read-back value is consistent with the initial preset value or not, and if so, reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value; and judging whether the second read-back value is consistent with the initial preset value, if not, judging that the stack state is in an abnormal state and executing program assertion operation. According to the method and the device, the initial preset value stored in the preset position of the stack is read twice, the read-back value and the initial preset value are judged, and the state of the target stack is determined based on the second judgment result, so that low consumption is realized, the stack state is detected efficiently, and the stable operation of a bare engine system is ensured.

Description

Stack state detection method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for detecting a stack state.
Background
Currently, most SSD (Solid State Disk) products are developed by using a bare computer instead of using an existing OS (operating system) platform in order to pursue extreme product performance, so as to apply the maximum capability of a CPU (central processing unit) to the SSD service. SSD products still present some serious problems in practical use if developed using OS platforms. For example, because the consumption of the CPU is large, excessive CPU performance is consumed in the operation and maintenance of the OS, the SSD product is irrevocable, stack overflow occurs, and when the data or program runs abnormally, the problem is generally difficult to be solved, the labor is consumed, and the problem is easily left in the product, which affects the quality of the SSD product.
However, most of current SSD products are developed using a bare metal system, and because there is no OS platform support, a mature stack state monitoring mechanism provided when the OS platform is used for development cannot be implemented, so that the safety of the bare metal in the operation process cannot be guaranteed, and a developer needs to ensure the basic operation safety of the bare metal by himself.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, an apparatus, a device and a storage medium for detecting a stack state, which can improve the operation security of a bare metal system and thus ensure stable operation of the bare metal system. The specific scheme is as follows:
in a first aspect, the present application discloses a stack state detection method applied to a bare metal system, including:
determining a storage position of the target stack, and allocating a memory space with a preset size at a preset position of the target stack;
writing an initial preset value into the memory space, and directly reading the initial preset value in the memory space to obtain a corresponding first read-back value;
judging whether the first read-back value is consistent with the initial preset value or not, and if so, reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value;
and judging whether the second read-back value is consistent with the initial preset value, if so, judging that the target stack state is in a non-abnormal state and executing interface exit operation, and if not, judging that the target stack state is in an abnormal state and executing program assertion operation.
Optionally, the allocating a memory space with a preset size at a preset position of the target stack includes:
respectively configuring memory spaces with preset sizes at the stack bottom and the stack top of the target stack to obtain a first memory space corresponding to the stack bottom and a second memory space corresponding to the stack top;
correspondingly, the writing the initial preset value into the memory space includes:
and respectively writing a first initial preset value and a second initial preset value into the first memory space corresponding to the stack bottom and the second memory space corresponding to the stack top.
Optionally, the directly reading the initial preset value in the memory space to obtain a corresponding first read-back value includes:
directly reading the first initial preset value in the first memory space to obtain a first memory read-back value;
directly reading the second initial preset value in the second memory space to obtain a second memory read-back value;
correspondingly, the determining whether the first read-back value is consistent with the initial preset value includes:
and judging whether the first memory read-back value and the second memory read-back value are consistent with the first initial preset value and the second initial preset value.
Optionally, the reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value includes:
reading back the second initial preset value in the second memory space through a preset detection interface to obtain a second target read-back value corresponding to the stack top;
correspondingly, the determining whether the second readback value is consistent with the initial preset value includes:
and judging whether the second target readback value is consistent with the second initial preset value or not.
Optionally, after determining whether the first read-back value is consistent with the initial preset value, the method further includes:
and if the first read-back value is inconsistent with the initial preset value, writing the initial preset value into the memory space again.
Optionally, before the reading back the initial preset value through the preset detection interface to obtain the corresponding second read-back value, the method further includes:
and creating an entry function corresponding to the target stack state detection, and adding the entry function into a main cycle of a main function to obtain a preset detection interface corresponding to the entry function.
Optionally, after determining that the target stack state is in an abnormal state and executing a program assertion operation if the second read-back value is inconsistent with the initial preset value, the method further includes:
and printing the second read-back value and the current stack information corresponding to the target stack to obtain corresponding printing information, and properly adjusting the target stack based on the printing information.
In a second aspect, the present application discloses a stack state detection apparatus, applied to a bare metal system, including:
the storage position determining module is used for determining the storage position of the target stack;
the memory space allocation module is used for allocating memory space with a preset size at a preset position of the target stack;
a numerical value writing module for writing an initial preset value into the memory space;
the first reading module is used for directly reading the initial preset value in the memory space to obtain a corresponding first read-back value;
the first judging module is used for judging whether the first read-back value is consistent with the initial preset value or not;
the second reading module is used for reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value when the first read-back value is consistent with the initial preset value;
the second judging module is used for judging whether the second read-back value is consistent with the initial preset value or not;
the first state judgment module is used for judging that the target stack state is in a non-abnormal state and executing interface exit operation when the second read-back value is consistent with the initial preset value;
and the second state judgment module is used for judging that the target stack state is in an abnormal state and executing program assertion operation when the second read-back value is inconsistent with the initial preset value.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the stack state detection method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program realizes the steps of the stack state detection method disclosed in the foregoing when being executed by a processor.
Therefore, the application provides a stack state detection method, which is applied to a bare metal system and comprises the following steps: determining a storage position of the target stack, and allocating a memory space with a preset size at a preset position of the target stack; writing an initial preset value into the memory space, and directly reading the initial preset value in the memory space to obtain a corresponding first read-back value; judging whether the first read-back value is consistent with the initial preset value or not, and if so, reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value; and judging whether the second read-back value is consistent with the initial preset value, if so, judging that the target stack state is in a non-abnormal state and executing interface exit operation, and if not, judging that the target stack state is in an abnormal state and executing program assertion operation. Therefore, the initial preset value in the memory space with the preset size distributed on the preset position of the first read-write stack is judged, whether the first read-back value is consistent with the initial preset value is judged, the problem of a found program can be exposed in advance, correct writing of the initial preset value is ensured, when the first read-back value is consistent with the initial preset value, the initial preset value is read for the second time in the preset detection interface, whether the second read-back value is consistent with the initial preset value is judged, and the state of the target stack is determined based on the judgment result.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart of a stack state detection method disclosed in the present application;
FIG. 2 is a flow chart of a specific stack state detection method disclosed herein;
fig. 3 is a schematic structural diagram of a stack state detection apparatus disclosed in the present application;
fig. 4 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Currently, because some serious problems may exist when an operating system platform is used for developing a solid state disk, in order to pursue extreme product performance, most solid state disk products are developed by using a bare computer instead of an existing operating system platform, so that the maximum capability of a central processing unit is applied to an SSD service, but the solid state disk developed by using the bare computer platform does not have a stack state monitoring mechanism on the operating system platform. Therefore, the stack state detection method can improve the operation safety of the bare metal system, so that the stable operation of the bare metal system is ensured, and meanwhile, the problem of finding a program can be exposed in advance.
The embodiment of the invention discloses a stack state detection method, which is shown in figure 1 and comprises the following steps:
step S11: and determining the storage position of the target stack, and allocating a memory space with a preset size at a preset position of the target stack.
In this embodiment, when a storage location of the target stack is specified in satrt.s (boot file) of a bare metal program, a memory space with a preset size is allocated at a preset location of the target stack. It is to be understood that the preset position may be a stack top on the target stack, or a stack top and a stack bottom on the target stack, that is, a memory space with a preset size is configured at the stack top of the target stack, or memory spaces with preset sizes are configured at the target stack and the stack bottom, respectively. It should be noted that after the memory space of the preset position of the stack is configured, it is to be avoided that other memory spaces coincide with the memory space of the preset position.
Step S12: writing an initial preset value into the memory space, and directly reading the initial preset value in the memory space to obtain a corresponding first read-back value.
In this embodiment, after the allocation of the memory space at the preset position of the stack is completed, an initial preset value is written into the memory space, and then the memory space is accessed to read the initial preset value, and the read value is determined as a first read-back value corresponding to the memory space.
Step S13: and judging whether the first read-back value is consistent with the initial preset value, and if so, reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value.
In this embodiment, it is determined whether the first read-back value is consistent with the initial preset value to ensure that the written initial preset value is correct during system initialization, and if the first read-back value is not consistent with the initial preset value, the initial preset value is written into the memory space again. And if the first readback value is consistent with the initial preset value, that is, after the initial preset value is correctly written into the memory space corresponding to the preset position, re-reading the initial preset value through a preset detection interface to obtain a corresponding second readback value. It is understood that the addresses of the top and bottom of the stack are detected by the detection interface, and then the data outside the top and bottom of the stack is read out. Wherein the creation process of the preset detection interface comprises: and creating an entry function corresponding to the target stack state detection, and adding the entry function into a main cycle of a main function to obtain a preset detection interface corresponding to the entry function. That is, the stack state detection entry function is added to the main loop of the main function, that is, a preset detection interface is added to the main loop of the main function, and then the initial preset value stored in the memory space corresponding to the preset position during system initialization is read back in the entry function, so that the read value is determined as a second read-back value.
Step S14: and judging whether the second read-back value is consistent with the initial preset value, if so, judging that the target stack state is in a non-abnormal state and executing interface exit operation, and if not, judging that the target stack state is in an abnormal state and executing program assertion operation.
In this embodiment, it is determined whether the second readback value is consistent with the initial preset value, and if so, it is determined that the target stack state is in a non-abnormal state and interface exit operation is performed, and if not, it is determined that the target stack state is in an abnormal state and program assertion operation is performed. It will be appreciated that the value read back the second time is compared with the value written at initialization, and if consistent, the exit is straight, indicating that the current stack is all normal. If the value read back for the second time is not consistent with the value written in the initialization, the overflow of the current stack is indicated.
In this implementation, after determining that the target stack state is in an abnormal state and performing a program assertion operation, the method further includes: and printing the second read-back value and the current stack information corresponding to the target stack to obtain corresponding printing information, and properly adjusting the target stack based on the printing information. It is understood that the above-mentioned print information may include, but is not limited to, lr register information, SP register information, pc pointer register information. Therefore, according to the printing information, the condition of stack overflow can be reflected, and the pc pointer is compared with the disassembled file, so that the function of stack overflow can be determined.
It can be seen that, in the embodiment of the present application, an initial preset value in a memory space of a preset size allocated at a preset position where a write-in stack is read for the first time is determined, and whether a first read-back value is consistent with the initial preset value is determined, so that a problem of finding a program can be exposed in advance, and correct writing of the initial preset value is ensured.
Referring to fig. 2, the embodiment of the present invention discloses a specific stack state detection method, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution.
Step S21: determining a storage position of the target stack, and respectively configuring memory spaces with preset sizes at the stack bottom and the stack top of the target stack to obtain a first memory space corresponding to the stack bottom and a second memory space corresponding to the stack top.
In this embodiment, a storage location of the target stack is determined, that is, memory addresses of a stack bottom and a stack top of the target stack are specified, so as to determine a stack space of the target stack, and then memory spaces with preset sizes are respectively configured at the stack bottom and the stack top of the target stack, so as to obtain a first memory space corresponding to the stack bottom and a second memory space corresponding to the stack top. It can be understood that configuring a preset size of memory space at the stack bottom and the stack top of the target stack does not occupy the stack space corresponding to the stack, and the preset size may be set to 4 bytes.
Step S22: and respectively writing a first initial preset value and a second initial preset value into the first memory space corresponding to the stack bottom and the second memory space corresponding to the stack top.
In this embodiment, after determining the memory spaces corresponding to the stack bottom and the stack top, a first initial preset value and a second initial preset value are written into the first memory space corresponding to the stack bottom and the second memory space corresponding to the stack top, respectively. For example, 0x5a5a5a5a is set to the first initial preset value and 0xa5a5a5 is set to the second initial preset value, that is, 0x5a5a5a is written into the first memory space corresponding to the bottom of the stack and 0xa5a5a5 is written into the second memory space corresponding to the top of the stack, or 0xa5a5a5a5 is written into the first memory space corresponding to the bottom of the stack and 0x5a5a5a5a is written into the second memory space corresponding to the top of the stack.
Step S23: and directly reading the first initial preset value in the first memory space to obtain a first memory read-back value, and directly reading the second initial preset value in the second memory space to obtain a second memory read-back value.
In this embodiment, after the first initial preset value and the initial preset value are written into the first memory space and the second memory space, the first memory space and the second memory space are accessed to read the first initial preset value and the second initial preset value, a value read from the first memory space is determined as a first memory read-back value, and a value read from the second memory space is determined as a second memory read-back value.
Step S24: and judging whether the first memory read-back value and the second memory read-back value are consistent with the first initial preset value and the second initial preset value.
In this embodiment, it is determined whether the first memory read-back value and the second memory read-back value are consistent with the first initial preset value and the second initial preset value, so as to determine whether the written initial preset value is correct during system initialization. And if the first memory read-back value is inconsistent with the first initial preset value or the second memory read-back value is inconsistent with the second initial preset value, writing the first initial preset value or the second initial preset value into the first memory space or the second memory space again.
Step S25: and if so, reading back the second initial preset value in the second memory space through a preset detection interface to obtain a second target read-back value corresponding to the stack top.
In this embodiment, only if the first memory read-back value and the first initial preset value and the second memory read-back value and the second initial preset value are consistent, the second initial preset value in the second memory space is read back through a preset detection interface, so as to obtain a second target read-back value corresponding to the stack top.
Step S26: and judging whether the second target readback value is consistent with the second initial preset value or not.
Step S27: if the target stack state is consistent with the abnormal state, judging that the target stack state is in the abnormal state and executing interface exit operation, and if the target stack state is not consistent with the abnormal state, judging that the target stack state is in the abnormal state and executing program assertion operation.
For the specific contents of the step S26 and the step S27, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and details are not repeated here.
It can be seen that, in the embodiment of the present application, a first initial preset value in a first memory space corresponding to the bottom of a stack and a second initial preset value in a second memory space corresponding to the top of the stack are respectively read for the first time, and judging whether the read first memory read-back value and the second memory read-back value are consistent with the first initial preset value and the second initial value, thereby ensuring the correct writing of the first default preset value and the second default preset value, if the first default preset value and the second default preset value are consistent, reading the second default preset value in the default detection interface, then judging whether the read second target read-back value is consistent with a second initial preset value or not, determining the state of the target stack based on the judgment result, therefore, the stack state can be efficiently detected under the condition of extremely low expenditure of the CPU, the operation safety of the bare metal system is improved, and the stable operation of the bare metal system is further ensured.
Correspondingly, an embodiment of the present application further discloses a stack state detection apparatus, which is applied to a bare metal system, and as shown in fig. 3, the apparatus includes:
a storage location determining module 11, configured to determine a storage location of the target stack;
a memory space allocation module 12, configured to allocate a memory space of a preset size at a preset position of the target stack;
a numerical value writing module 13, configured to write an initial preset value into the memory space;
a first reading module 14, configured to directly read the initial preset value in the memory space to obtain a corresponding first read-back value;
the first judging module 15 is configured to judge whether the first read-back value is consistent with the initial preset value;
a second reading module 16, configured to, when the first read-back value is consistent with the initial preset value, read back the initial preset value through a preset detection interface to obtain a corresponding second read-back value;
a second judging module 17, configured to judge whether the second readback value is consistent with the initial preset value;
a first state determining module 18, configured to determine that the target stack state is in a non-abnormal state and execute an interface exit operation when the second readback value is consistent with the initial preset value;
and a second state determining module 19, configured to determine that the target stack state is in an abnormal state and execute a program assertion operation when the second read-back value is inconsistent with the initial preset value.
As can be seen from the above, in the embodiment of the present application, the initial preset value in the memory space of the preset size allocated at the preset position of the write-in stack is read for the first time, and it is determined whether the first read-back value is consistent with the initial preset value, so that the problem of the program can be exposed in advance, and the correct write-in of the initial preset value is ensured.
In some specific embodiments, the memory space allocation module 12 specifically includes:
and the memory space distribution unit is used for respectively configuring memory spaces with preset sizes at the stack bottom and the stack top of the target stack so as to obtain a first memory space corresponding to the stack bottom and a second memory space corresponding to the stack top.
In some specific embodiments, the numerical value writing module 13 specifically includes:
and the first numerical value writing unit is used for writing a first initial preset value and a second initial preset value into the first memory space corresponding to the stack bottom and the second memory space corresponding to the stack top respectively.
In some specific embodiments, the first reading module 14 specifically includes:
a first value reading unit, configured to directly read the first initial preset value in the first memory space to obtain a first memory read-back value;
and the second numerical value reading unit is used for directly reading the second initial preset value in the second memory space to obtain a second memory read-back value.
In some specific embodiments, the first determining module 15 specifically includes:
and the first judging unit is used for judging whether the first memory read-back value and the second memory read-back value are consistent with the first initial preset value and the second initial preset value.
In some specific embodiments, the second reading module 16 specifically includes:
and the third numerical value reading unit is used for reading back the second initial preset value in the second memory space through a preset detection interface so as to obtain a second target read-back value corresponding to the stack top.
In some specific embodiments, the second determining module 17 specifically includes:
and the second judging unit is used for judging whether the second target readback value is consistent with the second initial preset value or not.
In some specific embodiments, the determining whether the first read-back value is consistent with the initial preset value specifically includes:
and a second value writing unit, configured to write the initial preset value into the memory space again when the first read-back value is inconsistent with the initial preset value.
In some specific embodiments, the stack state detection apparatus further includes:
and the interface creating module is used for creating an entry function corresponding to the target stack state detection and adding the entry function into the main cycle of the main function so as to obtain a preset detection interface corresponding to the entry function.
And the stack adjusting module is used for printing the second read-back value and the stack information corresponding to the current target stack to obtain corresponding printing information, and appropriately adjusting the target stack based on the printing information.
Further, the embodiment of the application also provides electronic equipment. FIG. 4 is a block diagram illustrating an electronic device 20 according to an exemplary embodiment, and the contents of the diagram should not be construed as limiting the scope of use of the present application in any way.
Fig. 4 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present disclosure. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the stack state detection method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
In addition, the storage 22 is used as a carrier for resource storage, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage manner may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device on the electronic device 20 and the computer program 222, and may be Windows Server, Netware, Unix, Linux, or the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the stack state detection method performed by the electronic device 20 disclosed in any of the foregoing embodiments.
Further, an embodiment of the present application further discloses a storage medium, where a computer program is stored, and when the computer program is loaded and executed by a processor, the steps of the stack state detection method disclosed in any of the foregoing embodiments are implemented.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above detailed description is provided for a stack state detection method, apparatus, device and storage medium, and the specific examples are applied herein to explain the principles and embodiments of the present invention, and the descriptions of the above embodiments are only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A stack state detection method is applied to a bare metal system and comprises the following steps:
determining a storage position of a target stack, and allocating a memory space with a preset size at a preset position of the target stack;
writing an initial preset value into the memory space, and directly reading the initial preset value in the memory space to obtain a corresponding first read-back value;
judging whether the first read-back value is consistent with the initial preset value or not, and if so, reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value;
and judging whether the second read-back value is consistent with the initial preset value, if so, judging that the target stack state is in a non-abnormal state and executing interface exit operation, and if not, judging that the target stack state is in an abnormal state and executing program assertion operation.
2. The method of claim 1, wherein allocating a memory space of a predetermined size at a predetermined location on the target stack comprises:
respectively configuring memory spaces with preset sizes at the stack bottom and the stack top of the target stack to obtain a first memory space corresponding to the stack bottom and a second memory space corresponding to the stack top;
correspondingly, the writing the initial preset value into the memory space includes:
and respectively writing a first initial preset value and a second initial preset value into the first memory space corresponding to the stack bottom and the second memory space corresponding to the stack top.
3. The method of claim 2, wherein the directly reading the initial default value in the memory space to obtain the corresponding first read-back value comprises:
directly reading the first initial preset value in the first memory space to obtain a first memory read-back value;
directly reading the second initial preset value in the second memory space to obtain a second memory read-back value;
correspondingly, the determining whether the first read-back value is consistent with the initial preset value includes:
and judging whether the first memory read-back value and the second memory read-back value are consistent with the first initial preset value and the second initial preset value.
4. The method for detecting the stack state according to claim 2, wherein the reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value comprises:
reading back the second initial preset value in the second memory space through a preset detection interface to obtain a second target read-back value corresponding to the stack top;
correspondingly, the determining whether the second readback value is consistent with the initial preset value includes:
and judging whether the second target readback value is consistent with the second initial preset value or not.
5. The method of claim 1, wherein after determining whether the first read-back value is consistent with the initial default value, the method further comprises:
and if the first read-back value is inconsistent with the initial preset value, writing the initial preset value into the memory space again.
6. The method of claim 1, wherein before the reading back the initial default value through the default detection interface to obtain the corresponding second read-back value, the method further comprises:
and creating an entry function corresponding to the target stack state detection, and adding the entry function into a main cycle of a main function to obtain a preset detection interface corresponding to the entry function.
7. The stack state detection method according to any one of claims 1 to 6, wherein after determining that the target stack state is in an abnormal state and performing a program assertion operation if the second read-back value does not coincide with the initial preset value, further comprising:
and printing the second read-back value and the current stack information corresponding to the target stack to obtain corresponding printing information, and properly adjusting the target stack based on the printing information.
8. A stack state detection device applied to a bare metal system comprises:
the storage position determining module is used for determining the storage position of the target stack;
the memory space allocation module is used for allocating memory space with a preset size at a preset position of the target stack;
a numerical value writing module for writing an initial preset value into the memory space;
the first reading module is used for directly reading the initial preset value in the memory space to obtain a corresponding first read-back value;
the first judging module is used for judging whether the first read-back value is consistent with the initial preset value or not;
the second reading module is used for reading back the initial preset value through a preset detection interface to obtain a corresponding second read-back value when the first read-back value is consistent with the initial preset value;
the second judging module is used for judging whether the second read-back value is consistent with the initial preset value or not;
the first state judgment module is used for judging that the target stack state is in a non-abnormal state and executing interface exit operation when the second read-back value is consistent with the initial preset value;
and the second state judgment module is used for judging that the target stack state is in an abnormal state and executing program assertion operation when the second read-back value is inconsistent with the initial preset value.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to carry out the steps of the stack state detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program realizes the steps of the stack state detection method according to any one of claims 1 to 7 when executed by a processor.
CN202210039845.6A 2022-01-14 2022-01-14 Stack state detection method, device, equipment and storage medium Active CN114048465B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210039845.6A CN114048465B (en) 2022-01-14 2022-01-14 Stack state detection method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210039845.6A CN114048465B (en) 2022-01-14 2022-01-14 Stack state detection method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114048465A true CN114048465A (en) 2022-02-15
CN114048465B CN114048465B (en) 2022-05-06

Family

ID=80196591

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210039845.6A Active CN114048465B (en) 2022-01-14 2022-01-14 Stack state detection method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114048465B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627852A (en) * 2023-07-24 2023-08-22 苏州萨沙迈半导体有限公司 Method and device for detecting stack overflow and computing equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102629231A (en) * 2012-04-24 2012-08-08 迈普通信技术股份有限公司 Method for detecting task stack
CN109214169A (en) * 2017-06-30 2019-01-15 芜湖美的厨卫电器制造有限公司 Stack overflow detection method, device and household electrical appliance
CN109426501A (en) * 2017-06-27 2019-03-05 比亚迪股份有限公司 Storehouse self checking method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102629231A (en) * 2012-04-24 2012-08-08 迈普通信技术股份有限公司 Method for detecting task stack
CN109426501A (en) * 2017-06-27 2019-03-05 比亚迪股份有限公司 Storehouse self checking method and device
CN109214169A (en) * 2017-06-30 2019-01-15 芜湖美的厨卫电器制造有限公司 Stack overflow detection method, device and household electrical appliance

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116627852A (en) * 2023-07-24 2023-08-22 苏州萨沙迈半导体有限公司 Method and device for detecting stack overflow and computing equipment
CN116627852B (en) * 2023-07-24 2023-10-03 苏州萨沙迈半导体有限公司 Method and device for detecting stack overflow and computing equipment

Also Published As

Publication number Publication date
CN114048465B (en) 2022-05-06

Similar Documents

Publication Publication Date Title
US8930953B2 (en) Dynamic checking of hardware resources for virtual environments
CN101218557A (en) Systems and methods for memory migration
CN110399217B (en) Memory resource allocation method, device and equipment
CN110750336B (en) OpenStack virtual machine memory hot-expanding method
CN109683970A (en) A kind of amending method of server FRU information, modification system and relevant apparatus
CN114048465B (en) Stack state detection method, device, equipment and storage medium
CN110930291A (en) GPU video memory management control method and related device
CN118426689A (en) Data processing method, system and equipment for solid state disk
US20240248633A1 (en) Apparatuses, Devices, Methods and Computer Programs for Providing and Processing Information Characterizing a Non-Uniform Memory Architecture
CN113536320A (en) Error information processing method, device and storage medium
EP4006725A1 (en) Virtual machine migration processing and strategy generation method, apparatus and device, and storage medium
US20040243731A1 (en) Upgrading a memory subsystem
CN115878327A (en) Bus reservation method, device, server, electronic equipment and storage medium
CN114780166A (en) Pin configuration method, related device, equipment and readable storage medium
CN115794232A (en) VPD (virtual private display) acquisition method, device, equipment and computer-readable storage medium
CN114995762A (en) Thick backup roll capacity expansion method, device, equipment and storage medium
CN115145595A (en) Dependency library installation method and device, server, electronic equipment and storage medium
CN114885032A (en) Equipment information generating and displaying method, device, equipment and medium
CN118409940B (en) Handle alarm method, device, electronic equipment, storage medium and program product
CN116991542B (en) Virtual machine snapshot method, system, electronic equipment and computer storage medium
CN109522122B (en) Memory management method, system, device and computer readable storage medium
CN115113817B (en) Storage optimization method and system based on network card, electronic equipment and storage medium
CN113312095B (en) Method, device, terminal and storage medium for managing plug event of display equipment
CN111475344B (en) Program resetting system, method and device and computer readable storage medium
CN111124882B (en) Method and device for realizing application test, computer storage medium and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220819

Address after: Room 401, 4th Floor, Gangsheng Building, No. 2177 Gangxi Road, High-tech Zone, Jinan City, Shandong Province, 250000

Patentee after: Shandong Yunhai guochuang cloud computing equipment industry innovation center Co.,Ltd.

Address before: Building 9, No.1, guanpu Road, Guoxiang street, Wuzhong Economic Development Zone, Wuzhong District, Suzhou City, Jiangsu Province

Patentee before: SUZHOU LANGCHAO INTELLIGENT TECHNOLOGY Co.,Ltd.

TR01 Transfer of patent right