US20110173505A1 - Method for detecting memory error - Google Patents

Method for detecting memory error Download PDF

Info

Publication number
US20110173505A1
US20110173505A1 US13/053,763 US201113053763A US2011173505A1 US 20110173505 A1 US20110173505 A1 US 20110173505A1 US 201113053763 A US201113053763 A US 201113053763A US 2011173505 A1 US2011173505 A1 US 2011173505A1
Authority
US
United States
Prior art keywords
memory
allocated
indication variable
error
block indication
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.)
Abandoned
Application number
US13/053,763
Inventor
Hyun Seop Bae
Gwang Sik Yoon
Seung Uk Oh
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.)
Individual
Original Assignee
Individual
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 Individual filed Critical Individual
Priority to US13/053,763 priority Critical patent/US20110173505A1/en
Publication of US20110173505A1 publication Critical patent/US20110173505A1/en
Abandoned legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/16Protection against loss of memory contents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/0703Error or fault processing not based on redundancy, i.e. by taking additional measures to deal with the error or fault not making use of redundancy in operation, in hardware, or in data representation
    • G06F11/0751Error or fault detection not based on redundancy
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C29/00Checking stores for correct operation ; Subsequent repair; Testing stores during standby or offline operation
    • G11C29/70Masking faults in memories by using spares or by reconfiguring
    • G11C29/76Masking faults in memories by using spares or by reconfiguring using address translation or modifications
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C29/00Checking stores for correct operation ; Subsequent repair; Testing stores during standby or offline operation
    • G11C29/04Detection or location of defective memory elements, e.g. cell constructio details, timing of test signals
    • G11C2029/0409Online test
    • GPHYSICS
    • G11INFORMATION STORAGE
    • G11CSTATIC STORES
    • G11C29/00Checking stores for correct operation ; Subsequent repair; Testing stores during standby or offline operation
    • G11C29/04Detection or location of defective memory elements, e.g. cell constructio details, timing of test signals
    • G11C29/08Functional testing, e.g. testing during refresh, power-on self testing [POST] or distributed testing
    • G11C29/12Built-in arrangements for testing, e.g. built-in self testing [BIST] or interconnection details
    • G11C29/44Indication or identification of errors, e.g. for repair

