[Minor Feature] Instrumented libtcod debug build for sanitizer coverage #280

Closed
opened 2026-03-08 03:19:35 +00:00 by john · 0 comments
Owner

Context

The debug build system (added post-7DRL 2026) instruments McRogueFace code with ASan/UBSan, but libtcod's pre-built release binaries in __lib/ are uninstrumented. libtcod's pathfinding and FOV operate directly on McRogueFace's grid data structures — the exact location of the #258–#263 heap overflow family.

ASan can detect overflows in our code that corrupt their memory, but cannot detect bugs originating inside libtcod. Since we build libtcod from source anyway (modules/libtcod-headless/), adding an instrumented build is straightforward.

Proposal

Add libtcod to tools/build_debug_python.sh (or a companion tools/build_debug_libs.sh) that:

  1. Builds libtcod from modules/libtcod-headless/ with -fsanitize=address,undefined
  2. Copies the instrumented .so to __lib_debug/
  3. The existing make asan target already links against __lib_debug/ first, so it would pick up the instrumented libtcod automatically

Value

  • Catches memory bugs originating inside libtcod (FOV computation, pathfinding) that touch our grid memory
  • Enables filing memory bugs upstream to libtcod with clear ASan traces
  • Closes the last major uninstrumented gap in the grid/entity subsystem
  • #258–#263 (gridstate overflow family — libtcod FOV is one trigger path)
  • #279 (memory safety audit meta-issue)
## Context The debug build system (added post-7DRL 2026) instruments McRogueFace code with ASan/UBSan, but libtcod's pre-built release binaries in `__lib/` are uninstrumented. libtcod's pathfinding and FOV operate directly on McRogueFace's grid data structures — the exact location of the #258–#263 heap overflow family. ASan can detect overflows in *our* code that corrupt *their* memory, but cannot detect bugs originating inside libtcod. Since we build libtcod from source anyway (`modules/libtcod-headless/`), adding an instrumented build is straightforward. ## Proposal Add libtcod to `tools/build_debug_python.sh` (or a companion `tools/build_debug_libs.sh`) that: 1. Builds libtcod from `modules/libtcod-headless/` with `-fsanitize=address,undefined` 2. Copies the instrumented `.so` to `__lib_debug/` 3. The existing `make asan` target already links against `__lib_debug/` first, so it would pick up the instrumented libtcod automatically ## Value - Catches memory bugs originating *inside* libtcod (FOV computation, pathfinding) that touch our grid memory - Enables filing memory bugs upstream to libtcod with clear ASan traces - Closes the last major uninstrumented gap in the grid/entity subsystem ## Related - #258–#263 (gridstate overflow family — libtcod FOV is one trigger path) - #279 (memory safety audit meta-issue)
john closed this issue 2026-04-10 08:08:46 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
john/McRogueFace#280
No description provided.