You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Static audit on main @ c7e1799 found an integer underflow / usize::MAX wraparound in ShaderCache::evict_one() whenever a split compute (dispatch_chain) shader is evicted. Part of #1269.
When that entry is later evicted at pso.rs:774 (self.bytes -= old.bytes();), old.bytes() exceeds the amount added on insert by the sum of chain.pieces capacities:
Debug/test builds: panics with subtract-with-underflow and permanently poisons the global shader_cache()Mutex.
Release builds:self.bytes wraps to ~usize::MAX, making while self.bytes + bytes > self.limit (pso.rs:820) evict every entry on every subsequent insert (and risking addition wraparound).
Trigger
Insert any split direct-DXIL compute shader (shader.dispatch_chain.is_some() with non-empty pieces) into ShaderCache, then insert additional entries past the byte or entry limit so the split entry is evicted.
Fix direction
Compute entry size through one shared helper (or construct ShaderEntry first and use entry.bytes() in both insert() and evict_one()), and add a unit test in pso.rs that inserts a Compiled with a non-empty dispatch_chain and triggers eviction.
AI use
Antigravity (Gemini 4 Neon): static code audit on main @ c7e1799 and issue drafting.
Taking this. I will use the same size calculation for insertion and eviction, and add a unit test for the cache budget with a split compute shader. AI use: OpenAI Codex (GPT-6).
Confirmed the insertion-driven eviction on Windows 11 (Rust 1.97.1 MSVC, debug) with one synthetic test and no GPU. With a split entry already cached, insert a plain entry sized to fill the whole byte budget. This exercises the eviction from inside ShaderCache::insert.
Activity
Creaa commentedon Nov 25, 2026
Taking this. I will use the same size calculation for insertion and eviction, and add a unit test for the cache budget with a split compute shader. AI use: OpenAI Codex (GPT-6).
ettehn commentedon Nov 26, 2026
Confirmed the insertion-driven eviction on Windows 11 (Rust 1.97.1 MSVC, debug) with one synthetic test and no GPU. With a split entry already cached, insert a plain entry sized to fill the whole byte budget. This exercises the eviction from inside
ShaderCache::insert.06055a7, the second insertion reachesevict_oneand panics atpso.rs:785withattempt to subtract with overflow.398cefb, the split entry is evicted, the replacement remains readable, andcache.bytesequals the budget. The same test passes.This verifies the debug panic and the fix at the insertion boundary. Release overflow behavior and retail runs were outside this check.
AI-assisted test and verification (OpenAI Codex).