Definitions

  • the present invention relates to a method for detecting a memory error and, more particularly, to a method for easily detecting a memory error that may occur when a memory is accessed or an allocated memory is freed in the process of developing software.
  • One of the errors that frequently occur in the process of software programming is an error in using a memory.
  • numerous variables are allocated for use in the memory.
  • a fatal error may occur in runtime.
  • a program developer should be careful that an inappropriate memory use does not occur in the programming stage and should correct a program code not to cause a memory error through debugging or testing.
  • the present invention has been made in view of the above-mentioned problem, and it is an object of the invention to provide a method for detecting a memory error whereby the likelihood of causing a memory error whenever a memory is used is checked in a program source code.
  • a method for detecting a memory error comprises: (a) generating an original block indication variable for indicating a starting memory block in a memory region allocated with respect to variables included in a computer program; (b) detecting a memory error that may occur when the allocated memory region is freed by performing a certain operation, before the allocated memory region is freed, using a target block indication variable indicating a memory block to be accessed in the allocated memory region and/or the original block indication variable; and (c) outputting information about a detected memory error.
  • step (b) may comprise: (1)1) checking whether or not the value of the target block indication variable is identical to a null value; and (b2), determining a memory error when the value of the target block indication variable is identical to the null value.
  • Step (b) may comprise: (b1) checking whether or not the value of the original block indication variable has been initialized; and (b2) determining a memory error if the original block indication variable has not been initialized.
  • Step (b) may comprise: (b1) checking whether or not the target block indication variable indicates a memory block which is at the outside of a heap memory to which the allocated memory region belongs; and (b) determining a memory error when the target block indication variable indicates a memory block which is at the outside of the heap memory to which the allocated memory region belongs.
  • Step (b) may comprise: (b1) checking whether or not the value of the original block indication variable is the null value; and (b2) determining a memory error when the value of the original block indication variable is the null value.
  • Step (b) may comprise: (b1) checking whether or not the target block indication variable indicates the starting memory block in the allocated memory region; and (b2) determining a memory error if the target block indication variable does not indicate the starting memory block in the allocated memory region.
  • the method may further comprise: (d) allocating an identification code to each memory block of the allocated memory region before step (b), and it may be checked whether or not the starting memory block in the allocated memory region is indicated by using the identification codes in step (b1).
  • the identification codes corresponding to the respective memory blocks included in a single allocated memory region may be successively stored in an identification code map region of a computer memory to form a single identification code group, and in step (d), the identification codes may be allocated such that identification codes of a single identification code group are the same and identification codes of adjacent identification code groups in the identification code map region are different, and step (b1) may comprise: (b1-1) checking whether or not an identification code corresponding to a memory block indicated by the target block indication variable is identical to an identification code that immediately precedes in the identification code map region; and (b1-2) determining that the target block indication variable does not indicate the starting memory block in the allocated memory region, if the identification codes are not identical.
  • the identification codes of the identification code group may be one of first to third bit values, and a fourth hit value may be stored at a portion where the identification code groups are not formed in the identification code map region.
  • the computer program that performs such methods may be stored in a computer-readable recording medium.
  • FIG. 1 is a flow chart illustrating the process of a method for detecting a memory error in accessing a memory according to an embodiment of the present invention
  • FIG. 2 is a schematic view illustrating memory regions to explain the method for detecting a memory error according to the embodiment of the present invention.
  • FIG. 3 is a flow chart illustrating the process of a method for detecting a memory error in freeing a memory according to the embodiment of the present invention.
  • Memory errors that may occur in accessing a memory may comprise a null pointer access error, an invalid pointer access error, an out-of-bound access error, and the like.
  • the null pointer access error may occur when although a value of a pointer variable for accessing a memory is null, a command for accessing the memory is executed by using the pointer variable.
  • the invalid pointer access error may comprise a memory error that occurs when a memory that has not been allocated is accessed and a memory error that occurs when a memory desired to be accessed has been freed from an allocated state.
  • the out-of-bound access error may refer to a memory error that occurs when a memory outside the bounds of a memory region allocated to a corresponding variable is accessed while accessing a memory to perform a certain calculation with a particular variable.
  • Memory errors that may occur in freeing a memory may be classified into largely two kinds of error: an illegal free error and a duplicate free error.
  • the illegal free error may comprise a memory error that occurs when a value of a pointer variable indicating a memory desired to be freed is a null value, a memory error that occurs when a memory that has not been allocated is freed, a memory error that occurs when a memory to be freed is outside the bounds of a heap memory region, a memory error that occurs when a pointer variable indicating a memory desired to be freed does not indicate a starting memory block of the memory desired to be freed, and the like.
  • the duplicate free error occurs when an already freed memory is freed again.
  • an original block indication variable is generated to indicate a starting memory block of the allocated memory region (S 102 ). Namely, whenever a memory allocation is generated, the original block indication variable is defined and initialized at a program source code. This process may be manually performed by a developer during a program coding, or may be automatically performed after the program coding is completed.
  • a certain operation is performed using a target block indication variable indicating an access target memory block (i.e., a memory block to be accessed) in the allocated memory region and/or the original block indication variable in order to detect a memory error that may occur in accessing the allocated memory region (S 104 ).
  • a source code that would call the API function to perform the operation is added to every portion of the source code where the memory access is expected to be made, so that the API function would be able to be called before the memory access.
  • the addition of the source code may be manually performed by the developer during the program coding operation, or may be automatically performed after the program coding operation is completed.
  • the program source code should be modified so that the program source code includes the original block indication variables and the code that would call a certain API function, and the modified program is executed to output memory error-associated information, and the program should be corrected based on the memory error-associated information.
  • contents which have been added to the program source code is deleted, and such deletion may be manually performed by the developer or may be automatically performed.
  • malloc( ) when malloc( ) is called in the program, a memory as large as desired by the user is allocated and a memory address is returned.
  • the memory when the memory is allocated by calling malloc( ) the variable for having the returned memory address of the allocated memory region is the target block indication variable and the variable for indicating the starting memory block of the allocated memory region is the original block indication variable.
  • the present invention may be applicable to an arbitrary function that may allocate or access the memory.
  • the present invention is applicable not only for a particular programming language but also for an arbitrary case where, in a system comprising a memory or a storage unit equivalent to the memory, such storage unit is accessed or freed. The method for detecting a memory error according to the types of memory errors will now be described in detail.
  • a memory error is determined (namely, it is determined that there is a memory error) (S 201 ).
  • an out-of-bound access error is detected (S 204 ).
  • the method for detecting an out-of-bound access error will now be described in detail with reference to FIG. 2 .
  • the out-of-bound access error refers to a memory error that occurs when a memory outside the bounds of a memory region allocated to a corresponding variable is accessed while accessing a memory 110 to perform an operation with a particular variable.
  • the error detection method employs a bit map coloring which will be explained hereinafter.
  • identification codes are allocated to each memory block of the allocated memory regions 112 , 114 and 116 .
  • identification codes are allocated to the memory blocks 116 a and 116 b of the allocated memory region 116 .
  • the same identification code is allocated to the memory blocks belonging to the same allocated memory region.
  • the identification codes corresponding to the respective memory blocks (e.g., 116 a and 116 b ) included in each of the allocated memory regions 112 , 114 , and 116 are continuously stored in an identification code map region 120 of the computer memory to form identification code group 122 , 124 , and 126 , respectively.
  • identification code map region 120 For example, if variables ‘a’, ‘b’, and ‘c’ are sequentially allocated a memory in the program, five of identification codes ‘11’ corresponding to the five memory blocks in the allocated memory region 112 with respect to the variable ‘a’ are continuously stored in the identification code map region 120 to form an identification code group 122 .
  • identification code map (bit map) region 120 four of identification codes ‘10’ corresponding to four memory blocks in the allocated memory region 114 with respect to the variable ‘b’ are continuously stored in the identification code map (bit map) region 120 to form an identification code group 124 .
  • the identification code map region 120 have been initialized to a value ‘00’.
  • the order of the identification codes ‘11’, ‘10’, and ‘01’ may be arbitrarily allocated, and the identification codes are allocated such that the identification codes belonging to same identification code group are the same while the identification codes of adjacent identification code groups are different. In order to allocate different identification codes to adjacent identification code groups, three identification codes are required. Also, an identification code for indicating an initialized state of the identification code map region 120 is required.
  • the 2-bit value is, used to express four identification codes; which are merely an example. That is, the bit value may have an arbitrary bit number, and in addition, as the identification codes, four different identification codes may be sufficiently used.
  • a color value may be allocated to each identification code to display a memory allocation and a usage state to the user (bit map coloring).
  • the identifications may not be necessarily stored physically continuously in the identification code map region 120 , so the identification code map region 120 may have an arbitrary logically continued data storage structure.
  • a method of checking whether or not the identification code corresponding to the memory block indicated by the target block indication variable and the identification code corresponding to the memory block indicated by the original block indication variable are identical may be used. If the identification codes are not identical, because it means that the target block indication variable with respect to the corresponding variable indicates a memory block outside the bounds of the allocated memory region, the out-of-bound access error can be detected.
  • One or more of the error detecting methods according to the types of memory errors may be performed regardless of the order to detect memory errors.
  • This method comprises generating an original block indication variable for indicating a starting memory block of a memory region allocated with respect to a variable included in the computer program (S 302 ); detecting a memory error that may occur when an allocated memory region is freed, by performing a certain operation, before the allocated memory region is freed, using a target block indication variable that indicates a memory block to be accessed in the allocated memory region (S 304 ); and outputting information regarding a detected memory error.
  • the target block indication variable indicates a memory block at the outside of the heap memory to which the allocated memory region belongs, and if the target block indication variable indicates a memory at the outside of the heap memory, it is determined as the illegal free error (S 403 ).
  • a memory error may be determined by checking whether or not a pointer variable indicating a memory to be freed has an appropriate value. For example, if a memory is freed by calling the function free( ), an pointer variable of the function free( ) should indicate a starting block of the allocated memory region to be freed. Thus, in order to detect the relevant memory error, the above-mentioned bit map coloring method is employed. With reference to FIG. 2 , in order to free the allocated memory region 114 related to the variable ‘b’, it is checked whether the identification code (the identification code of T_ADDR: the initial identification code ‘10’ of the identification code group 124 ) is identical to the preceding one (identification code of T_ADDR-1). If the two identification codes are identical, it means that the target block indication variable does not indicate the starting memory block of the allocated memory region, so the illegal free error can be detected (S 404 ).
  • the identification code the identification code of T_ADDR: the initial identification code ‘10’ of the identification code group 124
  • the value of the original block indication variable is the null value. If the value of the original block indication variable is the null value, the duplicate free error is detected. In order to make this method effective, when the allocated memory region is lawfully released, the null value needs to be allocated to the original block indication variable (S 405 ).
  • One or more of the error detecting methods according to the types of memory errors may be performed regardless of the order to detect the memory errors.
  • the types of memory errors detected by the memory error detecting method according to the present invention as described above are merely examples, and various other memory errors may be detected by using the technical concept of the present invention in which, in allocating a memory, the original block indication variable is generated to detect memory errors that may occur through operation with respect to the variable or memory errors are detected by using the bit map coloring method.
  • memory errors which may occur when a memory is accessed or freed such as in the programming process of a computer-program or in the execution process of the computer program, etc, can be automatically and reliably detected.

