encyclopegia.org

Stale pointer bug

A stale pointer bug, otherwise known as an aliasing bug, is a class of subtle programming errors that can arise in code that does dynamic memory allocation, especially via the malloc function or equivalent. If several pointers address (are aliases for) a given chunk of storage, it may happen that the storage is freed or reallocated (and thus moved) through one alias and then referenced through another, which may lead to subtle (and possibly intermittent) errors depending on the state and the allocation history of the malloc arena. This bug can be avoided by never creating aliases for allocated memory, by controlling the dynamic scope of references to the storage so that none can remain when it is freed, or by use of a garbage collector, in the form of an intelligent memory-allocation library or as provided by higher-level languages, such as Lisp. The term aliasing bug is nowadays associated with C programming, but it was already in use in a very similar sense in the ALGOL 60 and Fortran programming language communities in the 1960s.

A stale pointer bug, otherwise known as an aliasing bug, is a class of subtle programming errors that can arise in code that does dynamic memory allocation, especially via the malloc function or equivalent. If several pointers address (are aliases for) a given chunk of storage, it may happen that the storage is freed or reallocated (and thus moved) through one alias and then referenced through another, which may lead to subtle (and possibly intermittent) errors depending on the state and the allocation history of the malloc arena. This bug can be avoided by never creating aliases for allocated memory, by controlling the dynamic scope of references to the storage so that none can remain when it is freed, or by use of a garbage collector, in the form of an intelligent memory-allocation library or as provided by higher-level languages, such as Lisp. The term aliasing bug is nowadays associated with C programming, but it was already in use in a very similar sense in the ALGOL 60 and Fortran programming language communities in the 1960s. ==See also== Dangling pointer ==References==

References

No reference rows published for this article.

Cite this article

MLA

"Stale pointer bug." encyclopegia.org, 2026, https://encyclopegia.org/wiki/stale-pointer-bug. Accessed 24 November 2026.

Chicago

"Stale pointer bug." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/stale-pointer-bug.

APA

encyclopegia.org. (2026). Stale pointer bug. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/stale-pointer-bug

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Orange box

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1336939793 · 0.5 · snapshot enwiki-001336939793

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.