CN102214147A - Method and device for detecting transborder memory access - Google Patents

Method and device for detecting transborder memory access Download PDF

Info

Publication number
CN102214147A
CN102214147A CN201110179665XA CN201110179665A CN102214147A CN 102214147 A CN102214147 A CN 102214147A CN 201110179665X A CN201110179665X A CN 201110179665XA CN 201110179665 A CN201110179665 A CN 201110179665A CN 102214147 A CN102214147 A CN 102214147A
Authority
CN
China
Prior art keywords
memory
memory block
field
afterbody
correspondence
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
CN201110179665XA
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.)
Shenzhen Wuju Technology Co Ltd
Original Assignee
Shenzhen Wuju 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 Shenzhen Wuju Technology Co Ltd filed Critical Shenzhen Wuju Technology Co Ltd
Priority to CN201110179665XA priority Critical patent/CN102214147A/en
Publication of CN102214147A publication Critical patent/CN102214147A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention belongs to the technical field of embedded systems and in particular relates to a method and a device for detecting a transborder memory access. The method for detecting the transborder memory access comprises the following steps of: a, during memory block application, adding a detection field having a fixed length on the tail part of an applied memory block; b, during memory block operation, gradually detecting the detection field on the tail part of each memory block one by one, judging whether a value of the detection field on the tail part of the memory block is equal to an initially set value, and if the value of the detection field on the tail part of the memory block is not equal to the initially set value, performing step c; and c, indicating a transborder memory access phenomenon existing in the memory block corresponding to the detection field on the tail part. By the method and the device for detecting the transborder memory access, improper transborder memory operation in the embedded system can be found out immediately, and targeted maintenance operation can be performed on the embedded system; therefore, the protection intensity of the system memory data is enhanced, and the using efficiency of finite memories in the embedded system is improved.

Description