Abstract

A method for easily detecting a memory error that may occur when a memory is accessed or an allocated memory is freed in the process of developing software is disclosed. The memory error detecting method includes: (a) generating an original block indication variable for indicating a starting memory block of a memory region allocated with respect to a variable included in a computer program; (b) detecting a memory error that may occur when the allocated memory region is accessed, by performing a certain operation (computing or arithmetic operation), before the allocated memory region is accessed, using a target block indication variable indicating memory block to be accessed in the allocated memory region and/or the original block indication variable; and (c) outputting information about a detected memory error.

Description

    CROSS-REFERENCE TO RELATED APPLICATIONS
  • This present application is a divisional of U.S. patent application Ser. No. 12/036,550, filed Feb. 25, 2008, which claims priority under 35 U.S.C. §119 to Patent Application No. 2007-41945 filed in Korea on Apr. 30, 2007, the entireties of which are hereby incorporated by reference.
  • FIELD OF THE INVENTION
  • The present invention relates to a method for detecting a memory error and, more particularly, to a method for easily detecting a memory error that may occur when a memory is accessed or an allocated memory is freed in the process of developing software.
  • BACKGROUND OF THE INVENTION
  • One of the errors that frequently occur in the process of software programming is an error in using a memory. In order for software to operate, generally, numerous variables are allocated for use in the memory. When the memory is inappropriately accessed or freed in a program, a fatal error may occur in runtime. Thus, a program developer should be careful that an inappropriate memory use does not occur in the programming stage and should correct a program code not to cause a memory error through debugging or testing.
  • However, to date, in order to remove such an error in using the memory in the programming process in developing software, a programmer carefully performs coding, personally examines a program source code after coding, and executes a program in various execution environments, and when an error occurs, the programmer debugs the error as the need arises. This method, however, has many problems in that high costs are needed and much time is necessary for detecting an error in using the memory, and if no error occurs by chance in executing the program although the memory is inappropriately used, such memory error can be hardly detected, which will inevitably lead to a fatal error at the stage of using the program, possibly causing a huge amount of loss of expenses.
  • SUMMARY OF THE INVENTION
  • The present invention has been made in view of the above-mentioned problem, and it is an object of the invention to provide a method for detecting a memory error whereby the likelihood of causing a memory error whenever a memory is used is checked in a program source code.
  • In another aspect, a method for detecting a memory error comprises: (a) generating an original block indication variable for indicating a starting memory block in a memory region allocated with respect to variables included in a computer program; (b) detecting a memory error that may occur when the allocated memory region is freed by performing a certain operation, before the allocated memory region is freed, using a target block indication variable indicating a memory block to be accessed in the allocated memory region and/or the original block indication variable; and (c) outputting information about a detected memory error.
  • Here, step (b) may comprise: (1)1) checking whether or not the value of the target block indication variable is identical to a null value; and (b2), determining a memory error when the value of the target block indication variable is identical to the null value.
  • Step (b) may comprise: (b1) checking whether or not the value of the original block indication variable has been initialized; and (b2) determining a memory error if the original block indication variable has not been initialized.
  • Step (b) may comprise: (b1) checking whether or not the target block indication variable indicates a memory block which is at the outside of a heap memory to which the allocated memory region belongs; and (b) determining a memory error when the target block indication variable indicates a memory block which is at the outside of the heap memory to which the allocated memory region belongs.
  • Step (b) may comprise: (b1) checking whether or not the value of the original block indication variable is the null value; and (b2) determining a memory error when the value of the original block indication variable is the null value.
  • Step (b) may comprise: (b1) checking whether or not the target block indication variable indicates the starting memory block in the allocated memory region; and (b2) determining a memory error if the target block indication variable does not indicate the starting memory block in the allocated memory region.
  • The method may further comprise: (d) allocating an identification code to each memory block of the allocated memory region before step (b), and it may be checked whether or not the starting memory block in the allocated memory region is indicated by using the identification codes in step (b1).
  • The identification codes corresponding to the respective memory blocks included in a single allocated memory region may be successively stored in an identification code map region of a computer memory to form a single identification code group, and in step (d), the identification codes may be allocated such that identification codes of a single identification code group are the same and identification codes of adjacent identification code groups in the identification code map region are different, and step (b1) may comprise: (b1-1) checking whether or not an identification code corresponding to a memory block indicated by the target block indication variable is identical to an identification code that immediately precedes in the identification code map region; and (b1-2) determining that the target block indication variable does not indicate the starting memory block in the allocated memory region, if the identification codes are not identical.
  • The identification codes of the identification code group may be one of first to third bit values, and a fourth hit value may be stored at a portion where the identification code groups are not formed in the identification code map region.
  • The computer program that performs such methods may be stored in a computer-readable recording medium.
  • The foregoing and other objects, features, aspects and advantages of the present invention will become more apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings.
  • BRIEF DESCRIPTION OF THE DRAWINGS
  • The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the principles of the invention.
  • FIG. 1 is a flow chart illustrating the process of a method for detecting a memory error in accessing a memory according to an embodiment of the present invention;
  • FIG. 2 is a schematic view illustrating memory regions to explain the method for detecting a memory error according to the embodiment of the present invention; and
  • FIG. 3 is a flow chart illustrating the process of a method for detecting a memory error in freeing a memory according to the embodiment of the present invention.
  • DETAILED DESCRIPTION
  • Hereinafter, a method for detecting a memory error according to the present invention will now be described with reference to the accompanying drawings.
  • To begin with, types of memory errors to which the present invention may be applicable will now be described. Memory errors that may occur in accessing a memory may comprise a null pointer access error, an invalid pointer access error, an out-of-bound access error, and the like.
  • The null pointer access error may occur when although a value of a pointer variable for accessing a memory is null, a command for accessing the memory is executed by using the pointer variable. The invalid pointer access error may comprise a memory error that occurs when a memory that has not been allocated is accessed and a memory error that occurs when a memory desired to be accessed has been freed from an allocated state. The out-of-bound access error may refer to a memory error that occurs when a memory outside the bounds of a memory region allocated to a corresponding variable is accessed while accessing a memory to perform a certain calculation with a particular variable.
  • Memory errors that may occur in freeing a memory may be classified into largely two kinds of error: an illegal free error and a duplicate free error.
  • The illegal free error may comprise a memory error that occurs when a value of a pointer variable indicating a memory desired to be freed is a null value, a memory error that occurs when a memory that has not been allocated is freed, a memory error that occurs when a memory to be freed is outside the bounds of a heap memory region, a memory error that occurs when a pointer variable indicating a memory desired to be freed does not indicate a starting memory block of the memory desired to be freed, and the like.
  • The duplicate free error occurs when an already freed memory is freed again.
  • The method for detecting such memory errors according to the embodiment of the present invention will now be described with reference to the accompanying drawings.
  • With reference to FIG. 1, first, when a memory is allocated with respect to a variable included in a program, an original block indication variable is generated to indicate a starting memory block of the allocated memory region (S102). Namely, whenever a memory allocation is generated, the original block indication variable is defined and initialized at a program source code. This process may be manually performed by a developer during a program coding, or may be automatically performed after the program coding is completed.
  • Next, whenever the allocated memory region is accessed with respect to the corresponding variable, a certain operation is performed using a target block indication variable indicating an access target memory block (i.e., a memory block to be accessed) in the allocated memory region and/or the original block indication variable in order to detect a memory error that may occur in accessing the allocated memory region (S104). Namely, a source code that would call the API function to perform the operation is added to every portion of the source code where the memory access is expected to be made, so that the API function would be able to be called before the memory access. The addition of the source code may be manually performed by the developer during the program coding operation, or may be automatically performed after the program coding operation is completed.
  • If a memory error is expected to occur according to the detection result, information regarding the detected memory error is outputted (S106).
  • As mentioned above, the program source code should be modified so that the program source code includes the original block indication variables and the code that would call a certain API function, and the modified program is executed to output memory error-associated information, and the program should be corrected based on the memory error-associated information. After the program development is completed, preferably, contents which have been added to the program source code is deleted, and such deletion may be manually performed by the developer or may be automatically performed.
  • For instance, when malloc( ) is called in the program, a memory as large as desired by the user is allocated and a memory address is returned. In this case, when the memory is allocated by calling malloc( ) the variable for having the returned memory address of the allocated memory region is the target block indication variable and the variable for indicating the starting memory block of the allocated memory region is the original block indication variable. Besides the function malloc( ) the present invention may be applicable to an arbitrary function that may allocate or access the memory. Also, the present invention is applicable not only for a particular programming language but also for an arbitrary case where, in a system comprising a memory or a storage unit equivalent to the memory, such storage unit is accessed or freed. The method for detecting a memory error according to the types of memory errors will now be described in detail.
  • In accessing the allocated memory region, in order to detect a null pointer access error, it is checked whether the value of the target block indication variable is equal to a null value. If the value of the target block indication variable is equal to the null value, a memory error is determined (namely, it is determined that there is a memory error) (S201).
  • In accessing the allocated memory region, in order to detect a memory error that may occur when a memory which has not been allocated is accessed, it is checked whether the value of the original block indication variable has been initialized. If the value of the original block indication variable has not been initialized, an invalid pointer access error is determined (S202).
  • In order to detect a memory error that may occur when a memory desired to be accessed is a memory which has been already freed (from an allocated state), it is checked whether or not the value of the original block indication variable is the null value. If the value of the original block indication variable is the null value, the invalid memory access error is determined (S203).
  • In addition, an out-of-bound access error is detected (S204). The method for detecting an out-of-bound access error will now be described in detail with reference to FIG. 2.
  • First, as afore-mentioned, the out-of-bound access error refers to a memory error that occurs when a memory outside the bounds of a memory region allocated to a corresponding variable is accessed while accessing a memory 110 to perform an operation with a particular variable. Thus, in order to detect the out-of-bound access error, it is checked whether or not the target block indication variable indicates a memory block outside the bounds of the allocated memory region. To detect the out-of-bound access error, the error detection method according to the present invention employs a bit map coloring which will be explained hereinafter.
  • For example, when the memory regions 112, 114 and 116 are allocated with respect to respective variables ‘a’, ‘b’ and ‘c’ included in the computer program, identification codes are allocated to each memory block of the allocated memory regions 112, 114 and 116. For example, identification codes are allocated to the memory blocks 116 a and 116 b of the allocated memory region 116. In this case, the same identification code is allocated to the memory blocks belonging to the same allocated memory region.
  • The identification codes corresponding to the respective memory blocks (e.g., 116 a and 116 b) included in each of the allocated memory regions 112, 114, and 116 are continuously stored in an identification code map region 120 of the computer memory to form identification code group 122, 124, and 126, respectively. For example, if variables ‘a’, ‘b’, and ‘c’ are sequentially allocated a memory in the program, five of identification codes ‘11’ corresponding to the five memory blocks in the allocated memory region 112 with respect to the variable ‘a’ are continuously stored in the identification code map region 120 to form an identification code group 122. Also, four of identification codes ‘10’ corresponding to four memory blocks in the allocated memory region 114 with respect to the variable ‘b’ are continuously stored in the identification code map (bit map) region 120 to form an identification code group 124. Before the identification code groups are formed, the identification code map region 120 have been initialized to a value ‘00’.
  • The order of the identification codes ‘11’, ‘10’, and ‘01’ may be arbitrarily allocated, and the identification codes are allocated such that the identification codes belonging to same identification code group are the same while the identification codes of adjacent identification code groups are different. In order to allocate different identification codes to adjacent identification code groups, three identification codes are required. Also, an identification code for indicating an initialized state of the identification code map region 120 is required. In the embodiment of the present invention, the 2-bit value is, used to express four identification codes; which are merely an example. That is, the bit value may have an arbitrary bit number, and in addition, as the identification codes, four different identification codes may be sufficiently used. A color value may be allocated to each identification code to display a memory allocation and a usage state to the user (bit map coloring). In addition, the identifications may not be necessarily stored physically continuously in the identification code map region 120, so the identification code map region 120 may have an arbitrary logically continued data storage structure.
  • In order to detect the out-of-bound access error by using the bit map coloring, a method of checking whether or not the identification code corresponding to the memory block indicated by the target block indication variable and the identification code corresponding to the memory block indicated by the original block indication variable are identical may be used. If the identification codes are not identical, because it means that the target block indication variable with respect to the corresponding variable indicates a memory block outside the bounds of the allocated memory region, the out-of-bound access error can be detected.
  • One or more of the error detecting methods according to the types of memory errors may be performed regardless of the order to detect memory errors.
  • The method for detecting a memory error that may occur when the memory is freed will now be described with reference to FIG. 3. This method comprises generating an original block indication variable for indicating a starting memory block of a memory region allocated with respect to a variable included in the computer program (S302); detecting a memory error that may occur when an allocated memory region is freed, by performing a certain operation, before the allocated memory region is freed, using a target block indication variable that indicates a memory block to be accessed in the allocated memory region (S304); and outputting information regarding a detected memory error.
  • First, in order to detect a case where a memory is freed by using a pointer variable having a null value, it is checked whether the value of the target block indication variable is identical to the null value. If the value of the target block indication variable is identical to the null value, the illegal free error is determined (S401).
  • Next, in order to detect a case where a memory which has not been allocated is freed, it is checked whether the value of the original block indication variable has been initialized. If the value of the original block indication variable has not been initialized, the illegal free error is determined (S402). In order to make this method effective, it is necessary to generate the original block indication variable each time a memory is allocated, and initialize the value of the original block indication variable. Thus, if the original block indication variable has not been initialized, it may be determined that a memory has not been allocated.
  • And then, if a memory desired to be freed from an allocated state is at the outside of a heap memory, a fatal memory error would be caused. Thus, it is checked whether or not the target block indication variable indicates a memory block at the outside of the heap memory to which the allocated memory region belongs, and if the target block indication variable indicates a memory at the outside of the heap memory, it is determined as the illegal free error (S403).
  • A memory error may be determined by checking whether or not a pointer variable indicating a memory to be freed has an appropriate value. For example, if a memory is freed by calling the function free( ), an pointer variable of the function free( ) should indicate a starting block of the allocated memory region to be freed. Thus, in order to detect the relevant memory error, the above-mentioned bit map coloring method is employed. With reference to FIG. 2, in order to free the allocated memory region 114 related to the variable ‘b’, it is checked whether the identification code (the identification code of T_ADDR: the initial identification code ‘10’ of the identification code group 124) is identical to the preceding one (identification code of T_ADDR-1). If the two identification codes are identical, it means that the target block indication variable does not indicate the starting memory block of the allocated memory region, so the illegal free error can be detected (S404).
  • Next, in order to detect the case where an allocated memory region is repeatedly freed, it is checked whether the value of the original block indication variable is the null value. If the value of the original block indication variable is the null value, the duplicate free error is detected. In order to make this method effective, when the allocated memory region is lawfully released, the null value needs to be allocated to the original block indication variable (S405). One or more of the error detecting methods according to the types of memory errors may be performed regardless of the order to detect the memory errors.
  • The types of memory errors detected by the memory error detecting method according to the present invention as described above are merely examples, and various other memory errors may be detected by using the technical concept of the present invention in which, in allocating a memory, the original block indication variable is generated to detect memory errors that may occur through operation with respect to the variable or memory errors are detected by using the bit map coloring method.
  • As described above, memory errors, which may occur when a memory is accessed or freed such as in the programming process of a computer-program or in the execution process of the computer program, etc, can be automatically and reliably detected.
  • The preceding specific embodiments are illustrative of the practice of the invention. It is to be understood, however, that other expedients known to those skilled in the art or disclosed herein, may be employed without departing from the spirit of the invention or the scope of the appended claims.

