Manage object lifetime

Manage object lifetime in C++ — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
An object in our server module holds a raw pointer to a socket resource and sometimes outlives the…
An object in our server module holds a raw pointer to a socket resource and sometimes outlives the socket owner, causing use-after-free crashes on shutdown. Transfer ownership so the socket is closed exactly once: update the code to ensure the server either owns the socket or holds a non-owning observer, and add a clear sequence for destruction that guarantees close is called before any observers dereference it. Test the shutdown path.

Improve — make it easier to accept

+
Before I submit the refactor that replaces raw socket pointers with ownership-aware types, make it…
Before I submit the refactor that replaces raw socket pointers with ownership-aware types, make it easy for the code reviewer: pull the ownership intent to the top of the file, list which classes will own sockets and which will only observe, show the new destructor order and how it avoids double-close, and highlight any behavioral changes a reviewer should test, like concurrent shutdown and reconnection paths.

Decide — diagnose the stuck moment

+
During a test shutdown, the server crashed because a connection handler dereferenced a socket that…

A crash happened during shutdown; someone dereferenced a socket after it was closed.

During a test shutdown, the server crashed because a connection handler dereferenced a socket that another component closed a moment earlier. The codebase mixes raw pointers and manual close calls; I’m not sure who should own the socket. Diagnose the likely ownership pattern that caused this and recommend the next move: convert the socket to a single owner with observer weak references, or centralize close calls behind a manager. Prefer the solution that is fastest and safest to implement with minimal behavioral change.

Become — change the pattern

+
Across projects we repeatedly introduce use-after-free and double-close bugs because teams freely…

We repeatedly get lifetime bugs from mixed raw pointers and manual closes.

Across projects we repeatedly introduce use-after-free and double-close bugs because teams freely pass raw socket pointers and each module sometimes calls close. Where are we losing time and credibility, and what habit should change? Advise a team rule: adopt clear ownership annotations and use a single owning wrapper type for sockets, forbid external close calls, and require a short ownership diagram in PR descriptions. Offer a three-step rollout plan to enforce this gradually.

Next to this one

Other programming language work people do in C++.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.