A kind of method and device that detects memory accessing outside
Technical field
The invention belongs to the embedded system technology field, relate in particular to a kind of method and device that detects memory accessing outside.
Background technology
In the present embedded real time system, application program is quite high to the frequency of utilization of internal memory, especially need to apply for continually and releasing memory, but because the resource of embedded system is more limited, thereby effectively use internal memory to seem particularly important, how to utilize the limited maximum service efficiency of internal memory performance, become the key to the issue that embedded system further develops.
In actual application, can be a kind of common illegal internal memory operation such as " memory accessing outside " because inappropriate internal memory operation hinders the use of internal memory usually.Under a lot of situations,, can cause the problem of memory accessing outside, for example, exceed the address realm of the memory block of applying for when writing data, cover other region of memorys, just may cause the situation of memory accessing outside owing to the carelessness that program code is write.Because memory accessing outside may cover the data of active program, even overlay program code, thereby very likely be corrupted to other data of using in the program, also may impact in the time of serious other programs moved or total system, if operating system lacks protection, even might make the total system collapse; Simultaneously, because memory accessing outside influences the visit of other data, can reduce the service efficiency of limited memory in the embedded system.
Summary of the invention
The invention provides a kind of method and device that detects memory accessing outside, be intended to solve in the prior art because memory accessing outside impacts program and system moves, the problem of reduction internal memory service efficiency.
The present invention is achieved in that a kind of method that detects memory accessing outside, comprising:
Step a: the detected field of adding regular length during the application memory block at the afterbody of application memory block;
Step b: when carrying out the memory block operation, detect the afterbody detected field of each memory block one by one, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal; If the numerical value of afterbody detected field is not the initial setting up value, execution in step c;
Step c: point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside.
Technical scheme of the present invention also comprises: in described step a, the numerical value default setting of described detected field is easy detected numerical value.
Technical scheme of the present invention also comprises: described step a also comprises, the length allocation of application memory block is added the afterbody detected field length of this memory block correspondence for the initial application length of this memory block.
Technical scheme of the present invention also comprises: described step a also comprises, the memory block of distributing is inserted in the internal memory chained list, and return the initial address of each memory block correspondence.
Technical scheme of the present invention also comprises: described step a also comprises, adds the head detection field of regular length at the head of application memory block, and be easy detected numerical value with the numerical value default setting of this head detection field.
Technical scheme of the present invention also comprises: described step a also comprises, the length allocation of application memory block is added the head detection field length and the afterbody detected field length of this memory block correspondence for the initial application length of this memory block.
Technical scheme of the present invention also comprises: also comprise behind the described step c, detect the head detection field of each memory block one by one, and whether the numerical value of judging the head detection field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of head detection field is not the initial setting up value, point out the memory block write operation of this head detection field correspondence normal, and continue to judge the head detection field of next memory block; If the numerical value of head detection field is the initial setting up value, point out the memory block write operation of this head detection field correspondence improper.
Another technical scheme of the present invention: a kind of device that detects memory accessing outside, comprise internal memory application module, module is returned in the address, the memory setting module, the first internal memory judge module and condition prompting module, described internal memory application module is used to the program application memory block that needs use, described address return module be used for will distribute memory block insert the internal memory chained list, and return the initial address of each memory block correspondence, described memory setting module is used for adding at the afterbody of application memory block the detected field of regular length, the described first internal memory judge module is used for detecting one by one the afterbody detected field of each memory block, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal by the condition prompting module; If the numerical value of afterbody detected field is not the initial setting up value, point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside by the condition prompting module; Described condition prompting module is used for carrying out corresponding internal storage state prompting according to the judged result of the first internal memory judge module.
Technical scheme of the present invention also comprises: also comprise the second internal memory judge module and operation indicating module, the described second internal memory judge module is used for detecting one by one the head detection field of each memory block, and whether the numerical value of judging the head detection field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of head detection field is not the initial setting up value, point out the memory block write operation of this head detection field correspondence normal by the operation indicating module; If the numerical value of head detection field is the initial setting up value, point out the memory block write operation of this head detection field correspondence improper by the operation indicating module; Described operation indicating module is used for carrying out corresponding prompt according to the judged result of the second internal memory judge module.
Technical scheme of the present invention also comprises: also comprise memory allocating module, described memory allocating module is used for the length allocation of application memory block is added that for the initial application length of this memory block the afterbody detected field length of this memory block correspondence is or/and the head detection field length.
Technical scheme of the present invention has following advantage or beneficial effect: method and device that the present invention detects memory accessing outside pass through when application storage allocation piece; automatically head and the afterbody at the memory block that distributes adds the detected field that initial default value is set; when memory block is carried out corresponding operating; respectively afterbody and head detection field are detected; thereby fast and effeciently detect the phenomenon of memory accessing outside; and further detect the reason that causes the memory accessing outside phenomenon; make that inappropriate memory overwriting operation can in time be found and carry out attended operation pointedly in the embedded system; thereby strengthen Installed System Memory Data Protection intensity is improved the service efficiency of limited memory in the embedded system.
Description of drawings
Accompanying drawing 1 is the process flow diagram of method of the detection memory accessing outside of first embodiment of the invention;
Accompanying drawing 2 is process flow diagrams of method of the detection memory accessing outside of second embodiment of the invention;
Accompanying drawing 3 is process flow diagrams of method of the detection memory accessing outside of third embodiment of the invention;
Accompanying drawing 4 is structural representations of device of the detection memory accessing outside of first embodiment of the invention;
Accompanying drawing 5 is structural representations of device of the detection memory accessing outside of second embodiment of the invention;
Accompanying drawing 6 is structural representations of device of the detection memory accessing outside of third embodiment of the invention.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
Seeing also Fig. 1, is the process flow diagram of method of the detection memory accessing outside of first embodiment of the invention.The method of the detection memory accessing outside of first embodiment of the invention may further comprise the steps:
Step 100: the detected field of adding regular length during the application memory block at the afterbody of application memory block;
In this step, for the ease of detecting, the numerical value default setting of this detected field is easy detected numerical value; Each numerical value that can detected field is set to same value, is that 4bit is an example with the length of detected field, and detected field that can this 4 bit field is set to FFFF or 1111; Wherein, detected field that can all memory blocks is set to unified value, also the detected field of each memory block can be distinguished setting.
Step 110: when carrying out the memory block operation, detect the afterbody detected field of each memory block one by one, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence be the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, and execution in step 120; If the numerical value of afterbody detected field is not the initial setting up value, execution in step 130;
In this step, concrete detection method is: for guaranteeing the robustness of daily code, can internal memory application and release be arranged or internally deposit into the detection of carrying out memory overwriting in his interface operable of Xingqi at any one, be about to detection function and be inserted into malloc, free, in the internal memory application of respective classes such as memcpy or the release function, when each invoke memory application or release function, whether the afterbody detected field that detects memory block in the internal memory chained list is the initial setting up value, because the singularity of the initial setting up value of detected field, and because the initial application length of memory block practical application meeting surplus to some extent relatively usually, if thereby the numerical value that detects the afterbody detected field is when being not the initial setting up value, just very likely there is the phenomenon of memory accessing outside in the memory block corresponding with this detected field, if when detecting the numerical value of afterbody detected field and being the initial setting up value, illustrate that then the memory block internal storage access of this detected field correspondence is normal.Wherein, when the detected field of setting was long more, the reliability of detection was high more, if but oversize meeting causes the phenomenon of internal memory waste, and in embodiment of the present invention, when the length of detected field is set to 4bit preferred plan.
Step 120: point out the memory block internal storage access of this afterbody detected field correspondence normal;
Step 130: point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside.
See also Fig. 2, be second embodiment of the invention the process flow diagram of method of detection memory accessing outside.The method of the detection memory accessing outside of second embodiment of the invention may further comprise the steps:
Step 200: be the program application memory block of needs use;
Step 210: add the detected field of regular length at the afterbody of application memory block, and be easy detected numerical value with the numerical value default setting of this detected field;
In this step, for the ease of detecting, each numerical value that can detected field is set to same value, is that 4bit is an example with the length of detected field, and detected field that can this 4 bit field is set to FFFF or 1111; Wherein, detected field that can all memory blocks is set to unified value, also the detected field of each memory block can be distinguished setting.
Step 220: the afterbody detected field length that the length allocation of application memory block is added this memory block correspondence for the initial application length of this memory block;
In this step, suppose that the initial application length of memory block is M, the detected field length of being added is N, and the length of this application memory block then is assigned as M+N automatically so.
Step 230: the memory block of distributing is inserted in the internal memory chained list, and return the initial address of each memory block correspondence;
Wherein, the initial address that returns is the initial address of the memory block of actual allocated, promptly initially applies for the initial address of the memory block of length (M).
Step 240: when carrying out the memory block operation, detect the afterbody detected field of each memory block one by one, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence be the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, and execution in step 250; If the numerical value of afterbody detected field is not the initial setting up value, execution in step 260;
In this step, concrete detection method is: for guaranteeing the robustness of daily code, can internal memory application and release be arranged or internally deposit into the detection of carrying out memory overwriting in his interface operable of Xingqi at any one, be about to detection function and be inserted into malloc, free, in the internal memory application of respective classes such as memcpy or the release function, when each invoke memory application or release function, whether the afterbody detected field that detects memory block in the internal memory chained list is the initial setting up value, because the singularity of the initial setting up value of detected field, and because the initial application length of memory block practical application meeting surplus to some extent relatively usually, if thereby the numerical value that detects the afterbody detected field is when being not the initial setting up value, just very likely there is the phenomenon of memory accessing outside in the memory block corresponding with this detected field, if when detecting the numerical value of afterbody detected field and being the initial setting up value, illustrate that then the memory block internal storage access of this detected field correspondence is normal.Wherein, when the detected field of setting was long more, the reliability of detection was high more, if but oversize meeting causes the phenomenon of internal memory waste, and in embodiment of the present invention, when the length of detected field is set to 4bit preferred plan.
Step 250: point out the memory block internal storage access of this afterbody detected field correspondence normal, and execution in step 240 again;
Step 260: point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside;
Step 270: finish this detection.
See also Fig. 3, be third embodiment of the invention the process flow diagram of method of detection memory accessing outside.The method of the detection memory accessing outside of third embodiment of the invention may further comprise the steps:
Step 300: be the program application memory block of needs use;
Step 310: the head detection field and the afterbody detected field of adding regular length respectively at the head and the afterbody of application memory block, and be detected numerical value easily with the numerical value default setting of this detected field;
In this step, for the ease of detecting, each numerical value that can detected field is set to same value, is that 4bit is an example with the length of detected field, and detected field that can this 4 bit field is set to FFFF or 1111; Wherein, detected field that can all memory blocks is set to unified value, also the head detection field and the afterbody detected field of each memory block can be distinguished setting.
Step 320: the head detection field length and the afterbody detected field length that the length allocation of application memory block are added this memory block correspondence for the initial application length of this memory block;
In this step, suppose that the initial application length of memory block is M, the head detection field length of being added is N1, and the afterbody detected field length of being added is N2, and the length of this application memory block then is assigned as M+N1+N2 automatically so.
Step 330: the memory block of distributing is inserted in the internal memory chained list, and return the initial address of each corresponding memory block correspondence;
Wherein, the initial address that returns is the address after the initial address (M) of the memory block of actual allocated adds head detection field length (N1).
Step 340: when carrying out the memory block operation, detect the afterbody detected field of each memory block one by one, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence be the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, and execution in step 350; If the numerical value of afterbody detected field is not the initial setting up value, execution in step 360;
In this step, concrete detection method is: for guaranteeing the robustness of daily code, can internal memory application and release be arranged or internally deposit into the detection of carrying out memory overwriting in his interface operable of Xingqi at any one, be about to detection function and be inserted into malloc, free, in the internal memory application of respective classes such as memcpy or the release function, when each invoke memory application or release function, whether the afterbody detected field that detects memory block in the internal memory chained list is the initial setting up value, because the singularity of the initial setting up value of detected field, and because the initial application length of memory block practical application meeting surplus to some extent relatively usually, if thereby the numerical value that detects the afterbody detected field is when being not the initial setting up value, just very likely there is the phenomenon of memory accessing outside in the memory block corresponding with this detected field, if when detecting the numerical value of afterbody detected field and being the initial setting up value, illustrate that then the memory block internal storage access of this detected field correspondence is normal.Wherein, when the detected field of setting was long more, the reliability of detection was high more, if but oversize meeting causes the phenomenon of internal memory waste, and in embodiment of the present invention, when the length of detected field is set to 4bit preferred plan.
Step 350: point out the memory block internal storage access of this afterbody detected field correspondence normal, and re-execute the step 340;
Step 360: point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside;
Step 370: detect the head detection field of each memory block one by one, and judge whether the numerical value of the head detection field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of head detection field is not the initial setting up value, execution in step 380; If the numerical value of head detection field is the initial setting up value, execution in step 390;
In this step, for example: the afterbody detected field and the initial setting up value that detect memory block 3 are inequality, can judge that the memory accessing outside phenomenon has taken place this memory block 3, but can not learn it specifically is this moment because improper " crossing the border " phenomenon that causes of write operation of which memory block, can further detect the head detection field of memory block 3 this moment, if the head detection field of memory block 3 does not note abnormalities, can conclude that this phenomenon of " crossing the border " is owing to causing the write operation of memory block 3 is improper, and it is different if detect the head detection field of memory block 3 with the initial setting up value, can conclude that then this phenomenon of " crossing the border " is owing to improper the causing of write operation to memory block 2 or memory block 1 at least, in like manner, by successively to the afterbody of memory block 2, the head detection field, and the afterbody of memory block 1, the head detection field detects, thereby further detect the cause that this phenomenon of " crossing the border " takes place, thereby can carry out attended operation targetedly.
Step 380: point out the memory block write operation of this head detection field correspondence normal, and execution in step 370 again;
Step 390: point out the memory block write operation of this head detection field correspondence improper;
Step 400: finish this detection.
See also Fig. 4, be first embodiment of the invention the structural representation of device of detection memory accessing outside.First embodiment of the invention the device of detection memory accessing outside comprise that internal memory application module, address return module, memory setting module, the first internal memory judge module and condition prompting module, wherein,
Internal memory application module is used to the program application memory block that needs use;
The address return module be used for will distribute memory block insert the internal memory chained list, and return the initial address of each memory block correspondence;
The memory setting module is used for adding at the afterbody of application memory block the detected field of regular length; Wherein, for the ease of detecting, each numerical value that can detected field is set to same value, is that 4bit is an example with the length of detected field, and detected field that can this 4 bit field is set to FFFF or 1111; In addition, detected field that can all memory blocks is set to unified value, also the detected field of each memory block can be distinguished setting.
The first internal memory judge module is used for detecting one by one the afterbody detected field of each memory block, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal by the condition prompting module; If the numerical value of afterbody detected field is not the initial setting up value, point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside by the condition prompting module; Wherein, concrete detection method is: for guaranteeing the robustness of daily code, can internal memory application and release be arranged or internally deposit into the detection of carrying out memory overwriting in his interface operable of Xingqi at any one, be about to detection function and be inserted into malloc, free, in the internal memory application of respective classes such as memcpy or the release function, when each invoke memory application or release function, whether the afterbody detected field that detects memory block in the internal memory chained list is the initial setting up value, because the singularity of the initial setting up value of detected field, and because the initial application length of memory block practical application meeting surplus to some extent relatively usually, if thereby the numerical value that detects the afterbody detected field is when being not the initial setting up value, just very likely there is the phenomenon of memory accessing outside in the memory block corresponding with this detected field, if when detecting the numerical value of afterbody detected field and being the initial setting up value, illustrate that then the memory block internal storage access of this detected field correspondence is normal.Wherein, when the detected field of setting was long more, the reliability of detection was high more, if but oversize meeting causes the phenomenon of internal memory waste, and in embodiment of the present invention, when the length of detected field is set to 4bit preferred plan.
The condition prompting module is used for carrying out corresponding internal storage state prompting according to the judged result of the first internal memory judge module.
See also Fig. 5, be second embodiment of the invention the structural representation of device of detection memory accessing outside.Second embodiment of the invention the device of detection memory accessing outside comprise that internal memory application module, memory setting module, memory allocating module, address return module, the first internal memory judge module and condition prompting module, wherein
Internal memory application module is used to the program application memory block that needs use;
The memory setting module is used for adding at the afterbody of application memory block the detected field of regular length, and be easy detected numerical value with the numerical value default setting of this detected field; Wherein, for the ease of detecting, each numerical value that can detected field is set to same value, is that 4bit is an example with the length of detected field, and detected field that can this 4 bit field is set to FFFF or 1111; In addition, detected field that can all memory blocks is set to unified value, also the detected field of each memory block can be distinguished setting.
Memory allocating module is used for the length allocation of application memory block is added for the initial application length of this memory block the afterbody detected field length of this memory block correspondence; Wherein, suppose that the initial application length of memory block is M, the detected field length of being added is N, and the length of this application memory block then is assigned as M+N automatically so.
The address return module be used for will distribute memory block insert the internal memory chained list, and return the initial address of each memory block correspondence; Wherein, the initial address that returns is the initial address of the memory block of actual allocated, promptly initially applies for the initial address of the memory block of length (M).
The first internal memory judge module is used for detecting one by one the afterbody detected field of each memory block, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal by the condition prompting module; If the numerical value of afterbody detected field is not the initial setting up value, point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside by the condition prompting module;
Wherein, concrete detection method is: for guaranteeing the robustness of daily code, can internal memory application and release be arranged or internally deposit into the detection of carrying out memory overwriting in his interface operable of Xingqi at any one, be about to detection function and be inserted into malloc, free, in the internal memory application of respective classes such as memcpy or the release function, when each invoke memory application or release function, whether the afterbody detected field that detects memory block in the internal memory chained list is the initial setting up value, because the singularity of the initial setting up value of detected field, and because the initial application length of memory block practical application meeting surplus to some extent relatively usually, if thereby the numerical value that detects the afterbody detected field is when being not the initial setting up value, just very likely there is the phenomenon of memory accessing outside in the memory block corresponding with this detected field, if when detecting the numerical value of afterbody detected field and being the initial setting up value, illustrate that then the memory block internal storage access of this detected field correspondence is normal.Wherein, when the detected field of setting was long more, the reliability of detection was high more, if but oversize meeting causes the phenomenon of internal memory waste, and in embodiment of the present invention, when the length of detected field is set to 4bit preferred plan.
The condition prompting module is used for carrying out corresponding internal storage state prompting according to the judged result of the first internal memory judge module.
See also Fig. 6, be third embodiment of the invention the structural representation of device of detection memory accessing outside.Third embodiment of the invention the device of detection memory accessing outside comprise that internal memory application module, memory setting module, memory allocating module, address return module, the first internal memory judge module, condition prompting module, the second internal memory judge module and operation indicating module, wherein
Internal memory application module is used to the program application memory block that needs use;
The memory setting module is used for adding respectively at the head of application memory block and afterbody the head detection field and the afterbody detected field of regular length, and is detected numerical value easily with the numerical value default setting of this detected field; Wherein, for the ease of detecting, each numerical value that can detected field is set to same value, is that 4bit is an example with the length of detected field, and detected field that can this 4 bit field is set to FFFF or 1111; In addition, detected field that can all memory blocks is set to unified value, also the head detection field and the afterbody detected field of each memory block can be distinguished setting.
Memory allocating module is used for the length allocation of application memory block is added for the initial application length of this memory block the head detection field length and the afterbody detected field length of this memory block correspondence; Wherein, suppose that the initial application length of memory block is M, the head detection field length of being added is N1, and the afterbody detected field length of being added is N2, and the length of this application memory block then is assigned as M+N1+N2 automatically so.
The address return module be used for will distribute memory block insert the internal memory chained list, and return the initial address of each memory block correspondence; Wherein, the initial address that returns is the address after the initial address (M) of the memory block of actual allocated adds head detection field length (N1).
The first internal memory judge module is used for detecting one by one the afterbody detected field of each memory block, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal by the condition prompting module; If the numerical value of afterbody detected field is not the initial setting up value, point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside by the condition prompting module;
Wherein, concrete detection method is: for guaranteeing the robustness of daily code, can internal memory application and release be arranged or internally deposit into the detection of carrying out memory overwriting in his interface operable of Xingqi at any one, be about to detection function and be inserted into malloc, free, in the internal memory application of respective classes such as memcpy or the release function, when each invoke memory application or release function, whether the afterbody detected field that detects memory block in the internal memory chained list is the initial setting up value, because the singularity of the initial setting up value of detected field, and because the initial application length of memory block practical application meeting surplus to some extent relatively usually, if thereby the numerical value that detects the afterbody detected field is when being not the initial setting up value, just very likely there is the phenomenon of memory accessing outside in the memory block corresponding with this detected field, if when detecting the numerical value of afterbody detected field and being the initial setting up value, illustrate that then the memory block internal storage access of this detected field correspondence is normal.Wherein, when the detected field of setting was long more, the reliability of detection was high more, if but oversize meeting causes the phenomenon of internal memory waste, and in embodiment of the present invention, when the length of detected field is set to 4bit preferred plan.
The condition prompting module is used for carrying out corresponding internal storage state prompting according to the judged result of the first internal memory judge module;
The second internal memory judge module is used for detecting one by one the head detection field of each memory block, and whether the numerical value of judging the head detection field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of head detection field is not the initial setting up value, point out the memory block write operation of this head detection field correspondence normal by the operation indicating module; If the numerical value of head detection field is the initial setting up value, point out the memory block write operation of this head detection field correspondence improper by the operation indicating module;
Wherein, for example: the afterbody detected field and the initial setting up value that detect memory block 3 are inequality, can judge that the memory accessing outside phenomenon has taken place this memory block 3, but can not learn it specifically is this moment because improper " crossing the border " phenomenon that causes of write operation of which memory block, can further detect the head detection field of memory block 3 this moment, if the head detection field of memory block 3 does not note abnormalities, can conclude that this phenomenon of " crossing the border " is owing to causing the write operation of memory block 3 is improper, and it is different if detect the head detection field of memory block 3 with the initial setting up value, can conclude that then this phenomenon of " crossing the border " is owing to improper the causing of write operation to memory block 2 or memory block 1 at least, in like manner, by successively to the afterbody of memory block 2, the head detection field, and the afterbody of memory block 1, the head detection field detects, thereby further detect the cause that this phenomenon of " crossing the border " takes place, thereby can carry out attended operation targetedly.
The operation indicating module is used for carrying out corresponding prompt according to the judged result of the second internal memory judge module.
Method and device that the present invention detects memory accessing outside pass through when application storage allocation piece; automatically head and the afterbody at the memory block that distributes adds the detected field that initial default value is set; when memory block is carried out corresponding operating; call detection function to respectively afterbody and head detection field being detected; thereby fast and effeciently detect the phenomenon of memory accessing outside; and further detect the reason that causes the memory accessing outside phenomenon; make that inappropriate memory overwriting operation can in time be found and carry out attended operation pointedly in the embedded system; thereby strengthen Installed System Memory Data Protection intensity is improved the service efficiency of limited memory in the embedded system.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.