Claims (21)

1. A method for detecting a memory error within source code of a computer program comprising:
(a) generating an original block indication variable for indicating a starting memory block in a memory region allocated with respect to variables included in a computer program;
(b) detecting if a memory error will occur when the allocated memory region is freed, before the allocated memory region is freed, using at least one of a target block indication variable indicating a memory block to be accessed in the allocated memory region and the original block indication variable; and
(c) outputting information about a detected memory error.
2. The method of claim 1, wherein the step (b) comprises:
(b1) checking whether or not a value of the target block indication variable is identical to a null value; and
(b2) determining a memory error when the value of the target block indication variable is identical to the null value.
3. The method of claim 1, wherein the step (b) comprises:
(b1) checking whether or not a value of the original block indication variable has been initialized; and
(b2) determining a memory error if the original block indication variable has not been initialized.
4. The method of claim 1, wherein the step (b) comprises:
(b1) checking whether or not the target block indication variable indicates a memory block which is at the outside of a heap memory to which the allocated memory region belongs; and
(b2) determining a memory error when the target block indication variable indicates a memory block which is at the outside of the heap memory to which the allocated memory region belongs.
5. The method of claim 1, wherein the step (b) comprises:
(b1) checking whether or not a value of the original block indication variable is a null value; and
(b2) determining a memory error when the value of the original block indication variable is the null value.
6. The method of claim 1, wherein the step (b) comprises:
(b1) checking whether or not the target block indication variable indicates a starting memory block in the allocated memory region; and
(b2) determining a memory error if the target block indication variable does not indicate the starting memory block in the allocated memory region.
7. The method of claim 6, further comprising:
(d) allocating an identification code to each memory block of the allocated memory region before step (b), and it is checked whether or not the starting memory block in the allocated memory region is indicated by using the identification codes in step (b1).
8. The method of claim 7, wherein the identification codes corresponding to the respective memory blocks included in a single allocated memory region are successively stored in an identification code map region of a computer memory to form a single identification code group, and in step (d), the identification codes are allocated such that identification codes of a single identification code group are the same and identification codes of adjacent identification code groups in the identification code map region are different, and step (b1) comprises:
(b1-1) checking whether or not an identification code corresponding to a memory block indicated by the target block indication variable is identical to an identification code that immediately precedes in the identification code map region; and
(b1-2) determining that the target block indication variable does not indicate the starting memory block in the allocated memory region, if the identification codes are identical.
9-10. (canceled)
11. A method for detecting a memory error within source code of a computer program comprising:
(a) generating an original block indication variable for indicating a starting memory block in an allocated memory region;
(b) adding an error check source code to the source code of the computer program that performs a computing operation, wherein the error check source code is added before portions of the source code of the computer program where freeing memory will occur, and wherein the computing operation checks for memory errors;
(c) detecting if a memory error will occur when the allocated memory region is freed before the allocated memory region is freed by executing the error check source code to perform the computing operation, wherein the computing operation uses at least one of a target block indication variable and the original block indication variable, wherein the target block indication variable indicates a memory block to be accessed in the allocated memory region; and
(d) outputting information about a detected memory error.
12. The method of claim 11, wherein the computing operation comprises:
checking whether or not a value of the target block indication variable is identical to a null value; and
determining a memory error when the value of the target block indication variable is identical to the null value.
13. The method of claim 1, wherein the computing operation comprises:
checking whether or not a value of the original block indication variable has been initialized; and
determining a memory error if the original block indication variable has not been initialized.
14. The method of claim 11, wherein the computing operation comprises:
checking whether or not the target block indication variable indicates a memory block which is at the outside of a heap memory to which the allocated memory region belongs; and
determining a memory error when the target block indication variable indicates a memory block which is at the outside of the heap memory to which the allocated memory region belongs.
15. The method of claim 11, wherein the computing operation comprises:
checking whether or not the value of the original block indication variable is the null value; and
determining a memory error when the value of the original block indication variable is the null value.
16. The method of claim 11, wherein the computing operation comprises:
checking whether or not the target block indication variable indicates the starting memory block in the allocated memory region; and
determining a memory error if the target block indication variable does not indicate the starting memory block in the allocated memory region.
17. The method of claim 16, further comprising:
(e) allocating an identification code to each memory block of the allocated memory region before step (b), and
checking whether or not the starting memory block in the allocated memory region is indicated by using the identification codes.
18. The method of claim 17, wherein the identification codes corresponding to the respective memory blocks included in a single allocated memory region are successively stored in an identification code map region or a computer memory to form a single identification code group, and
in step (e), the identification codes are allocated such that identification codes of a single identification code group are the same and identification codes of adjacent identification code groups in the identification code map region are different, and
the computing operation comprises:
checking whether or not an identification code corresponding to a memory block indicated by the target block indication variable is identical to an identification code that immediately precedes in the identification code map region; and
determining that the target block indication variable does not indicate the starting memory block in the allocated memory region, if the identification codes are identical.
19. The method of claim 18, wherein the identification codes of the identification code group are one of first to third bit values, and a fourth bit value is stored at a portion where the identification code groups are not formed in the identification code map region.
20. A computer-readable recording medium that stores a program which, when executed by a computer, causes the computer to execute the method described as in claim 11.
21. A method for detecting a memory error within source code of a computer program comprising:
(a) generating an original block indication variable for indicating a starting memory block in an allocated memory region;
(b) detecting if a memory error will occur when the allocated memory region is freed before the allocated memory region is freed by executing error check source code to perform a computing operation, wherein the computing operation uses at least one of a target block indication variable and the original block indication variable, wherein the target block indication variable indicates a memory block to be accessed in the allocated memory region; and
(c) outputting information about a detected memory error.
22. The method of claim 21, wherein the step (b) comprises:
(b1) checking whether or not a value of the target block indication variable is identical to a null value; and
(b2) determining a memory error when the value of the target block indication variable is identical to the null value.
US13/053,763 2007-04-30 2011-03-22 Method for detecting memory error Abandoned US20110173505A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US13/053,763 US20110173505A1 (en) 2007-04-30 2011-03-22 Method for detecting memory error

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
KR1020070041945A KR100890546B1 (en) 2007-04-30 2007-04-30 The method of detecting memory error
KR10-2007-0041945 2007-04-30
US12/036,550 US7962832B2 (en) 2007-04-30 2008-02-25 Method for detecting memory error
US13/053,763 US20110173505A1 (en) 2007-04-30 2011-03-22 Method for detecting memory error

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
US12/036,550 Division US7962832B2 (en) 2007-04-30 2008-02-25 Method for detecting memory error

