CN117149644A - Memory overflow detection method, device, operating system, equipment and storage medium - Google Patents

Memory overflow detection method, device, operating system, equipment and storage medium Download PDF

Info

Publication number
CN117149644A
CN117149644A CN202311142533.9A CN202311142533A CN117149644A CN 117149644 A CN117149644 A CN 117149644A CN 202311142533 A CN202311142533 A CN 202311142533A CN 117149644 A CN117149644 A CN 117149644A
Authority
CN
China
Prior art keywords
memory
page
data
pages
allocated
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311142533.9A
Other languages
Chinese (zh)
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.)
Kedong Guangzhou Software Technology Co Ltd
Original Assignee
Kedong Guangzhou Software 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 Kedong Guangzhou Software Technology Co Ltd filed Critical Kedong Guangzhou Software Technology Co Ltd
Priority to CN202311142533.9A priority Critical patent/CN117149644A/en
Publication of CN117149644A publication Critical patent/CN117149644A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Storage Device Security (AREA)

Abstract

The embodiment of the invention provides a memory overflow detection method, a device, an operating system, equipment and a storage medium, wherein the method comprises the following steps: dividing protection pages and data pages with address interval distribution from a memory pool; allocating an idle data page when memory allocation is performed each time, and setting adjacent protection pages of the allocated data pages as invalid; when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered. According to the technical scheme provided by the embodiment of the invention, the timeliness of memory overflow detection can be effectively improved through the protection page, the memory overflow problem checking time is shortened, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in running are overcome, and the stability and the reliability of a program are improved.

Description