Claims (10)

1. method that detects memory accessing outside comprises:
Step a: the detected field of adding regular length during the application memory block at the afterbody of application memory block;
Step b: when carrying out the memory block operation, detect the afterbody detected field of each memory block one by one, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal; If the numerical value of afterbody detected field is not the initial setting up value, execution in step c;
Step c: point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside.
2. the method for detection memory accessing outside according to claim 1 is characterized in that, in described step a, the numerical value default setting of described detected field is easy detected numerical value.
3. the method for detection memory accessing outside according to claim 1 is characterized in that, described step a also comprises, the length allocation of application memory block is added the afterbody detected field length of this memory block correspondence for the initial application length of this memory block.
4. the method for detection memory accessing outside according to claim 1 is characterized in that, described step a also comprises, the memory block of distributing is inserted in the internal memory chained list, and return the initial address of each memory block correspondence.
5. according to the method for each described detection memory accessing outside of claim 1 to 4, it is characterized in that, described step a also comprises, adds the head detection field of regular length at the head of application memory block, and be easy detected numerical value with the numerical value default setting of this head detection field.
6. the method for detection memory accessing outside according to claim 5, it is characterized in that, described step a also comprises, the length allocation of application memory block is added the head detection field length and the afterbody detected field length of this memory block correspondence for the initial application length of this memory block.
7. the method for detection memory accessing outside according to claim 6, it is characterized in that, also comprise behind the described step c, detect the head detection field of each memory block one by one, and whether the numerical value of judging the head detection field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of head detection field is not the initial setting up value, points out the memory block write operation of this head detection field correspondence normal, and continue to judge the head detection field of next memory block; If the numerical value of head detection field is the initial setting up value, point out the memory block write operation of this head detection field correspondence improper.
8. device that detects memory accessing outside, comprise that internal memory application module and address return module, described internal memory application module is used to the program application memory block that needs use, described address return module be used for will distribute memory block insert the internal memory chained list, and return the initial address of each memory block correspondence, it is characterized in that, also comprise the memory setting module, the first internal memory judge module and condition prompting module, described memory setting module is used for adding at the afterbody of application memory block the detected field of regular length, the described first internal memory judge module is used for detecting one by one the afterbody detected field of each memory block, and whether the numerical value of judging the afterbody detected field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of afterbody detected field is the initial setting up value, point out the memory block internal storage access of this afterbody detected field correspondence normal by the condition prompting module; If the numerical value of afterbody detected field is not the initial setting up value, point out the memory block of this afterbody detected field correspondence to have the phenomenon of memory accessing outside by the condition prompting module; Described condition prompting module is used for carrying out corresponding internal storage state prompting according to the judged result of the first internal memory judge module.
9. the device of detection memory accessing outside according to claim 8, it is characterized in that, also comprise the second internal memory judge module and operation indicating module, the described second internal memory judge module is used for detecting one by one the head detection field of each memory block, and whether the numerical value of judging the head detection field of correspondence memory piece correspondence is the initial setting up value, if the numerical value of head detection field is not the initial setting up value, point out the memory block write operation of this head detection field correspondence normal by the operation indicating module; If the numerical value of head detection field is the initial setting up value, point out the memory block write operation of this head detection field correspondence improper by the operation indicating module; Described operation indicating module is used for carrying out corresponding prompt according to the judged result of the second internal memory judge module.
10. according to Claim 8 or the device of 9 described detection memory accessing outsides, it is characterized in that, also comprise memory allocating module, described memory allocating module is used for the length allocation of application memory block is added that for the initial application length of this memory block the afterbody detected field length of this memory block correspondence is or/and the head detection field length.
CN201110179665XA 2011-06-29 2011-06-29 Method and device for detecting transborder memory access Pending CN102214147A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201110179665XA CN102214147A (en) 2011-06-29 2011-06-29 Method and device for detecting transborder memory access

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201110179665XA CN102214147A (en) 2011-06-29 2011-06-29 Method and device for detecting transborder memory access