Publications (1)

Publication Number Publication Date
US20110173505A1 true US20110173505A1 (en) 2011-07-14

Family

ID=39888489

Family Applications (2)

Application Number Title Priority Date Filing Date
US12/036,550 Active 2029-02-06 US7962832B2 (en) 2007-04-30 2008-02-25 Method for detecting memory error
US13/053,763 Abandoned US20110173505A1 (en) 2007-04-30 2011-03-22 Method for detecting memory error

Family Applications Before (1)

Application Number Title Priority Date Filing Date
US12/036,550 Active 2029-02-06 US7962832B2 (en) 2007-04-30 2008-02-25 Method for detecting memory error

Country Status (3)

Country Link
US (2) US7962832B2 (en)
JP (1) JP2008276763A (en)
KR (1) KR100890546B1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120278665A1 (en) * 2011-04-29 2012-11-01 Google Inc. Method and apparatus for detecting memory access faults
US9113164B1 (en) 2012-05-15 2015-08-18 Google Inc. Constant bit rate control using implicit quantization values
US9407915B2 (en) 2012-10-08 2016-08-02 Google Inc. Lossless video coding with sub-frame level optimal quantization values
US9510019B2 (en) 2012-08-09 2016-11-29 Google Inc. Two-step quantization and coding method and apparatus
WO2017074615A1 (en) * 2015-10-28 2017-05-04 Intel Corporation Interfacing with block-based storage in a processor
US10324659B2 (en) 2017-05-24 2019-06-18 International Business Machines Corporation Detection of over-access of memory shared among multiple processes

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010057459A1 (en) * 2008-11-24 2010-05-27 Luk Lamellen Und Kupplungsbau Beteiligungs Kg Method for start-up and computer program product and apparatus
CN102385533A (en) * 2010-08-30 2012-03-21 鸿富锦精密工业(深圳)有限公司 Computer and restart method thereof during run-time error of memory
KR101335326B1 (en) * 2011-12-30 2013-12-02 (주)네오위즈게임즈 Client Apparatus, Watching Server, and Method for Preventing Falsification of Watching Area
US9892253B1 (en) 2016-06-20 2018-02-13 Amazon Technologies, Inc. Buffer overflow exploit detection
KR101850303B1 (en) * 2016-09-13 2018-05-31 슈어소프트테크주식회사 Method for correcting violation of source code and computer readable recording medium having program the same
KR20180126921A (en) * 2017-05-19 2018-11-28 에스케이하이닉스 주식회사 Data storage device and operating method thereof
KR102545765B1 (en) * 2018-05-28 2023-06-21 삼성전자주식회사 Method and system for detecting memory errors
CN112486803A (en) * 2020-11-12 2021-03-12 珠海格力电器股份有限公司 Error processing method, device and equipment
CN112331254A (en) * 2020-11-24 2021-02-05 北京泽石科技有限公司 Method and device for generating trial and error table of nonvolatile memory
US11720674B2 (en) * 2021-01-28 2023-08-08 Northrop Grumman Systems Corporation Systems and methods for malware detection

Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4710934A (en) * 1985-11-08 1987-12-01 Texas Instruments Incorporated Random access memory with error correction capability
US5077720A (en) * 1986-12-10 1991-12-31 Matsushita Electric Industrial Co., Ltd. Optical information recording and reproducing system and optical disk
US5557622A (en) * 1990-10-01 1996-09-17 Digital Equipment Corporation Method and apparatus for parity generation
US5590329A (en) * 1994-02-04 1996-12-31 Lucent Technologies Inc. Method and apparatus for detecting memory access errors
US5628016A (en) * 1994-06-15 1997-05-06 Borland International, Inc. Systems and methods and implementing exception handling using exception registration records stored in stack memory
US5644709A (en) * 1994-04-21 1997-07-01 Wisconsin Alumni Research Foundation Method for detecting computer memory access errors
US5819252A (en) * 1996-04-10 1998-10-06 Digital Equipment Corporation Method and apparatus for handling and detecting an invalid use of a data structure
US6035432A (en) * 1997-07-31 2000-03-07 Micron Electronics, Inc. System for remapping defective memory bit sets
US6237110B1 (en) * 1997-10-30 2001-05-22 Kye Technology Corporation Apparatus and method accessing flash memory
US6243845B1 (en) * 1997-06-19 2001-06-05 Sanyo Electric Co., Ltd. Code error correcting and detecting apparatus
US6671771B2 (en) * 1999-12-21 2003-12-30 Intel Corporation Hash CAM having a reduced width comparison circuitry and its application
US7051264B2 (en) * 2001-11-14 2006-05-23 Monolithic System Technology, Inc. Error correcting memory and method of operating same
US7246302B2 (en) * 2003-11-11 2007-07-17 Samsung Electronics Co., Ltd. Disk player for allocating pointers to frames of CD data and storing pointers in memory and method of processing reproduced data of disk player
US7370260B2 (en) * 2003-12-16 2008-05-06 Freescale Semiconductor, Inc. MRAM having error correction code circuitry and method therefor
US7631244B2 (en) * 2005-03-17 2009-12-08 Fujitsu Limited Soft error correction method, memory control apparatus and memory system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06282463A (en) * 1993-03-26 1994-10-07 Matsushita Electric Ind Co Ltd Memory control method for program test
JP2005070950A (en) * 2003-08-21 2005-03-17 Sanyo Electric Co Ltd Program processing apparatus
KR100580071B1 (en) * 2004-10-05 2006-05-16 주식회사 팬택앤큐리텔 Detcting method for memory error

