szn

Bug 414 — TemplateCache identity by (ptr,len) aliases reused arena blocks — stale compiled ops produce silently wrong expansions

414. TemplateCache identity by (ptr,len) aliases reused arena blocks — stale compiled ops produce silently wrong expansions

Severity: MEDIUM Status: ✅ RESOLVED

cachedOps treats template.ptr == cached_ptr and template.len == cached_len as “same string”. Option templates are duped from session arenas; when a session dies, its arena blocks return to the backing GPA where a same-size allocation can land at the same address (the server itself admits the hazard: “alias an arena-reused address”, :3183). Server-scoped caches (status_left_cache, status_right_cache, …) are never invalidated on session kill, so expansion then slices the new buffer at the old template’s offsets — wrong text, wrong styles, no crash to hint at it (default 18-byte templates collide trivially).

Fix: also compare content (std.mem.eql) — cheap once identity matched — or bump a config epoch invalidated in killSession and stamp it in the cache.