Method and apparatus for detecting memory access errors
First Claim
1. A method of generating executable code for a program from source code for the program, the executable code including pointer checking code which checks memory references made by dereferencing pointers, the method comprising the steps of:
- performing an analysis based on the source code to identify certain memory references which are made by dereferencing pointers and which need not be checked; and
responding to the analysis by generating the executable code without pointer checking code that checks the certain memory references.
2 Assignments
0 Petitions
Accused Products
Abstract
Disclosed is a software generation system (SGS) based memory error detection system which may be utilized to detect various memory access errors, such as array dimension violations, dereferencing of invalid pointers, accessing freed memory, reading uninitialized memory, and automated detection of memory leaks. Error checking commands and additional information are inserted into a parse tree associated with a source code file being tested at read-time which serve to initiate and facilitate run-time error detection processes. Wrapper functions may be provided for initiating error checking processes for associated library functions. A pointer check table maintains pointer information, including valid range information, for each pointer that is utilized to monitor the use and modification of the respective pointers. A memory allocation structure records allocation information, including a chain list of all pointers that point to the memory region and an initialization status for each byte in the memory region, for each region of memory. The chain list is utilized to monitor the deallocation of the associated memory region, as well as to detect when there is a memory leak. The initialization status is used to ensure that a region of uninitialized memory is not accessed. A data flow analysis algorithm minimizes the number of pointer checks that have to be performed and allows certain read-time errors to be detected.
183 Citations
12 Claims
-
1. A method of generating executable code for a program from source code for the program, the executable code including pointer checking code which checks memory references made by dereferencing pointers, the method comprising the steps of:
-
performing an analysis based on the source code to identify certain memory references which are made by dereferencing pointers and which need not be checked; and responding to the analysis by generating the executable code without pointer checking code that checks the certain memory references. - View Dependent Claims (2, 3)
-
-
4. A method of generating executable code for a program from source code for the program, the executable code including pointer checking code which checks memory references made by dereferencing pointers, the method comprising the steps of:
-
performing an analysis based on the source code to identify certain memory references which are made by dereferencing pointers and which need not be checked; and responding to the analysis by generating the executable code without pointer checking code that checks the certain memory references, wherein the program is executed by a software generation system, and wherein the program comprises one or more library functions, said software generation system maintaining pointer information on each of said dereferencing pointers, the method further comprising the steps of; establishing a flow set for each of said dereferencing pointers; and performing an analysis routine on each line of the source code, said analysis routine comprising the steps of; (i) establishing a new flow set each time said software generation system detects an assignment of a new value to one of the dereferencing pointers in said line of the source code; and (ii) marking the current flow set associated with a dereferenced pointer with an indication that said dereferenced pointer has been dereferenced in said line of the source code; and performing a single pointer check for each of said flow sets having one or more pointer dereferences, said pointer check having an expanded offset for each of said identified flow sets having a plurality of pointer dereferences. - View Dependent Claims (5, 6, 7, 8, 9, 10)
-
-
11. A method of generating executable code for a program from source code for the program, the executable code including pointer checking code which checks memory references made by dereferencing pointers, each of which is associated with one of a plurality of flow sets, the method comprising the steps of:
-
performing an analysis based on the source code to identify certain memory references which are made by dereferencing pointers and which need not be checked, wherein the step of performing comprises the step of eliminating overlapping pointer checks; and responding to the analysis by generating the executable code without pointer checking code that checks the certain memory references, wherein the step of responding comprises the step of establishing a single pointer check for each flow set having one or more pointer dereferences and wherein the step of establishing a single pointer check comprises the step of establishing, for each of the flow sets having a plurality of pointer dereferences, a pointer check having an expanded offset.
-
-
12. A method of generating executable code for a program from source code for the program, the executable code including pointer checking code which checks memory references made by dereferencing pointers, the method comprising the steps of:
-
performing an analysis based on the source code to identify certain memory references which are made by dereferencing pointers and which need not be checked; and responding to the analysis by generating the executable code without pointer checking code that checks the certain memory references, wherein the program comprises a complex expression and is executed by a software generation system, said complex expression containing a plurality of instruction streams, each of said instruction streams having a pointer expression, said software generation system maintaining pointer information on each of said dereferencing pointers, said method further comprising the steps of; allocating a memory location for temporary storage of pointer information; placing a command in each of said instruction streams, only one of said instruction streams being executed by said software generation system at run-time, said command causing said software generation system to retrieve the pointer information associated with the pointer expression in said executed instruction stream and to place said retrieved pointer information in said temporary memory location; and retrieving said pointer information from said temporary memory location upon said pointer'"'"'s dereferencing of said complex expression at run-time.
-
Specification