Patent Citations (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4710934A (en) * 1985-11-08 1987-12-01 Texas Instruments Incorporated Random access memory with error correction capability
US5077720A (en) * 1986-12-10 1991-12-31 Matsushita Electric Industrial Co., Ltd. Optical information recording and reproducing system and optical disk
US5557622A (en) * 1990-10-01 1996-09-17 Digital Equipment Corporation Method and apparatus for parity generation
US5590329A (en) * 1994-02-04 1996-12-31 Lucent Technologies Inc. Method and apparatus for detecting memory access errors
US5644709A (en) * 1994-04-21 1997-07-01 Wisconsin Alumni Research Foundation Method for detecting computer memory access errors
US5628016A (en) * 1994-06-15 1997-05-06 Borland International, Inc. Systems and methods and implementing exception handling using exception registration records stored in stack memory
US5819252A (en) * 1996-04-10 1998-10-06 Digital Equipment Corporation Method and apparatus for handling and detecting an invalid use of a data structure
US6243845B1 (en) * 1997-06-19 2001-06-05 Sanyo Electric Co., Ltd. Code error correcting and detecting apparatus
US6035432A (en) * 1997-07-31 2000-03-07 Micron Electronics, Inc. System for remapping defective memory bit sets
US6237110B1 (en) * 1997-10-30 2001-05-22 Kye Technology Corporation Apparatus and method accessing flash memory
US6671771B2 (en) * 1999-12-21 2003-12-30 Intel Corporation Hash CAM having a reduced width comparison circuitry and its application
US7051264B2 (en) * 2001-11-14 2006-05-23 Monolithic System Technology, Inc. Error correcting memory and method of operating same
US7246302B2 (en) * 2003-11-11 2007-07-17 Samsung Electronics Co., Ltd. Disk player for allocating pointers to frames of CD data and storing pointers in memory and method of processing reproduced data of disk player
US7370260B2 (en) * 2003-12-16 2008-05-06 Freescale Semiconductor, Inc. MRAM having error correction code circuitry and method therefor
US7631244B2 (en) * 2005-03-17 2009-12-08 Fujitsu Limited Soft error correction method, memory control apparatus and memory system

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120278665A1 (en) * 2011-04-29 2012-11-01 Google Inc. Method and apparatus for detecting memory access faults
US8762797B2 (en) * 2011-04-29 2014-06-24 Google Inc. Method and apparatus for detecting memory access faults
US9113164B1 (en) 2012-05-15 2015-08-18 Google Inc. Constant bit rate control using implicit quantization values
US9510019B2 (en) 2012-08-09 2016-11-29 Google Inc. Two-step quantization and coding method and apparatus
US9407915B2 (en) 2012-10-08 2016-08-02 Google Inc. Lossless video coding with sub-frame level optimal quantization values
WO2017074615A1 (en) * 2015-10-28 2017-05-04 Intel Corporation Interfacing with block-based storage in a processor
US9904586B2 (en) 2015-10-28 2018-02-27 Intel Corporation Interfacing with block-based storage in a processor
US10324659B2 (en) 2017-05-24 2019-06-18 International Business Machines Corporation Detection of over-access of memory shared among multiple processes

Also Published As

Publication number Publication date
KR100890546B1 (en) 2009-03-27
US7962832B2 (en) 2011-06-14
KR20080096963A (en) 2008-11-04
US20080270855A1 (en) 2008-10-30
JP2008276763A (en) 2008-11-13

Similar Documents

Publication Publication Date Title
US7962832B2 (en) Method for detecting memory error
US20030126590A1 (en) System and method for dynamic data-type checking
US5355469A (en) Method for detecting program errors
US6817009B2 (en) Method and apparatus for verifying data local to a single thread
US6009269A (en) Detecting concurrency errors in multi-threaded programs
US7757225B2 (en) Linktime recognition of alternative implementations of programmed functionality
US5699509A (en) Method and system for using inverted data to detect corrupt data
US6542167B1 (en) System and method for flexible software linking
CN100492301C (en) Method and system for avoiding software conflict
US8352921B2 (en) Static analysis defect detection in the presence of virtual function calls
US6240545B1 (en) Setting instance breakpoints in object oriented computer programs
US7698690B2 (en) Identifying code that wastes time performing redundant computation
US20030135844A1 (en) Bytecode program interpreter apparatus and method with pre-verification of data type restrictions and object initialization
US20070204261A1 (en) Robust software library wrapper method and apparatus
JPH0836488A (en) Method and device for checking run-time error using dynamic patching
US9535613B2 (en) Hardware and software methodologies for detecting illegal memory address of a memory access operation
US7028293B2 (en) Constant return optimization transforming indirect calls to data fetches
JPH01263734A (en) Supply of dynamic link identifier for multi-task environment
CN111124921B (en) Method, device, equipment and storage medium for detecting memory boundary crossing
US11868465B2 (en) Binary image stack cookie protection
GB2407403A (en) Validating a variable data item in a software routine
US20240020140A1 (en) Computer system enabled with runtime software module tracking
CN117785540A (en) Memory error detection method, device, equipment and medium
Davydov Detecting Memory Leaks in Long-Running Applications
US20040093537A1 (en) System for determining computer program memory allocation and deallocation

Legal Events

Date Code Title Description
STCB Information on status: application discontinuation

Free format text: ABANDONED -- FAILURE TO RESPOND TO AN OFFICE ACTION