Publications (1)

Publication Number Publication Date
CN102214147A true CN102214147A (en) 2011-10-12

Family

ID=44745465

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201110179665XA Pending CN102214147A (en) 2011-06-29 2011-06-29 Method and device for detecting transborder memory access

Country Status (1)

Country Link
CN (1) CN102214147A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657275A (en) * 2015-03-09 2015-05-27 浪潮软件集团有限公司 Memory out-of-range positioning method and device
CN105183542A (en) * 2015-08-13 2015-12-23 上海斐讯数据通信技术有限公司 Memory management method and system
CN106201727A (en) * 2016-07-27 2016-12-07 浪潮(北京)电子信息产业有限公司 The EMS memory management process of a kind of operating system and device
CN106547606A (en) * 2016-10-25 2017-03-29 交控科技股份有限公司 Storehouse self checking method and device
CN110413521A (en) * 2019-07-24 2019-11-05 杭州迪普信息技术有限公司 A kind of the write-overflow detection method and device of heap memory
CN112631821A (en) * 2021-01-28 2021-04-09 长沙景嘉微电子股份有限公司 Memory fault detection positioning method and device, computer equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1286429A (en) * 1999-11-20 2001-03-07 深圳市中兴通讯股份有限公司 Test and monitor method for embedded in processor memory
CN101110042A (en) * 2006-07-20 2008-01-23 中兴通讯股份有限公司 Method for detecting memory accessing outside

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1286429A (en) * 1999-11-20 2001-03-07 深圳市中兴通讯股份有限公司 Test and monitor method for embedded in processor memory
CN101110042A (en) * 2006-07-20 2008-01-23 中兴通讯股份有限公司 Method for detecting memory accessing outside

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104657275A (en) * 2015-03-09 2015-05-27 浪潮软件集团有限公司 Memory out-of-range positioning method and device
CN105183542A (en) * 2015-08-13 2015-12-23 上海斐讯数据通信技术有限公司 Memory management method and system
CN105183542B (en) * 2015-08-13 2019-07-12 上海斐讯数据通信技术有限公司 A kind of EMS memory management process and system
CN106201727A (en) * 2016-07-27 2016-12-07 浪潮(北京)电子信息产业有限公司 The EMS memory management process of a kind of operating system and device
CN106547606A (en) * 2016-10-25 2017-03-29 交控科技股份有限公司 Storehouse self checking method and device
CN106547606B (en) * 2016-10-25 2019-07-02 交控科技股份有限公司 Storehouse self checking method and device
CN110413521A (en) * 2019-07-24 2019-11-05 杭州迪普信息技术有限公司 A kind of the write-overflow detection method and device of heap memory
CN110413521B (en) * 2019-07-24 2023-01-24 杭州迪普信息技术有限公司 Write-crossing detection method and device for heap memory
CN112631821A (en) * 2021-01-28 2021-04-09 长沙景嘉微电子股份有限公司 Memory fault detection positioning method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN102214147A (en) Method and device for detecting transborder memory access
CN101593152B (en) Method and device for detecting memory leakage of mobile terminal
CN100487658C (en) Method for detecting memory accessing outside
CN101859279B (en) Memory allocation and release method and device
CN103955431A (en) Data management method and apparatus in flash memory storage device
CN105302738A (en) Method and device for distributing memory
CN103544080B (en) A kind of data guard method, Apparatus and system
CN104102590A (en) Heterogeneous memory management method and device
CN102117240A (en) Method and device for acquiring progress blocking information
CN102609305A (en) Method for sharing internal memory in server cluster
CN103412822A (en) Operation method of non-volatile RAM, data operation method and relevant device
CN105786725A (en) Memory management method and system based on heterogeneous hybrid memory
CN105868093A (en) Log write-in method and server side
CN102073549B (en) Communication method between assemblies on basis of resource sharing
CN104932933A (en) Spin lock acquisition method and apparatus
CN101706788B (en) Cross-area access method for embedded file system
CN109976898B (en) SPI and Eeprom asynchronous communication method of hierarchical task system
CN103218305A (en) Distribution method of memory space
CN109857541A (en) A kind of resource allocation methods of server, system and associated component
CN102262562A (en) Task processing method and system
CN100489781C (en) Method and apparatus for positioning target file
KR101331098B1 (en) Compressed memory swap for virtualized embedded systems and the method
CN106161082A (en) The method to set up of server UUID, system and baseboard management controller
CN106406771B (en) Log recording method and logger
CN104899157A (en) Memory overflow detection method and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20111012