Commit Graph

1 Commits

Author SHA1 Message Date
eb4c4204e8 runtime: harden title_window_plan and ArenaBlocks boundary and overflow checks
Fix edge-case arithmetic and boundary bugs in the title-memory window
planner and GPU address arena allocator:

1. runtime/src/title_window_plan.h:
   - title_window_range(): reject va < lo (previously returned a range
     starting at lo > va that excluded va, causing va - range.start to
     underflow in resolve_title_memory), reject most == 0 (avoiding
     std::clamp(want, 1, 0) UB), require power-of-two align, and avoid
     UINT64_MAX - want - align unsigned underflow when computing end.
   - title_pool_extent(): reject non-power-of-two align and unreadable
     requests (readable_end <= va) before rounding end up to align, and
     enforce the most cap after alignment rounding so out.size <= most
     always holds and out contains va.
2. runtime/src/arena_blocks.h:
   - Make align_up() overflow-checked so high alignments or keep_out_end
     near UINT64_MAX cannot wrap to 0 and trigger an infinite loop in
     ArenaBlocks::allocate().
   - Guard against non-advancing keep_out_end <= start in allocate().
   - Make consistent() safe against reserved_ > size_ underflow and
     free_bytes_ + live_bytes overflow.

Extend runtime/test/arena_blocks_test.cpp and add portable
runtime/test/title_window_plan_bounds_test.cpp.

Item: RT-TITLE-WINDOW-AND-ARENA-BOUNDS
2026-11-25 13:09:51 +01:00