CN108388517A - A kind of internal-memory detection method, device, equipment and storage medium - Google Patents
A kind of internal-memory detection method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN108388517A CN108388517A CN201810210345.8A CN201810210345A CN108388517A CN 108388517 A CN108388517 A CN 108388517A CN 201810210345 A CN201810210345 A CN 201810210345A CN 108388517 A CN108388517 A CN 108388517A
- Authority
- CN
- China
- Prior art keywords
- memory
- internal storage
- storage access
- region
- address
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/366—Software debugging using diagnostics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/08—Error detection or correction by redundancy in data representation, e.g. by using checking codes
- G06F11/10—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
- G06F11/1008—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices
- G06F11/1012—Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's in individual solid state devices using codes or arrangements adapted for a specific type of error
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Storage Device Security (AREA)
Abstract
The invention discloses a kind of internal-memory detection method, device, equipment and storage mediums.This method includes:Memory access request is obtained, memory access request includes internal storage access address;If internal storage access address is legal address, corresponding internal storage access region is obtained according to internal storage access address, internal storage access region includes stack internal storage access region;Stack internal storage access region is accessed according to memory access request, and whether detection variable and default detection variable of the lookup in region before and after local variable inside function defined in stack internal storage access region are consistent, if it is inconsistent, determining memory abnormal.The embodiment of the present invention solves the problems, such as memory detection limitation in the prior art, realizes and is quickly positioned to memory abnormal, to improve the efficiency and accuracy rate of memory abnormal detection.
Description
Technical field
The present embodiments relate to detection techniques more particularly to a kind of internal-memory detection method, device, equipment and storage to be situated between
Matter.
Background technology
Memory management is extremely important in Computer System Design, and efficient Memory Allocation is discharged and is organized in and answers
More and more important in, memory often occurs due to program exception problem caused by some maloperations, sternly in use
It will lead to computer corruption when weight, simultaneously as the problem of memory abnormal causes relatively is difficult to position, also be brought to development
Therefore how huge challenge realizes the normal operation to computer system and computer program to the accurate judgement of memory abnormal
It is vital.
In the prior art, it does not deposit internally generally and is detected, or only the application of memory and release are detected, then
Simply detect Memory Leaks when computer program exits, this memory detection mode is only able to detect the interior of wherein sub-fraction
Exception is deposited, the memory abnormal that can not be directed to various complexity makes effective detection.
Invention content
A kind of internal-memory detection method of present invention offer, device, equipment and storage medium, carry out soon memory abnormal with realizing
Speed positioning, effectively detects memory abnormal situation.
In a first aspect, an embodiment of the present invention provides a kind of internal-memory detection method, this method includes:
Memory access request is obtained, the memory access request includes internal storage access address;
If the internal storage access address is legal address, corresponding memory is obtained according to the internal storage access address and is visited
Ask region, the internal storage access region packet stack internal storage access region;
Stack internal storage access region is accessed according to the memory access request, and searches and is located at stack internal storage access area
Whether the detection variable and default detection variable inside function defined in domain before and after local variable in region are consistent, if differed
It causes, it is determined that memory abnormal.
Further, the internal storage access region further includes heap memory access region, and this method further includes:
The heap memory access region is accessed according to the memory access request, and calculates access operation and generates data
Cyclic redundancy check;
If the cyclic redundancy check and default cyclic redundancy check are inconsistent, it is determined that memory abnormal.
Further, before accessing stack internal storage access region according to the memory access request, this method is also wrapped
It includes:
It searches beacon information in the area of isolation in the internal storage access region and whether default beacon information is consistent, if
It is inconsistent, it is determined that memory abnormal.
Further, the internal storage access address is legal address, including:
Obtain the use information of current memory;
Addressable memory address library is established according to the use information;
The internal storage access address is matched with the record in the memory address library, if successful match, really
The fixed internal storage access address is legal address.
Further, stack internal storage access region is accessed according to the memory access request, including:
According to the memory access request, stack internal storage access region is accessed by having secure access to interface.
Further, the heap memory access region is accessed according to the memory access request, including:
According to the memory access request, the heap memory access region is accessed by having secure access to interface.
Second aspect, the embodiment of the present invention additionally provide a kind of memory detection device, which includes:
Memory access request acquisition module, for obtaining memory access request, the memory access request includes that memory is visited
Ask address;
Internal storage access region acquisition module, if being legal address for the internal storage access address, according to described interior
It deposits access address and obtains corresponding internal storage access region, the internal storage access region includes stack internal storage access region;
The first determining module of memory abnormal, for accessing stack internal storage access region according to the memory access request,
And it searches the detection variable being located inside function defined in stack internal storage access region before and after local variable in region and presets
Whether consistent variable is detected, if it is inconsistent, determining memory abnormal.
Further, the internal storage access region further includes heap memory access region, which further includes:
Cyclic redundancy check acquisition module for accessing the heap memory access region according to the memory access request, and is counted
Calculate the cyclic redundancy check that access operation generates data;
The second determining module of memory abnormal, if inconsistent for the cyclic redundancy check and default CRC check, really
Determine memory abnormal.
The third aspect, the embodiment of the present invention additionally provide a kind of equipment, which includes:
One or more processors;
Memory, for storing one or more programs;
When one or more of programs are executed by one or more of processors so that one or more of processing
Device realizes internal-memory detection method as previously described.
Fourth aspect, the embodiment of the present invention additionally provide a kind of computer readable storage medium, are stored thereon with computer
Program, the program realize internal-memory detection method as previously described when being executed by processor.
The present invention is by obtaining memory access request, and memory access request includes internal storage access address, if internal storage access
Address is legal address, then obtains corresponding internal storage access region according to internal storage access address, and internal storage access region includes in stack
Access region is deposited, and stack internal storage access region is accessed according to memory access request, searches and is located at defined in stack internal storage access region
Whether the detection variable and the default variable that detects inside function before and after local variable in region are consistent, if it is inconsistent, can be with
Determine there are memory abnormal situation, solve the problems, such as in the prior art memory detection limitation, realize to memory abnormal into
Row quickly positioning, to improve the efficiency and accuracy rate of memory abnormal detection.
Description of the drawings
Fig. 1 is a kind of flow chart of internal-memory detection method in the embodiment of the present invention one;
Fig. 2 is a kind of flow chart of internal-memory detection method in the embodiment of the present invention two;
Fig. 3 is a kind of structural schematic diagram of memory detection device in the embodiment of the present invention three;
Fig. 4 is a kind of structural schematic diagram of equipment in the embodiment of the present invention four.
Specific implementation mode
The present invention is described in further detail with reference to the accompanying drawings and examples.It is understood that this place is retouched
The specific embodiment stated is used only for explaining the present invention rather than limitation of the invention.It also should be noted that in order to just
Only the parts related to the present invention are shown in description, attached drawing rather than entire infrastructure.
Embodiment one
Fig. 1 is a kind of flow chart for internal-memory detection method that the embodiment of the present invention one provides, and the present embodiment is applicable to soon
Speed be accurately positioned memory abnormal the case where, this method can be executed by memory detection device, the device may be used software and/
Or the mode of hardware is realized, which can be configured in equipment, such as typically computer etc..As shown in Figure 1, this method
Specifically comprise the following steps:
S110, memory access request is obtained, memory access request includes internal storage access address;
In a specific embodiment of the present invention, when internal storage access event is triggered, memory access request is obtained, wherein
Memory access request can specifically include internal storage access address, and in addition to this, memory access request can also include specifically memory
Size and internal storage access period etc..Inter access address is found from memory access request, in order to can subsequently be visited
Ask operation.
If S120, internal storage access address are legal address, corresponding internal storage access is obtained according to internal storage access address
Region, internal storage access region include stack internal storage access region;
In a specific embodiment of the present invention, in order to ensure carrying out the legitimacy of internal storage access operation, firstly, it is necessary to internally
The legitimacy for depositing access address is detected, i.e., in the case where it is legal memory address to ensure internal storage access address, carries out
The operation of subsequent internal storage access, internal storage access operation mentioned here can be memory read, memory write-in and memory copying etc.,
More specifically, internal storage access address mentioned here, which is legal address, two layers of meaning, first, determination is legal memory
Location, second, being legal internal storage access address on the basis of determination is legal memory address.This is since there may be memories
Access address is to meet the legal memory address of memory address requirement, but is not meet internal storage access address challenges legal
Internal storage access address.Illustratively, as a certain address be meet the legal memory address of memory address call format, but this
A address does not have the permission for accessing the region of memory, and therefore, which is not just legal internal storage access address.In determination
Access address is deposited on the basis of legal address, to determine corresponding internal storage access region according to internal storage access address, wherein interior
It may include stack internal storage access region to deposit access region.The reference of the variable and object of some fundamental types defined in function becomes
Amount is all allocated in function stack memory, will be in stack addressing region when one section of code block defines a variable
In will discharge distributed memory headroom automatically after more than the action scope of variable, make for this variable storage allocation space
Obtaining the memory headroom can be otherwise utilized immediately.Namely the parameter value of function is stored in stack memory, the value etc. of local variable, by
Compiler distributes release automatically.
S130, stack internal storage access region is accessed according to memory access request, and search to be located in stack internal storage access region and determine
Whether the detection variable and default detection variable inside adopted function before and after local variable in region are consistent, if it is inconsistent, really
Determine memory abnormal.
In a specific embodiment of the present invention, according to described in S120 it is found that storing function in stack internal storage access region
The value etc. of parameter value and local variable can be fixed in order to determine that stack internal storage access region whether there is memory abnormal situation
The default detection variable of particular value is inserted into inside adopted function in the front and back region of local variable, and detects and is inserted into before function exits
The default detection variable whether changed, can determine that internal storage access region of popping whether there is memory abnormal according to this.
When accessing stack internal storage access region according to memory access request, by searching for fixed in stack internal storage access region
Whether detection variable inside adopted function before and after local variable in region and default detection variable unanimously determine stack internal storage access
Region can determine the case where there are memory abnormals with the presence or absence of memory abnormal if the two is inconsistent.Described here is interior
It deposits the abnormal data that can refer to stack internal storage access region and there is the case where being tampered.
It should be noted that the specific format and content of default detection variable can be set according to actual conditions,
It is not specifically limited herein.
The technical solution of the present embodiment, by obtaining memory access request, memory access request includes internal storage access address,
If internal storage access address is legal address, corresponding internal storage access region, internal storage access are obtained according to internal storage access address
Region includes stack internal storage access region, and accesses stack internal storage access region according to memory access request, searches and is located at the visit of stack memory
Ask whether the detection variable inside function defined in region before and after local variable in region and the default variable that detects are consistent, if not
Unanimously, then it can determine there are memory abnormal situation solve the problems, such as memory detection limitation in the prior art, realize pair
Memory abnormal is quickly positioned, to improve the efficiency and accuracy rate of memory abnormal detection.
Further, based on the above technical solution, internal storage access region further includes heap memory access region, the party
Method can also include specifically:
Heap memory access region is accessed according to memory access request, and calculates the cyclic redundancy check that access operation generates data;
If cyclic redundancy check and default cyclic redundancy check are inconsistent, it is determined that memory abnormal.
In a specific embodiment of the present invention, internal storage access region can also include heap memory access region, relative to preceding
Stack internal storage access region described in text, heap memory access region be by programmer manually complete memory application and release, and
The content specifically stored in heap memory access region is determined by programmer and is completed.It is accessed according to memory access request
When heap memory access region, the cyclic redundancy check that current access operation generates data is calculated, wherein CRC (Cyclic
Redundancy Check, cyclic redundancy check) it is common a kind of error check code in data communication field, it is characterized in that letter
The length for ceasing field and check field can be arbitrarily selected.Basic principle is:Splice R check codes again after K information codes,
Entire code length is N, and therefore, this coding is also (N, K) code.Splice in check code and information code after information code
There is certain specific relationships between appearance.If because certain reason makes a certain position in information code or certain generation mistakes,
This specific relationship will be destroyed.Therefore, by checking this relationship, so that it may to realize the inspection to data correctness.
In to memory detection process, in addition to examining the data that access operation generates, the correctness of data itself using cyclic redundancy check
It outside, can be with the legitimacy of test access operation itself, if it is determined that it is illegal to go out access operation, then memory can be determined
There are abnormal conditions.
Specifically, after completing to the access operation of heap memory access region, the schools CRC that access operation generates data are calculated
Test code and by the cyclic redundancy check synchronized update to preset field, wherein access operation here can refer to memory read, memory
Write-in and memory copying etc..In addition, it is to be particularly noted that here update operation only to heap memory access region into
Capable access operation be it is legal in the case of can just execute, namely if to heap memory access region carry out access operation be not
Legal, then can equally calculate the access operation generates the cyclic redundancy check of data, but preset field preservation will not be updated
Cyclic redundancy check.
Based on above-mentioned, before carrying out next access operation to heap memory access region, can be calculated by comparing
Whether cyclic redundancy check and default cyclic redundancy check unanimously determine whether access operation is legal, and then it is different to determine whether there is memory
Reason condition, this can all calculate the CRC check that access operation generates data just because of no matter whether access operation is legal every time
Code, but cyclic redundancy check is preset only when access operation is legal, just meeting synchronized update, is allowed to the schools CRC to be calculated
Test code, and when access operation is illegal, can't synchronized update, it is that legal access operation generates still to save as last time
The cyclic redundancy check of data it will be appreciated that, what default cyclic redundancy check described here can indicate to be preserved in preset field
Cyclic redundancy check.It can obtain accordingly:If the cyclic redundancy check being calculated and default cyclic redundancy check are inconsistent, illustrate to visit
It asks that operation is illegal, and then can determine memory there are abnormal conditions.Memory abnormal described here can refer to heap memory
There is the case where being tampered in the data of access region.
Furthermore, it is necessary to which explanation, default cyclic redundancy check are updated according to actual conditions, newer condition is
Access operation is legal.
Further, based on the above technical solution, stack internal storage access region is being accessed according to memory access request
Before, this method can also include specifically:
Whether the beacon information and default beacon information in the area of isolation in lookup internal storage access region are consistent, if differed
It causes, it is determined that memory abnormal.
It in a specific embodiment of the present invention, can be in the internal storage access region being assigned to when carrying out memory application operation
Front and back two parts delimit area of isolation and insert specifically default beacon information in area of isolation, wherein area of isolation
Specific location and the particular content of default beacon information can be set according to actual conditions, be not specifically limited herein.
Later, if the access operation carried out is legal, default beacon information can remain unchanged, that is, remain as and carrying out memory application
It is set when operation, and if carry out access operation be illegal, default beacon information can change, i.e., in progress
Deposit difference set when application access operation.It therefore, can be by comparing the mark in the area of isolation in internal storage access region
Whether information and default beacon information unanimously determine whether access operation is legal, and then determine whether there is memory abnormal feelings
Condition.It should be noted that default beacon information described here can refer to when carrying out memory application operation, in area of isolation institute
The beacon information of setting.
Based on above-mentioned, before accessing stack internal storage access region according to memory access request every time, memory can be searched
Whether the beacon information in the area of isolation of access region is consistent with default beacon information, if inconsistent, illustrates access operation
It is illegal, and then can determines memory there are abnormal conditions.
It, can be into addition to before accessing stack internal storage access region according to memory access request in addition it is also necessary to explanation
The detection of row beacon information equally can also carry out mark letter before accessing heap memory access region according to memory access request
The detection of breath, detection mode is identical as the detection mode carried out for stack internal storage access region, no longer specifically repeats herein.
It is to be understood that the detection of beacon information can be all carried out before accessing internal storage access region according to memory access request, so as to
In determining whether there is memory abnormal situation.Memory abnormal situation described here can refer to internal storage access region, and there are memories to get over
The case where boundary.
Further, based on the above technical solution, internal storage access address is legal address, be can specifically include:
Obtain the use information of current memory;
Addressable memory address library is established according to use information;
Internal storage access address is matched with the record in memory address library, if successful match, it is determined that memory is visited
Ask that address is legal address.
In a specific embodiment of the present invention, it can be visited by obtaining the use information of current memory to determine in memory
It asks the region of operation, and addressable memory address library is established according to use information, wherein use information described here can be with
Including total amount of memory, memory headroom has been used, may have access to the address etc. of memory headroom and addressable memory headroom, memory address
Address recorded in library can refer to the address of addressable memory headroom.Due to the address recorded in memory address library be can
The address of memory headroom is accessed, i.e., it is that legal internal storage access address therefore can be by internal storage access address and memory address
The address of the addressable memory headroom recorded in library carries out the matching analysis, if successful match, with can determining internal storage access
Location is legal address and is legal internal storage access address.
Further, based on the above technical solution, stack internal storage access region, tool are accessed according to memory access request
Body may include:
According to memory access request, stack internal storage access region is accessed by safe interface.
In a specific embodiment of the present invention, secure access interface can be arranged to unite come the operation for carrying out memory
One management, wherein operation described here may include memory application operation and internal storage access operation, can also be released including memory
Operation is put, internal storage access operation may include memory reading, memory write-in and memory copying etc. again.Correspondingly, safe interface can
To include memory application, memory reading, memory write-in, memory copying and memory release etc..
According to memory access request, stack internal storage access region can specifically be visited by the safe interface of setting
It asks.
Further, based on the above technical solution, heap memory access region, tool are accessed according to memory access request
Body may include:
According to memory access request, heap memory access region is accessed by safe interface.
In a specific embodiment of the present invention, according to described previously it is found that being directed to for stack internal storage access region, Ke Yitong
It crosses safe interface and accesses stack internal storage access region, likewise, for for heap memory access region, it can also be according to internal storage access
Request, can specifically access to heap memory access region by the safe interface of setting.
The above-mentioned safe interface for described in stack internal storage access region and heap memory access region refers to same safety
Interface, it is therefore, above-mentioned it is also understood that according to memory access request access internal storage access region, it can specifically include:According to
Memory access request accesses internal storage access region by safe interface.
Furthermore, it is necessary to explanation is based on this since access operation is carried out by way of safe interface, in order to
The information using memory can be got, is needed to accessing malloc and free functions involved in internal storage access region process
And the occupation mode of new and delete operators is changed accordingly.Specific volume, for access internal storage access region mistake
Involved malloc and free functions may be used the mode redefined and be used in journey, new and delete operators can
It is used in a manner of using heavy duty.
In addition it is also necessary to which explanation is it will be appreciated that previously described legal operation, can refer to must be by connecing safely
The operation that mouth is carried out, opposite, illegal operation is may be considered if not the operation carried out by safe interface,
In, operation may include memory application operation and internal storage access operation.
In addition, it is another it should be noted that during to internal storage access with the presence or absence of abnormal be detected, meanwhile,
The use information of current memory can be periodically monitored and obtained to the memory not discharged, when the use according to current memory
When information determines that may have access to memory headroom is less than smallest accessible memory headroom threshold value, warning information is generated, warning information is used
In prompt, currently addressable memory headroom is insufficient.Meanwhile the memory not discharged is monitored, it can be used to determine whether exist
The case where RAM leakage.
It, can only be for certain memory abnormal situation be detected, by using safe interface in compared with the existing technology
Internal memory operation is managed collectively, may be implemented to be detected a variety of memory abnormal situations, memory as previously described is got over
Boundary, heap memory access region data be tampered situations such as being tampered with the data in stack internal storage access region, in improving
Deposit the efficiency and accuracy rate of abnormality detection.
Embodiment two
Fig. 2 is a kind of flow chart of internal-memory detection method provided by Embodiment 2 of the present invention, and the present embodiment is applicable to soon
Speed be accurately positioned memory abnormal the case where, this method can be executed by memory detection device, the device may be used software and/
Or the mode of hardware is realized, which can be configured in equipment, such as typically computer etc..As shown in Fig. 2, this method
Specifically comprise the following steps:
S210, memory access request is obtained, memory access request includes internal storage access address;
If S220, internal storage access address are legal address, corresponding internal storage access is obtained according to internal storage access address
Region, internal storage access region include stack internal storage access region and heap memory access region;
S230, beacon information in the area of isolation in internal storage access region is searched and whether default beacon information is consistent;If
It is then to execute S290;If it is not, then executing S280;
S240, according to memory access request, stack internal storage access region is accessed by safe interface, and be transferred to and execute S260;
S250, according to memory access request, heap memory access region is accessed by safe interface, and calculate access operation production
The cyclic redundancy check of raw data, and be transferred to and execute S270;
S260, the detection variable being located inside function defined in stack internal storage access region before and after local variable in region is searched
It is whether consistent with default detection variable;If so, executing S290;If it is not, then executing S280;
S270, judge whether cyclic redundancy check is consistent with default cyclic redundancy check;If so, executing S290;If it is not, then executing
S280;
S280, memory abnormal is determined;
S290, determine that memory is normal.
In a specific embodiment of the present invention, it should be noted that the memory abnormal situation described in S280 may include
Memory overwriting, stack internal storage access region data be tampered situations such as being tampered with the data of heap memory access region, it is right respectively
Situation that should be involved in S230, S260 and S270.Memory described in S290 can normally refer to be determined in each case
Memory it is normal, it is understood that be situation one:For the memory overwriting detection involved by S230, if meeting internal storage access
Beacon information in the area of isolation in region is consistent with default beacon information, it is determined that the case where memory overwriting is not present;Situation
Two:It is tampered detection for the data in the stack internal storage access region involved by S240 and S260, if meeting stack internal storage access area
Detection variable inside function defined in domain before and after local variable in region is consistent with default detection variable, it is determined that stack is not present
The case where data in internal storage access region are tampered;Situation three:For the heap memory access region involved by S250 and S270
Data are tampered detection, if it is consistent with default cyclic redundancy check to meet cyclic redundancy check, it is determined that heap memory access region is not present
The case where data in domain are tampered detection.But the normal result of memory determined by each case is only applicable to this kind of situation,
Whether memory is abnormal in the case of can not determining other.Such as, according to circumstances a mode provided determines that memory overwriting is not present
The case where, but the data that can not determine whether there is the stack internal storage access region involved in situation two are tampered and situation three
Involved in the data of heap memory access region be tampered.In addition it is also necessary to explanation, S230 is to access to grasp in current memory
It is carried out before making, S250 and S260 are carried out after the completion of current memory access operation, and S270 is grasped in next internal storage access
It is carried out before making.
The technical solution of the present embodiment is managed collectively internal memory operation by using safe interface, realizes to more
Kind memory abnormal situation is detected, as the data of memory overwriting, heap memory access region are tampered and stack internal storage access region
Data situations such as being tampered, solve the problems, such as memory detection limitation in the prior art, realize and memory abnormal is carried out
Quickly positioning, to improve the efficiency and accuracy rate of memory abnormal detection.
Embodiment three
Fig. 3 is a kind of structural schematic diagram for memory detection device that the embodiment of the present invention three provides, and the present embodiment is applicable
In quick and precisely position memory abnormal the case where, which may be used software and/or the mode of hardware is realized, which can be with
It is configured in equipment, such as typically computer etc..As shown in figure 3, the device specifically includes:
Memory access request acquisition module 310, for obtaining memory access request, memory access request includes internal storage access
Address;
Internal storage access region acquisition module 320, if being legal address for internal storage access address, according to internal storage access
Address obtains corresponding internal storage access region, and internal storage access region includes stack internal storage access region;
The first determining module of memory abnormal 330 for accessing stack internal storage access region according to memory access request, and is searched
It is with the default variable that detects positioned at the detection variable defined in stack internal storage access region inside function before and after local variable in region
It is no consistent, if it is inconsistent, determining memory abnormal.
The technical solution of the present embodiment obtains memory access request by memory access request acquisition module 310, and memory is visited
Ask that request includes internal storage access address, if acquisition module 320 internal storage access address in internal storage access region is legal address, root
Corresponding internal storage access region is obtained according to internal storage access address, internal storage access region includes stack internal storage access region, memory abnormal
First determining module 330 simultaneously accesses stack internal storage access region according to memory access request, searches and is located in stack internal storage access region
Whether the detection variable and default detection variable inside defined function before and after local variable in region are consistent, if it is inconsistent,
It can determine there are memory abnormal situation solve the problems, such as memory detection limitation in the prior art, realize different to memory
It is often quickly positioned, to improve the efficiency and accuracy rate of memory abnormal detection.
Further, based on the above technical solution, internal storage access region further includes heap memory access region, the dress
Setting can also include specifically:
Cyclic redundancy check acquisition module for accessing heap memory access region according to memory access request, and calculates access behaviour
Make the cyclic redundancy check of generation data;
The second determining module of memory abnormal, if inconsistent for cyclic redundancy check and default cyclic redundancy check, it is determined that interior
Deposit exception.
Further, based on the above technical solution, which can also include specifically:
Memory abnormal third determining module, beacon information in area of isolation for searching internal storage access region with it is default
Whether beacon information is consistent, if it is inconsistent, determining memory abnormal.
Further, based on the above technical solution, internal storage access region acquisition module 320, can specifically include:
Use information acquiring unit, the use information for obtaining current memory;
Unit is established in memory address library, for establishing addressable memory address library according to use information;
Legal address determination unit, for internal storage access address to be matched with the record in memory address library, if
Successful match, it is determined that internal storage access address is legal address.
Further, based on the above technical solution, stack internal storage access region, tool are accessed according to memory access request
Body may include:
According to memory access request, stack internal storage access region is accessed by safe interface.
Further, based on the above technical solution, heap memory access region, tool are accessed according to memory access request
Body may include:
According to memory access request, heap memory access region is accessed by having secure access to interface.
What the embodiment of the present invention was provided is configured at the executable any embodiment institute of the present invention of memory detection device of equipment
The internal-memory detection method applied to equipment provided, has the corresponding function module of execution method and advantageous effect.
Example IV
Fig. 4 is a kind of structural schematic diagram for equipment that the embodiment of the present invention four provides.Fig. 4 is shown suitable for being used for realizing this
The block diagram of the example devices 412 of invention embodiment.The equipment 412 that Fig. 4 is shown is only an example, should not be to the present invention
The function and use scope of embodiment bring any restrictions.
As shown in figure 4, equipment 412 is showed in the form of universal computing device.The component of equipment 412 may include but unlimited
In:One or more processor 416, system storage 428 are connected to different system component (including 428 He of system storage
Processor 416) bus 418.
Bus 418 indicates one or more in a few class bus structures, including memory bus or Memory Controller,
Peripheral bus, graphics acceleration port, processor or the local bus using the arbitrary bus structures in a variety of bus structures.It lifts
For example, these architectures include but not limited to industry standard architecture (ISA) bus, microchannel architecture (MAC)
Bus, enhanced isa bus, Video Electronics Standards Association (VESA) local bus and peripheral component interconnection (PCI) bus.
Equipment 412 typically comprises a variety of computer system readable media.These media can be it is any can be by equipment
412 usable mediums accessed, including volatile and non-volatile media, moveable and immovable medium.
System storage 428 may include the computer system readable media of form of volatile memory, such as deposit at random
Access to memory (RAM) 430 and/or cache memory 432.Equipment 412 may further include other removable/not removable
Dynamic, volatile/non-volatile computer system storage medium.Only as an example, storage system 434 can be used for read and write can not
Mobile, non-volatile magnetic media (Fig. 4 do not show, commonly referred to as " hard disk drive ").Although not shown in fig 4, Ke Yiti
For the disc driver for being read and write to moving non-volatile magnetic disk (such as " floppy disk "), and to moving non-volatile light
The CD drive of disk (such as CD-ROM, DVD-ROM or other optical mediums) read-write.In these cases, each driver
It can be connected with bus 418 by one or more data media interfaces.Memory 428 may include at least one program production
There is one group of (for example, at least one) program module, these program modules to be configured to perform of the invention each for product, the program product
The function of embodiment.
Program/utility 440 with one group of (at least one) program module 442, can be stored in such as memory
In 428, such program module 442 includes but not limited to operating system, one or more application program, other program modules
And program data, the realization of network environment may be included in each or certain combination in these examples.Program module 442
Usually execute the function and/or method in embodiment described in the invention.
Equipment 412 can also be logical with one or more external equipments 414 (such as keyboard, sensing equipment, display 424 etc.)
Letter, can also be enabled a user to one or more equipment interact with the equipment 412 communicate, and/or with make the equipment 412
Any equipment (such as network interface card, modem etc.) communication that can be communicated with one or more of the other computing device.This
Kind communication can be carried out by input/output (I/O) interface 422.Also, equipment 412 can also by network adapter 420 with
One or more network (such as LAN (LAN), wide area network (WAN) and/or public network, such as internet) communication.Such as
Shown in figure, network adapter 420 is communicated by bus 418 with other modules of equipment 412.It should be understood that although not showing in Fig. 4
Go out, other hardware and/or software module can be used with bonding apparatus 412, including but not limited to:It is microcode, device driver, superfluous
Remaining processing unit, external disk drive array, RAID system, tape drive and data backup storage system etc..
Processor 416 is stored in program in system storage 428 by operation, to perform various functions application and
Data processing, such as realize a kind of internal-memory detection method that the embodiment of the present invention is provided, including:
Memory access request is obtained, memory access request includes internal storage access address;
If internal storage access address is legal address, corresponding internal storage access region is obtained according to internal storage access address,
Internal storage access region includes stack internal storage access region;
Stack internal storage access region is accessed according to memory access request, and searches and is located at function defined in stack internal storage access region
Whether the detection variable and default detection variable before and after internal local variable in region are consistent, if it is inconsistent, determining memory
It is abnormal.
Embodiment five
The embodiment of the present invention five additionally provides a kind of computer readable storage medium, is stored thereon with computer program, should
Realize that a kind of internal-memory detection method provided such as the embodiment of the present invention, this method include when program is executed by processor:
Memory access request is obtained, memory access request includes internal storage access address;
If internal storage access address is legal address, corresponding internal storage access region is obtained according to internal storage access address,
Internal storage access region includes stack internal storage access region;
Stack internal storage access region is accessed according to memory access request, and searches and is located at function defined in stack internal storage access region
Whether the detection variable and default detection variable before and after internal local variable in region are consistent, if it is inconsistent, determining memory
It is abnormal.
The arbitrary of one or more computer-readable media may be used in the computer storage media of the embodiment of the present invention
Combination.Computer-readable medium can be computer-readable signal media or computer readable storage medium.It is computer-readable
Storage medium for example may be-but not limited to-the system of electricity, magnetic, optical, electromagnetic, infrared ray or semiconductor, device or
Device, or the arbitrary above combination.The more specific example (non exhaustive list) of computer readable storage medium includes:Tool
There are one or the electrical connection of multiple conducting wires, portable computer diskette, hard disk, random access memory (RAM), read-only memory
(ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-
ROM), light storage device, magnetic memory device or above-mentioned any appropriate combination.In this document, computer-readable storage
Medium, which can be any, includes or the tangible medium of storage program, which can be commanded execution system, device or device
Using or it is in connection.
Computer-readable signal media may include in a base band or as the data-signal that a carrier wave part is propagated,
Wherein carry computer-readable program code.Diversified forms may be used in the data-signal of this propagation, including but unlimited
In electromagnetic signal, optical signal or above-mentioned any appropriate combination.Computer-readable signal media can also be that computer can
Any computer-readable medium other than storage medium is read, which can send, propagates or transmit and be used for
By instruction execution system, device either device use or program in connection.
The program code for including on computer-readable medium can transmit with any suitable medium, including --- but it is unlimited
In wireless, electric wire, optical cable, RF etc. or above-mentioned any appropriate combination.
It can be write with one or more programming languages or combinations thereof for executing the computer that operates of the present invention
Program code, described program design language include object oriented program language-such as Java, Smalltalk, C++,
Ruby, Go further include conventional procedural programming language-such as " C " language or similar programming language.Program
Code can be executed fully, partly be executed on the user computer, as an independent software on the user computer
Packet executes, part executes or on the remote computer completely in remote computer or server on the user computer for part
Upper execution.In situations involving remote computers, remote computer can pass through the network of any kind --- including local
Net (LAN) or wide area network (WAN)-are connected to subscriber computer, or, it may be connected to outer computer (such as using because of spy
Service provider is netted to be connected by internet).
Note that above are only presently preferred embodiments of the present invention and institute's application technology principle.It will be appreciated by those skilled in the art that
The present invention is not limited to specific embodiments described here, can carry out for a person skilled in the art it is various it is apparent variation,
It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out to the present invention by above example
It is described in further detail, but the present invention is not limited only to above example, without departing from the inventive concept, also
May include other more equivalent embodiments, and the scope of the present invention is determined by scope of the appended claims.
Claims (10)
1. a kind of internal-memory detection method, which is characterized in that including:
Memory access request is obtained, the memory access request includes internal storage access address;
If the internal storage access address is legal address, corresponding internal storage access area is obtained according to the internal storage access address
Domain, the internal storage access region include stack internal storage access region;
Stack internal storage access region is accessed according to the memory access request, and searches and is located in stack internal storage access region
Whether the detection variable and default detection variable inside defined function before and after local variable in region are consistent, if it is inconsistent,
Determine memory abnormal.
2. according to the method described in claim 1, it is characterized in that, the internal storage access region further includes heap memory access region
Domain further includes:
The heap memory access region is accessed according to the memory access request, and calculates the schools CRC that access operation generates data
Test code;
If the cyclic redundancy check and default cyclic redundancy check are inconsistent, it is determined that memory abnormal.
3. according to the method described in claim 1, it is characterized in that, accessing the stack memory according to the memory access request
Before access region, further include:
It searches beacon information in the area of isolation in the internal storage access region and whether default beacon information is consistent, if differed
It causes, then determines memory abnormal.
4. according to the method described in claim 1, it is characterized in that, the internal storage access address be legal address, including:
Obtain the use information of current memory;
Addressable memory address library is established according to the use information;
The internal storage access address is matched with the record in the memory address library, if successful match, it is determined that institute
It is legal address to state internal storage access address.
5. according to the method described in claim 1, being visited it is characterized in that, accessing the stack memory according to the memory access request
Ask region, including:
According to the memory access request, stack internal storage access region is accessed by safe interface.
6. according to the method described in claim 2, accessing the heap memory access region, packet according to the memory access request
It includes:
According to the memory access request, the heap memory access region is accessed by safe interface.
7. a kind of memory detection device, which is characterized in that including:
Memory access request acquisition module, for obtaining memory access request, the memory access request includes internal storage access
Location;
Internal storage access region acquisition module is visited if being legal address for the internal storage access address according to the memory
Ask that address obtains corresponding internal storage access region, the internal storage access region includes stack internal storage access region;
The first determining module of memory abnormal for accessing stack internal storage access region according to the memory access request, and is looked into
Look for the detection variable in region before and after local variable inside function defined in stack internal storage access region and default detection
Whether variable is consistent, if it is inconsistent, determining memory abnormal.
8. device according to claim 7, which is characterized in that the internal storage access region further includes heap memory access region
Domain further includes:
Cyclic redundancy check acquisition module for accessing the heap memory access region according to the memory access request, and calculates visit
Ask that operation generates the cyclic redundancy check of data;
The second determining module of memory abnormal, if inconsistent for the cyclic redundancy check and default cyclic redundancy check, it is determined that interior
Deposit exception.
9. a kind of equipment, which is characterized in that including:
One or more processors;
Memory, for storing one or more programs;
When one or more of programs are executed by one or more of processors so that one or more of processors are real
The now internal-memory detection method as described in any in claim 1-6.
10. a kind of computer readable storage medium, is stored thereon with computer program, which is characterized in that the program is by processor
The internal-memory detection method as described in any in claim 1-6 is realized when execution.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810210345.8A CN108388517A (en) | 2018-03-14 | 2018-03-14 | A kind of internal-memory detection method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810210345.8A CN108388517A (en) | 2018-03-14 | 2018-03-14 | A kind of internal-memory detection method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108388517A true CN108388517A (en) | 2018-08-10 |
Family
ID=63067375
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810210345.8A Pending CN108388517A (en) | 2018-03-14 | 2018-03-14 | A kind of internal-memory detection method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108388517A (en) |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109446755A (en) * | 2018-09-30 | 2019-03-08 | 龙芯中科技术有限公司 | The guard method of kernel hooking function, device, equipment and storage medium |
CN110674050A (en) * | 2019-10-08 | 2020-01-10 | 腾讯科技(深圳)有限公司 | Memory out-of-range detection method and device, electronic equipment and computer storage medium |
CN110764914A (en) * | 2019-10-28 | 2020-02-07 | 锐捷网络股份有限公司 | Memory rewriting positioning method and device |
CN110825575A (en) * | 2019-11-13 | 2020-02-21 | 重庆秦嵩科技有限公司 | Memory detection method |
CN110928204A (en) * | 2019-11-27 | 2020-03-27 | 深圳拓邦股份有限公司 | Control method of cleaning equipment and cleaning equipment |
CN111104347A (en) * | 2019-12-23 | 2020-05-05 | 北京东土军悦科技有限公司 | Heap memory block searching method, device, equipment and storage medium |
CN111177726A (en) * | 2019-08-29 | 2020-05-19 | 腾讯科技(深圳)有限公司 | System vulnerability detection method, device, equipment and medium |
CN117093472A (en) * | 2023-07-12 | 2023-11-21 | 荣耀终端有限公司 | Memory operation processing method, equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101694686A (en) * | 2009-09-21 | 2010-04-14 | 北京工业大学 | Dynamic measuring method of buffer overflow on the basis of logic isolation |
CN103678028A (en) * | 2013-12-16 | 2014-03-26 | 重庆川仪自动化股份有限公司 | RAM internal storage detection method and device |
CN105183542A (en) * | 2015-08-13 | 2015-12-23 | 上海斐讯数据通信技术有限公司 | Memory management method and system |
US20160092673A1 (en) * | 2014-09-26 | 2016-03-31 | Michael LeMay | Hardware shadow stack support for legacy guests |
CN106502926A (en) * | 2016-09-26 | 2017-03-15 | 华为技术有限公司 | A kind of internal memory monitoring method, internal storage access controller and SoC systems |
CN106682492A (en) * | 2015-11-06 | 2017-05-17 | 大唐移动通信设备有限公司 | Method and device for managing heap corruption |
CN107045605A (en) * | 2016-02-05 | 2017-08-15 | 中兴通讯股份有限公司 | A kind of real-time metrics method and device |
CN107516546A (en) * | 2017-07-07 | 2017-12-26 | 中国航空工业集团公司西安飞行自动控制研究所 | The on-line measuring device and method of a kind of random access memory |
-
2018
- 2018-03-14 CN CN201810210345.8A patent/CN108388517A/en active Pending
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101694686A (en) * | 2009-09-21 | 2010-04-14 | 北京工业大学 | Dynamic measuring method of buffer overflow on the basis of logic isolation |
CN103678028A (en) * | 2013-12-16 | 2014-03-26 | 重庆川仪自动化股份有限公司 | RAM internal storage detection method and device |
US20160092673A1 (en) * | 2014-09-26 | 2016-03-31 | Michael LeMay | Hardware shadow stack support for legacy guests |
CN105183542A (en) * | 2015-08-13 | 2015-12-23 | 上海斐讯数据通信技术有限公司 | Memory management method and system |
CN106682492A (en) * | 2015-11-06 | 2017-05-17 | 大唐移动通信设备有限公司 | Method and device for managing heap corruption |
CN107045605A (en) * | 2016-02-05 | 2017-08-15 | 中兴通讯股份有限公司 | A kind of real-time metrics method and device |
CN106502926A (en) * | 2016-09-26 | 2017-03-15 | 华为技术有限公司 | A kind of internal memory monitoring method, internal storage access controller and SoC systems |
CN107516546A (en) * | 2017-07-07 | 2017-12-26 | 中国航空工业集团公司西安飞行自动控制研究所 | The on-line measuring device and method of a kind of random access memory |
Non-Patent Citations (2)
Title |
---|
JAMES O. COPLIEN: "《Advanced C++中文版》", 29 February 2004, 中国电力出版社 * |
李文明: ""C程序内存安全性的运行时验证研究与实现"", 《中国优秀硕士学位论文全文数据库 信息科技辑》 * |
Cited By (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109446755B (en) * | 2018-09-30 | 2021-03-30 | 龙芯中科技术股份有限公司 | Kernel hook function protection method, device, equipment and storage medium |
CN109446755A (en) * | 2018-09-30 | 2019-03-08 | 龙芯中科技术有限公司 | The guard method of kernel hooking function, device, equipment and storage medium |
CN111177726B (en) * | 2019-08-29 | 2024-02-06 | 腾讯科技(深圳)有限公司 | System vulnerability detection method, device, equipment and medium |
CN111177726A (en) * | 2019-08-29 | 2020-05-19 | 腾讯科技(深圳)有限公司 | System vulnerability detection method, device, equipment and medium |
CN110674050A (en) * | 2019-10-08 | 2020-01-10 | 腾讯科技(深圳)有限公司 | Memory out-of-range detection method and device, electronic equipment and computer storage medium |
CN110674050B (en) * | 2019-10-08 | 2022-04-19 | 腾讯科技(深圳)有限公司 | Memory out-of-range detection method and device, electronic equipment and computer storage medium |
CN110764914A (en) * | 2019-10-28 | 2020-02-07 | 锐捷网络股份有限公司 | Memory rewriting positioning method and device |
CN110825575A (en) * | 2019-11-13 | 2020-02-21 | 重庆秦嵩科技有限公司 | Memory detection method |
CN110825575B (en) * | 2019-11-13 | 2023-04-04 | 重庆秦嵩科技有限公司 | Memory detection method |
CN110928204B (en) * | 2019-11-27 | 2022-11-22 | 深圳拓邦股份有限公司 | Control method of cleaning equipment and cleaning equipment |
CN110928204A (en) * | 2019-11-27 | 2020-03-27 | 深圳拓邦股份有限公司 | Control method of cleaning equipment and cleaning equipment |
CN111104347A (en) * | 2019-12-23 | 2020-05-05 | 北京东土军悦科技有限公司 | Heap memory block searching method, device, equipment and storage medium |
CN117093472A (en) * | 2023-07-12 | 2023-11-21 | 荣耀终端有限公司 | Memory operation processing method, equipment and storage medium |
CN117093472B (en) * | 2023-07-12 | 2024-08-02 | 荣耀终端有限公司 | Memory operation processing method, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108388517A (en) | A kind of internal-memory detection method, device, equipment and storage medium | |
CN109726136A (en) | Test method, device, equipment and the storage medium of database | |
CN110427735A (en) | A kind of method of calibration, device, server and storage medium | |
CN110502357A (en) | A kind of stack retrogressive method, device, medium and equipment | |
US11232020B2 (en) | Fault detection using breakpoint value-based fingerprints of failing regression test cases | |
US7434020B2 (en) | Overwrite detection diagnostic for memory heap | |
CN110515647A (en) | A kind of static resource management method, device, equipment and storage medium | |
CN107944278A (en) | A kind of kernel leak detection method and device | |
CN107678833A (en) | Simulator detection method and device based on operation system information | |
CN107102950A (en) | A kind of applied program testing method and device | |
CN109086176A (en) | A kind of SSD steady-state method of test, device, equipment and storage medium based on FIO | |
CN107798064A (en) | Page processing method, electronic equipment and computer-readable recording medium | |
CN110210220B (en) | Information leakage detection method and device and storage medium | |
CN109033804A (en) | A kind of software virtual machine authorization method and device | |
US7350045B2 (en) | Dynamic memory heap tagging | |
CN109446078A (en) | Code test method and device, storage medium, electronic equipment | |
CN110489164B (en) | Acquisition method, device, medium and equipment of hidden assertion information | |
CN113032543B (en) | Dialogue diagnosis method, device, equipment and medium based on stack structure | |
CN116881173A (en) | Interface parameter detection method, device, electronic equipment and computer readable medium | |
CN109669875A (en) | Application crash test method and device, electronic equipment and storage medium | |
CN112052040A (en) | Processing method, processing device, computer equipment and storage medium | |
CN113010409B (en) | Intelligent contract testing method and device, electronic equipment and storage medium | |
CN108415849A (en) | Method and apparatus for test application | |
CN108197041A (en) | A kind of method, equipment and its storage medium of the parent process of determining subprocess | |
CN114428700A (en) | Memory self-checking method and device |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180810 |
|
RJ01 | Rejection of invention patent application after publication |