Memory overflow detection method, device, operating system, equipment and storage medium
Technical Field
The present invention relates to the field of operating systems, and in particular, to a method and apparatus for detecting memory overflow, an operating system, a device, and a storage medium.
Background
In the field of kernel memory debugging, two major problems, namely 'memory is changed' and 'memory leaks', continue to exist. The consequences of memory problems are very serious, which can lead to program crashes, data loss or utilization by malicious attackers, memory problems are tricky, the site when the faults occur can be not the first site, and the problems are difficult to check, time-consuming and labor-consuming. Therefore, it is important to find and solve the memory overflow problem in time.
Memory detection mechanisms are important mechanisms for detecting memory leaks and errors. Memory leaks and errors are typically detected by tracking and using memory allocation and release during memory usage. Memory detection mechanisms can be divided into two types: static and dynamic.
The static memory detection mechanism is a mechanism that detects memory leaks and errors at compile time. This mechanism uses a memory analysis tool to check the compiler's code and detect any memory leaks or errors. Static memory detection mechanisms can generally improve the quality and reliability of programs because they discover memory leaks and errors at runtime.
Dynamic memory detection mechanisms are mechanisms that detect memory leaks and errors while the program is running. This mechanism uses a memory allocation and release tracking procedure to detect memory leaks and errors. Dynamic memory detection mechanisms are generally more flexible than static memory detection mechanisms because it can detect memory leaks and errors at runtime and take timely action to solve the problem.
Existing memory detection mechanisms suffer from a number of drawbacks, including:
missing/false detection: missed detection refers to the fact that the detected memory leak problem is not all true memory leak problems. Some memory leaks may be caused by other problems with the program or because the memory leak problem is complex and cannot be detected completely by the detection tool.
The efficiency is low: memory leak detection and garbage collection detection need to be performed while the program is running, and thus may affect the performance and efficiency of the program. Particularly in large programs and concurrent environments, the detection process may have a serious impact on the performance of the program.
Aging is poor: the existing memory detection mechanism cannot accurately capture the first site where the problem occurs.
Disclosure of Invention
In view of this, an embodiment of the present invention provides a method, an apparatus, an operating system, a device, and a storage medium for detecting memory overflow, where the method includes: dividing protection pages and data pages with address interval distribution from a memory pool; allocating an idle data page when memory allocation is performed each time, and setting adjacent protection pages of the allocated data pages as invalid; when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered. According to the technical scheme provided by the embodiment of the invention, the timeliness of memory overflow detection can be effectively improved through the protection page, the memory overflow problem checking time is shortened, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in running are overcome, and the stability and the reliability of a program are improved.
In a first aspect, an embodiment of the present invention provides a method for detecting memory overflow, including: dividing protection pages and data pages with address interval distribution from a memory pool; allocating an idle data page when memory allocation is performed each time, and setting adjacent protection pages of the allocated data pages as invalid; when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered.
By the method, timeliness of memory overflow detection can be effectively improved through the protection page, memory overflow problem checking time is shortened, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in operation are overcome, and stability and reliability of a program are improved.
In a possible implementation manner of the first aspect, the method further includes: when the page out-of-range access exception is triggered, the instruction position of the exception access protection page is located through stack backtracking.
By the method, the instruction position of the abnormal access protection page is located through stack backtracking, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in running are overcome, and the stability and the reliability of a program are improved.
In a possible implementation manner of the first aspect, the method further includes: when one of the released data pages is an empty data page, an abnormal release error is reported.
By judging abnormal release on the release data page, the detection of invalid release of the memory and the like is realized, a large amount of CPU time is not required, and the stability and the reliability of the program are improved
In a possible implementation manner of the first aspect, the method further includes: when the allocated data page is larger than the memory required by the allocation, filling magic data in the rest positions of the allocated data page; when the actual data of the rest position of one released data page is different from the magic data, reporting an out-of-range access error in the page.
By judging the page boundary crossing access error in the release data page, the detection of the page boundary crossing access error in the memory page is realized, a large amount of CPU time is not required, and the stability and the reliability of the program are improved.
In a possible implementation manner of the first aspect, when the allocated data page is larger than the memory required for the allocation, the allocated memory is located in the middle of the allocated data page.
By the above, the memory allocated is located in the middle of the allocated data page, so as to detect out-of-range access errors in pages at two sides.
In a possible implementation manner of the first aspect, the method further includes: the free data pages are managed by the free memory linked list.
By the above, the idle data pages are managed through the idle memory linked list, so that the state of the idle data pages can be tracked conveniently.
In a second aspect, an embodiment of the present invention provides a memory overflow detection apparatus, including: the memory initialization module is used for dividing the memory pool into protection pages and data pages with address interval distribution; the memory allocation module is used for allocating an idle data page and an adjacent idle protection page thereof when the memory is allocated each time and setting the adjacent protection pages of the allocated data page as invalid; and the page out-of-range detection module is used for triggering page out-of-range access exception when the adjacent protection page of the allocated data page is accessed.
By the method, timeliness of memory overflow detection can be effectively improved through the protection page, memory overflow problem checking time is shortened, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in operation are overcome, and stability and reliability of a program are improved.
In a possible implementation manner of the second aspect, the method further includes: and the page boundary crossing positioning module is used for positioning the instruction position of the abnormal access protection page through stack backtracking when triggering the page boundary crossing access abnormality.
By the method, the instruction position of the abnormal access protection page is located through stack backtracking, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in running are overcome, and the stability and the reliability of a program are improved.
In a possible implementation manner of the second aspect, the method further includes: and the abnormal release report module is used for reporting abnormal release errors when one released data page is an idle data page.
By judging abnormal release on the release data page, the detection of invalid release of the memory and the like is realized, a large amount of CPU time is not required, and the stability and the reliability of the program are improved
In one possible implementation manner of the second aspect, the memory allocation module is further configured to fill magic data in a remaining position of the allocated data page when the allocated data page is greater than the memory required for the allocation; the apparatus further comprises: and the page boundary crossing reporting module is used for reporting page boundary crossing access errors when the actual data of the residual position of one released data page is different from the magic number data.
By judging the page boundary crossing access error in the release data page, the detection of the page boundary crossing access error in the memory page is realized, a large amount of CPU time is not required, and the stability and the reliability of the program are improved.
In one possible implementation manner of the second aspect, when the allocated data page is larger than the memory required for the allocation, the allocated memory is located in the middle of the allocated data page.
By the above, the memory allocated is located in the middle of the allocated data page, so as to detect out-of-range access errors in pages at two sides.
In a possible implementation manner of the second aspect, the free data pages are managed by a free memory linked list.
By the above, the idle data pages are managed through the idle memory linked list, so that the state of the idle data pages can be tracked conveniently.
In a third aspect, embodiments of the present invention provide an operating system, which when executed by a computer, causes the computer to perform any of the methods of the first aspect.
In a fourth aspect, embodiments of the present invention provide a computing device comprising: a bus; a communication interface connected to the bus; at least one processor coupled to the bus; and at least one memory coupled to the bus and storing program instructions that, when executed by the at least one processor, cause the at least one processor to perform any of the embodiments of the first aspect of the invention.
In a fifth aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon program instructions which when executed by a computer cause the computer to perform any of the embodiments of the first aspect of the present invention.
Drawings
FIG. 1 is a flowchart of a memory overflow detection method according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating memory pool partitioning and idle memory linked list management according to a first embodiment of a memory overflow detection method of the present invention;
FIG. 3 is a diagram illustrating a page crossing access according to a first embodiment of a memory overflow detection method of the present invention;
FIG. 4 is a flowchart illustrating a memory overflow detection method according to a second embodiment of the present invention;
FIG. 5 is a diagram illustrating filling magic data in the remaining positions of allocated data pages according to a second embodiment of a memory overflow detection method of the present invention;
FIG. 6 is a schematic diagram illustrating a memory overflow detecting device according to an embodiment of the present invention;
FIG. 7 is a schematic diagram illustrating a memory overflow detecting device according to a second embodiment of the present invention;
FIG. 8 is a schematic diagram of a computing device embodiment of the present invention.
Detailed Description
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
In the following description, references to the terms "first/second/third, etc." or module a, module B, module C, etc. are used merely to distinguish between similar objects or between different embodiments, and do not represent a particular ordering of the objects, it being understood that particular orders or precedence may be interchanged as permitted so that embodiments of the invention described herein can be implemented in an order other than that illustrated or described herein.
In the following description, reference numerals indicating steps such as S110, S120, … …, etc. do not necessarily indicate that the steps are performed in this order, and the order of the steps may be interchanged or performed simultaneously as allowed.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
The embodiment of the invention provides a memory overflow detection method, a device, an operating system, equipment and a storage medium, wherein the method comprises the following steps: dividing protection pages and data pages with address interval distribution from a memory pool; allocating an idle data page when memory allocation is performed each time, and setting adjacent protection pages of the allocated data pages as invalid; when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered.
The technical scheme of the embodiment of the invention is suitable for a method for distributing the memory through the malloc function, and the timeliness of memory overflow detection can be effectively improved by setting the protection page, so that the memory overflow problem checking time is shortened, the defects that other memory detection methods occupy a large amount of CPU time and influence the performance in operation are overcome, and the stability and the reliability of a program are improved.
An embodiment of a memory overflow detection method is described below with reference to fig. 1 to 5.
An embodiment of a memory overflow detection method firstly divides protection pages and data pages with address interval distribution from a memory pool; allocating an idle data page when memory allocation is performed each time, and setting adjacent protection pages of the allocated data pages as invalid; when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered.
Fig. 1 shows a flow of a first embodiment of a memory overflow detection method, including steps S110 to S140.
S110: and dividing the protection pages and the data pages with address interval distribution from the memory pool.
In some embodiments, each data page is equal in size to the guard page space, which is the space of one memory page managed by the MMU.
In some embodiments, each guard page space is equal in size, one memory page managed by the MMU, the data page space may be unequal in size, each data page space is an integer multiple of the memory page space managed by the MMU, and each data page of space size is a number.
In some embodiments, the free data pages are managed by free memory linked lists, and the free memory linked lists corresponding to each space-sized data page are different.
Fig. 2 is a schematic diagram of memory pool partitioning and free memory linked list management according to a first embodiment of a memory overflow detection method.
For ease of illustration, each page of the memory pool in the figure is an MMU managed memory page. The 0 th memory page is reserved because the left cannot be divided into the protection pages, the 1 st memory page is divided into the protection pages, the 2 nd memory page is divided into the data pages, and the later memory pages are divided into the protection pages and the memory pages in sequence. Because each data page is idle at the beginning, the first item of the idle memory linked list corresponds to data page 2, the second item corresponds to data page 4, and so on.
S120: and allocating an idle data page when the memory is allocated each time, and setting the adjacent protection pages of the allocated data pages as invalid.
The data page is allocated by a method of allocating memory through a dynamic memory allocation (memory allocation) malloc function, the data page can be allocated by dynamic memory of various objects, and adjacent protection pages of the allocated data page are set as invalid.
The adjacent protection pages on two sides of the allocated data page are all set to be invalid, so that when the adjacent protection pages are accessed, page out-of-range access abnormality is triggered, and the two-side page out-of-range access abnormality can be detected.
In some embodiments, each data page is a memory page managed by the MMU, and for memory requirements greater than one memory page managed by the MMU, the memory requirements are divided into several memory requirements for allocation.
In some embodiments, the data page space size is unequal, and then a data page matching the required memory size is allocated each time memory allocation occurs. The matching may be understood as the allocated data page being a free data page that is larger than the required memory and has minimal space.
In some embodiments, when free data pages are managed through a free memory linked list, the allocated data pages are deleted from the free memory linked list.
S130: when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered.
Wherein the adjacent protection page of the allocated data page is set as an invalid attribute, if read-write access to the adjacent protection page, the MMU may cause a page fault exception, which is defined in embodiments of the present invention as a page out-of-bound access exception.
Fig. 3 is a schematic diagram of a page crossing access according to a first embodiment of a memory overflow detection method. When any guard page adjacent to both sides of the allocated data page is accessed, the MMU automatically triggers a page out of range access exception.
The first site where the problem of accurate capturing occurs is found out in time through the protection page, and a large amount of CPU time is not required.
S140: when triggering page out-of-range access exception, locating the instruction position of the page out-of-range access exception through stack backtracking.
When the page crossing access abnormality is triggered, namely the page missing abnormality, the page missing abnormality processing function of the operating system analyzes and reports the generated errors, calls a stack backtracking function, prints a function call stack for generating abnormal points, and is convenient for accurately positioning the illegally accessed instruction position.
In summary, an embodiment of a memory overflow detection method can effectively improve timeliness of memory overflow detection through a protection page, shorten memory overflow problem investigation time, and combine stack backtracking to accurately locate an instruction position generating memory overflow, thereby overcoming defects that other memory detection methods need to occupy a large amount of CPU time and influence the performance in running, and improving stability and reliability of a program. The method of the embodiment can run microkernels or macrokernels of various operating systems, and is particularly suitable for microkernels based on real-time operating systems.
The second embodiment of the memory overflow detection method inherits all the methods of the first embodiment of the memory overflow detection method, has all the advantages of the first embodiment of the memory overflow detection method, further increases the detection of abnormal release and page-in-page out-of-range access errors on the data page released by the memory release free function, and further improves the stability and reliability of the program.
Fig. 4 shows a flow of a second embodiment of a memory overflow detection method, including steps S210 to S290.
S210: and initializing the memory, dividing a protection page and a data page with address interval distribution from a memory pool, and constructing an idle memory linked list to manage the idle data page.
In the specific method of this step, please refer to step S110 of the first embodiment of a memory overflow detecting method.
S220: memory is allocated, and each time memory allocation is performed, an idle data page is allocated and adjacent idle protection pages are set as invalid.
The specific method in this step is based on step S120 of the first embodiment of a memory overflow detection method, and further includes: and filling magic data in the rest positions of the allocated data pages when the allocated data pages are larger than the memory required by the allocation.
The magic data is known data and is used for checking whether an intra-page out-of-range access error occurs when the allocated data page is released.
In some embodiments, the allocated memory is located in the middle of the allocated data page, with the remaining locations within the allocated data page being on both sides of the allocated memory.
Fig. 5 shows a schematic diagram of the filling of magic data in the remaining positions of the allocated data pages. In the figure, the rest positions are positioned at two sides of the allocated memory, so that the out-of-range of the two sides can be conveniently detected.
S230: page out-of-range access exception, when an adjacent guard page of the allocated data page is accessed, the page out-of-range access exception is triggered.
In this embodiment, please refer to step S130 of the first embodiment of a memory overflow detection method.
S240: and (3) page out-of-range positioning, namely when triggering page out-of-range access exception, positioning the instruction position of the page out-of-range access exception through stack backtracking.
In the specific method of this step, please refer to step S140 of the first embodiment of a memory overflow detecting method.
S250: an abnormal release judgment judges whether or not a data page is an empty data page when releasing the data page.
The data page is released by a free function through a memory release mode, corresponds to the data page distributed through a malloc function, and is suitable for the release of dynamic memories of various objects. The determination of this step is made when the data page is released by the memory release free function.
If yes, step S260 is executed, otherwise step S270 is executed.
And judging whether the released data page is an idle data page or not by judging whether the released data page is the data page in the idle memory linked list or not.
S260: and reporting an abnormal release error when the released data page is an idle data page.
The abnormal release error is that the released data page is not the allocated data page, but the idle data page in the idle memory linked list.
S270: and judging whether the actual data of the residual position in the released data page is different from the magic number data or not.
Wherein, if the same, step S290 is executed, otherwise step S280 is executed.
S280: and reporting page boundary crossing access errors when the actual data of the residual positions in the released data page is different from the magic data.
The page-crossing access error is a position where the memory access exceeds the allocated memory in one data page.
S290: and releasing the data page, and storing the pointer of the released data page into a free memory linked list.
And releasing the data pages which are not abnormally released to an idle memory linked list for subsequent memory allocation.
In summary, the second embodiment of the memory overflow detection method increases the detection of abnormal release and page-crossing access errors by analyzing the released memory on the basis of the first embodiment of the memory overflow detection method, and further improves the stability and reliability of the program. The method of the embodiment can run microkernels or macrokernels of various operating systems, and is particularly suitable for microkernels based on real-time operating systems.
An embodiment of a memory overflow detection device is described below with reference to fig. 6-7.
Embodiments of a memory overflow detection device-the method of performing an embodiment of a memory overflow detection method-has all the advantages of an embodiment of a memory overflow detection method. The device of the embodiment can be deployed in microkernels or macrokernels of various operating systems, and is particularly suitable for microkernels based on real-time operating systems.
Fig. 6 shows a structure of a first embodiment of a memory overflow detecting device, including: a memory initialization module 610, a memory allocation module 620, a page crossing detection module 630, and a page crossing location module 640.
The memory initialization module 610 is configured to partition the protection page and the data page with address intervals from the memory pool. The working principle and advantages of the method refer to step S110 of the first embodiment of a memory overflow detecting method.
The memory allocation module 620 is configured to allocate a free data page each time a memory is allocated, and set a protection page adjacent to the allocated data page to be invalid. The working principle and advantages of the method refer to step S120 of the first embodiment of a memory overflow detecting method.
The page crossing detection module 630 is configured to trigger a page crossing access exception when an adjacent protection page of the allocated data page is accessed. The working principle and advantages of the method refer to step S130 of the first embodiment of a memory overflow detecting method.
The page crossing location module 640 is configured to locate, when triggering a page crossing access exception, an instruction location of the page crossing access exception through a stack trace. The working principle and advantages of the method refer to step S140 of the first embodiment of a memory overflow detecting method.
The second embodiment of the memory overflow detecting device performs the method described in the second embodiment of the memory overflow detecting method, and has all the advantages of the second embodiment of the memory overflow detecting method. The device of the embodiment can be deployed in microkernels or macrokernels of various operating systems, and is particularly suitable for microkernels based on real-time operating systems.
Fig. 7 shows a structure of a second embodiment of a memory overflow detecting device, including: the memory system comprises a memory initialization module 710, a memory allocation module 720, a page crossing detection module 730, a page crossing location module 740, an abnormal release determination module 750, an abnormal release report module 760, an in-page crossing determination module 770, an in-page crossing report module 780 and a release data page module 790.
The memory initialization module 710 is configured to partition the protection pages and the data pages with address intervals from the memory pool, and construct a free memory linked list to manage the free data pages. The working principle and advantages of the method refer to step S210 of the second embodiment of the memory overflow detecting method.
The memory allocation module 720 is configured to allocate a free data page and set its adjacent free protection page to be invalid every time memory allocation is performed. The working principle and advantages of the method refer to step S220 of the second embodiment of the memory overflow detecting method.
The page crossing detection module 730 is configured to trigger a page crossing access exception when an adjacent protection page of the allocated data page is accessed. The working principle and advantages of the method refer to step S230 of the second embodiment of the memory overflow detecting method.
The page-out-of-bound location module 740 is configured to locate, via a stack trace, an instruction location of the page-out-of-bound access exception when the page-out-of-bound access exception is triggered. The working principle and advantages of the method refer to step S240 of the second embodiment of the memory overflow detecting method.
The abnormal release determination module 750 is configured to determine whether a data page is a free data page when releasing the data page. The working principle and advantages of the method refer to step S250 of the second embodiment of the memory overflow detecting method.
The abnormal release report module 760 is configured to report an abnormal release error when the released data page is a free data page. The working principle and advantages of the method refer to step S260 of the second embodiment of the memory overflow detecting method.
The page boundary crossing determination module 770 is configured to determine whether actual data of a remaining position in the released data page is different from magic data. The working principle and advantages of the method refer to step S270 of the second embodiment of the memory overflow detecting method.
The intra-page out-of-range reporting module 780 is configured to report an intra-page out-of-range access error when actual data of a remaining position in the released data page is different from magic data. The working principle and advantages of the method refer to step S280 of the second embodiment of the memory overflow detecting method.
The free data page module 790 is configured to store pointers to the free data pages in the free memory linked list. The working principle and advantages of the method refer to step S290 of the second embodiment of the memory overflow detection method.
The embodiment of the invention also provides an operating system which is executed by a computer to enable the computer to execute the method of the first embodiment of the memory overflow detection method or the second embodiment of the memory overflow detection method.
An embodiment of the present invention also provides a computing device, described in detail below with respect to fig. 8.
The computing device 800 includes a processor 810, a memory 820, a communication interface 830, a bus 840.
It should be appreciated that the communication interface 830 in the computing device 800 shown in this figure may be used to communicate with other devices.
Wherein the processor 810 may be coupled to the memory 820. The memory 820 may be used to store the program code and data. Accordingly, the memory 820 may be a storage unit internal to the processor 810, an external storage unit independent of the processor 810, or a component including a storage unit internal to the processor 810 and an external storage unit independent of the processor 810.
Optionally, computing device 800 may also include a bus 840. The memory 820 and the communication interface 830 may be connected to the processor 810 through a bus 840. Bus 840 may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (EFStended Industry Standard Architecture, EISA) bus, among others. The bus 840 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one line is shown in the figure, but not only one bus or one type of bus.
It should be appreciated that in embodiments of the present invention, the processor 810 may employ a central processing unit (central processing unit, CPU). The processor may also be other general purpose processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate arrays (field programmable gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Or the processor 810 may employ one or more integrated circuits for executing associated routines to implement the techniques provided by embodiments of the present invention.
The memory 820 may include read only memory and random access memory and provides instructions and data to the processor 810. A portion of the processor 810 may also include non-volatile random access memory. For example, the processor 810 may also store information of the device type.
When the computing device 800 is running, the processor 810 executes computer-executable instructions in the memory 820 to perform the operational steps of the various method embodiments.
It should be understood that the computing device 800 according to the embodiments of the present invention may correspond to a respective subject performing the methods according to the embodiments of the present invention, and that the above and other operations and/or functions of the respective modules in the computing device 800 are respectively for implementing the respective flows of the methods according to the embodiments of the present method, and are not repeated herein for brevity.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the method embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the decoding method according to the embodiments of the present invention. The storage medium includes various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk.
The embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program for performing the operational steps of the method embodiments when executed by a processor.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the invention, which fall within the scope of the invention.

Claims (10)

1. The memory overflow detection method is characterized by comprising the following steps:
dividing protection pages and data pages with address interval distribution from a memory pool;
allocating an idle data page when memory allocation is performed each time, and setting adjacent protection pages of the allocated data pages as invalid;
when an adjacent guard page of the allocated data page is accessed, a page out-of-range access exception is triggered.
2. The method as recited in claim 1, further comprising:
when the page out-of-range access exception is triggered, the instruction position of the exception access protection page is located through stack backtracking.
3. The method as recited in claim 1, further comprising:
when one of the released data pages is an empty data page, an abnormal release error is reported.
4. The method as recited in claim 1, further comprising: when the allocated data page is larger than the memory required by the allocation, filling magic data in the rest positions of the allocated data page;
when the actual data of the rest position of one released data page is different from the magic data, reporting an out-of-range access error in the page.
5. The method of claim 4, wherein when the allocated data page is greater than the memory required for the current allocation, the allocated memory is located in the middle of the allocated data page.
6. The method according to any one of claims 1 to 5, further comprising: the free data pages are managed by the free memory linked list.
7. A memory overflow detection device, comprising:
the memory initialization module is used for dividing the memory pool into protection pages and data pages with address interval distribution;
the memory allocation module is used for allocating an idle data page and an adjacent idle protection page thereof when the memory is allocated each time and setting the adjacent protection pages of the allocated data page as invalid;
and the page out-of-range detection module is used for triggering page out-of-range access exception when the adjacent protection page of the allocated data page is accessed.
8. An operating system which, when executed by a computer, causes the computer to perform the method of any of claims 1 to 6.
9. A computing device, comprising:
a bus;
a communication interface connected to the bus;
at least one processor coupled to the bus; and
at least one memory coupled to the bus and storing program instructions that, when executed by the at least one processor, cause the at least one processor to perform the method of any of claims 1 to 6.
10. A computer readable storage medium, characterized in that it has stored thereon program instructions, which when executed by a computer, cause the computer to perform the method of any of claims 1 to 6.
CN202311142533.9A 2023-09-05 2023-09-05 Memory overflow detection method, device, operating system, equipment and storage medium Pending CN117149644A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311142533.9A CN117149644A (en) 2023-09-05 2023-09-05 Memory overflow detection method, device, operating system, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311142533.9A CN117149644A (en) 2023-09-05 2023-09-05 Memory overflow detection method, device, operating system, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117149644A true CN117149644A (en) 2023-12-01

Family

ID=88898457

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311142533.9A Pending CN117149644A (en) 2023-09-05 2023-09-05 Memory overflow detection method, device, operating system, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117149644A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117648196A (en) * 2024-01-29 2024-03-05 苏州元脑智能科技有限公司 Memory allocation protection method, device, equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117648196A (en) * 2024-01-29 2024-03-05 苏州元脑智能科技有限公司 Memory allocation protection method, device, equipment and medium
CN117648196B (en) * 2024-01-29 2024-04-26 苏州元脑智能科技有限公司 Memory allocation protection method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN107357666B (en) Multi-core parallel system processing method based on hardware protection
Serebryany et al. {AddressSanitizer}: A fast address sanity checker
US9317360B2 (en) Machine check summary register
US8762797B2 (en) Method and apparatus for detecting memory access faults
US7711914B2 (en) Debugging using virtual watchpoints
US9804917B2 (en) Notification of address range including non-correctable error
CN107133144B (en) Memory monitoring device and method for dynamically monitoring use errors of heap memory
CN117149644A (en) Memory overflow detection method, device, operating system, equipment and storage medium
US9639451B2 (en) Debugger system, method and computer program product for utilizing hardware breakpoints for debugging instructions
CN107977577B (en) Access instruction access detection method and device
US20040015864A1 (en) Method and system for testing memory operations of computer program
KR102254159B1 (en) Method for detecting real-time error in operating system kernel memory
US20130262947A1 (en) Information processing apparatus, and method of controlling information processing apparatus
Seo et al. A profiling method by PCB hooking and its application for memory fault detection in embedded system operational test
US9348723B2 (en) Method, system, and computer program product
Lam et al. Checking array bound violation using segmentation hardware
US20230119005A1 (en) Data race detection with per-thread memory protection
US20090172368A1 (en) Hardware Based Runtime Error Detection
CN111190658B (en) System for supporting dynamic loading of application program on SoC (system on chip) without MMU (memory management unit) based on-chip execution
Serebryany et al. GWP-ASan: Sampling-Based Detection of Memory-Safety Bugs in Production
US10229070B2 (en) Computer-implemented method and a system for encoding a heap application memory state using shadow memory
Liu et al. Csod: context-sensitive overflow detection
Dolz et al. Enabling semantics to improve detection of data races and misuses of lock‐free data structures
US20230161678A1 (en) Classification of different types of cache misses
CN117034256A (en) Task stack overflow detection method, device, equipment and storage medium

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