Memory Safety - Types of Memory Errors

Types of Memory Errors

Several types of memory errors can occur, depending on which programming language is used:

  • Buffer overflow - Out-of bound writes can corrupt the content of adjacent objects, or internal data like bookkeeping information for the heap or return addresses.
  • Dynamic memory errors - Incorrect management of dynamic memory and pointers:
    • Dangling pointer - A pointer storing the address of an object that has been deleted.
    • Double frees - Repeated call to free though the object has been already freed can cause freelist-based allocators to fail.
    • Invalid Free - Passing an invalid address to free can corrupt the heap. Or sometimes will lead to an undefined behavior.
    • Null pointer accesses will cause an exception or program termination in most environments, but can cause corruption in operating system kernels or systems without memory protection, or when use of the null pointer involves a large or negative offset.
  • Uninitialized variables - A variable that has not been assigned a value is used. It may contain an undesired or, in some languages, a corrupt value.
    • Wild pointers arise when a pointer is used prior to initialization to some known state. They show the same erratic behaviour as dangling pointers, though they are less likely to stay undetected.
  • Out of memory errors:
    • Stack overflow - Occurs when a program runs out of stack space, typically because of too deep recursion.
    • Allocation failures - The program tries to use more memory than the amount available. In some languages, this condition must be checked for manually after each allocation.

Read more about this topic:  Memory Safety

Famous quotes containing the words types of, types, memory and/or errors:

    The wider the range of possibilities we offer children, the more intense will be their motivations and the richer their experiences. We must widen the range of topics and goals, the types of situations we offer and their degree of structure, the kinds and combinations of resources and materials, and the possible interactions with things, peers, and adults.
    Loris Malaguzzi (1920–1994)

    The rank and file have let their servants become their masters and dictators.... Provision should be made in all union constitutions for the recall of leaders. Big salaries should not be paid. Career hunters should be driven out, as well as leaders who use labor for political ends. These types are menaces to the advancement of labor.
    Mother Jones (1830–1930)

    There are no stars to-night
    But those of memory.
    Yet how much room for memory there is
    In the loose girdle of soft rain.
    Hart Crane (1899–1932)

    Let us pardon him his hope of a vain apocalypse, and of a second coming in great triumph upon the clouds of heaven. Perhaps these were the errors of others rather than his own; and if it be true that he himself shared the general illusion, what matters it, since his dream rendered him strong against death, and sustained him in a struggle to which he might otherwise have been unequal?
    Ernest Renan (1823–1892)