stale pointer bug


stale pointer bug

(programming)(Or "aliasing bug") A class of subtleprogramming errors that can arise in code that does dynamic allocation, especially via malloc or equivalent.

If several pointers address (are "aliases for") a given hunkof storage, it may happen that the storage is freed orreallocated (and thus moved) through one alias and thenreferenced through another, which may lead to subtle (andpossibly intermittent) lossage depending on the state and theallocation history of the malloc arena. This bug can beavoided by never creating aliases for allocated memory, or byuse of a higher-level language, such as Lisp, whichemploys a garbage collector.

The term "aliasing bug" is nowadays associated with Cprogramming, it was already in use in a very similar sense inthe ALGOL 60 and Fortran communities in the 1960s.

See also smash the stack, fandango on core, memory leak,memory smash, spam.