liveBook · Manning

Dangling pointer

A dangling pointer is a pointer or reference to an object or memory whose lifetime has ended or is otherwise no longer valid to access.

How 3 Manning books explain it

C++ Concurrency in Action, Second Edition

A dangling pointer is a pointer that refers to an object whose lifetime has ended or whose storage is no longer valid.

How it is used
Explains a memory-lifetime hazard in concurrent lock-free stack operations.
How deep it goes
Traces the pop race and shows delayed deletion and split reference counts as ways to prevent unsafe access.
Examples
Demonstrates two pop threads competing over one node and a reference-counted implementation.
What you can do after
Understand why a thread must secure a node’s lifetime before dereferencing its pointer.

Read how C++ Concurrency in Action, Second Edition explains dangling pointer →

Systems Programming with Zig

A dangling pointer is a pointer that retains an address after the data formerly stored there is no longer valid.

How it is used
Uses memory lifetimes to guide string ownership in a recipe-book FFI.
How deep it goes
Defines dangling pointers, explains two failure cases, and stops short of a general prevention procedure.
Examples
Shows dereferencing freed memory, returning a stack-variable pointer, and duplicating recipe strings.
What you can do after
Evaluate whether recipe strings outlive their use and duplicate them when user-managed storage is unsuitable.

Read how Systems Programming with Zig explains dangling pointer →

API Design Patterns

A dangling pointer is a pointer that refers to a data object or resource that no longer exists.

How it is used
Handles deletion decisions when API resources refer to one another.
How deep it goes
Defines invalid references, compares four deletion policies, and examines circular references, bulk writes, and deletion avalanches.
Examples
Uses book-author resources, the Becoming example, circular author-book references, and association resources.
What you can do after
Evaluate deletion policies and recognize when an API should return HTTP 412 or tolerate invalid references.

Read how API Design Patterns explains dangling pointer →

Also covered in

What to know first

Related concepts

Questions about dangling pointer

What is dangling pointer?

A dangling pointer is a pointer or reference to an object or memory whose lifetime has ended or is otherwise no longer valid to access.

Which Manning books explain dangling pointer?

C++ Concurrency in Action, Second Edition, Systems Programming with Zig and API Design Patterns.

What should I know before learning dangling pointer?

Manning books that teach dangling pointer usually introduce missing value and reference first.

What is the difference between dangling pointer and missing value?

A dangling pointer is a pointer or reference to an object or memory whose lifetime has ended or is otherwise no longer valid to access. A missing value is an expected data value or observation that is absent, unavailable, unknown, or inapplicable.

What is dangling pointer a kind of?

Dangling pointer is a kind of reference. A reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.