Severity: HIGH
Status: ✅ FIXED
Files: src/grid.zig
Only triggers on allocation failure while shrinking history-limit with a rotated ring (history_start > 0). Double deinit of the same cells buffers → allocator canary / use-after-free in safe builds.
// shrink: deinit excess oldest entries, set history_count = new_limit
self.history_start = ...; self.history_count = new_limit;
if (self.history_start > 0 and ...) {
const temp = self.allocator.alloc(GridLine, self.history_count) catch null;
if (temp) |buf| { ...; self.history.items.len = self.history_count; ... }
// OOM (null): len stays long, count short, freed structs remain
}
Grid.deinit:199 loops for (self.history.items) (full len, not count) and deinits again.
On compaction failure either truncate history.items.len = history_count after moving live entries without temp, or re-compact in place / leave history_start rotated but consistent so deinit only visits live entries. Test with a failing allocator at the compaction point.