con un clic
cpp-memory
Fixing C++ memory crashes (double-free, segfault, UAF) and ASAN
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Fixing C++ memory crashes (double-free, segfault, UAF) and ASAN
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Before writing new code — search existing implementations, topical audits, READMEs, file-header caveats
After implementing — update file headers, README, topical audits; note duplication
Navigate and debug OrbitalWar / SpaceCraft — design, truss sim, combat, radiosity, orbits; hub to docs and tests
Diagnostic plots/visualizations — shared utilities, output paths, plot style conventions
Dedicated documentation work — OKF format, topical audits, extract-overview and inline-doc workflows
Writing new code — inventory-first, module-vs-script placement, no-new-files, STOP triggers for duplication
| name | cpp-memory |
| description | Fixing C++ memory crashes (double-free, segfault, UAF) and ASAN |
One owner per heap array. Other objects hold borrowed aliases (T* copies). Only the owner may _dealloc. Track with bOwn* flags set from _bindOrRealloc return value.
We use explicit dealloc() / clearFFs(), not strict RAII. Destructors on some classes (Atoms) call dealloc(), but SPFF teardown is orchestrated by MolWorld::clearFFs().
cpp/common/macroUtils.h)_alloc / _realloc / _dealloc — standard heap arrays_bindOrRealloc(n, from, arr) → false = borrow from, true = allocated arr_dealloc nulls only the reference passed — other aliases stay live| Tool | Use for |
|---|---|
ASAN (Build-asan, see cpp-build skill) | double-free, UAF, overflow — first choice |
DEBUG_ALLOCATOR (#define in macroUtils.h) | alloc site ledger, invalid-free detection; call debugAllocator_init() |
tests/tSPFF/test_asan_minimal.py | init/clear/Hessian smoke test |
Python getBuffs() = non-owning views. After SPFF.clear(), old NumPy arrays are UAF.
_dealloc and bind sites.bOwn* at bind (initNBmol, bindOrRealloc, setOptimizer).clearFFs() frees owner before borrowers (ffl before nbmol/opt).apos⊂DOFs, UFF fbon⊂fint — never free views._bindOrRealloc if own-or-borrow; set bOwn*.dealloc().init → clear → init.