From 6fb6815cd96b8ca6033187425ab94308c67a4a84 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Fri, 23 Oct 2026 09:29:39 -0400 Subject: [PATCH] fix: document the deliberate buffer leak during thread teardown (SonarCloud) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dropping a wgpu buffer after the device's thread-locals are gone can abort; the device owns the memory either way. 🤖 Generated with Codebuff Co-Authored-By: Codebuff --- crates/gpu/src/ctx.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/gpu/src/ctx.rs b/crates/gpu/src/ctx.rs index 0c3ab8f05..33e02fbe4 100644 --- a/crates/gpu/src/ctx.rs +++ b/crates/gpu/src/ctx.rs @@ -118,7 +118,9 @@ impl Drop for Buf { let mut b = Some(b); let _ = RETIRED.try_with(|r| r.0.borrow_mut().extend(b.take())); match b { - Some(b) => std::mem::forget(b), + // Leaking is deliberate during thread teardown — dropping a wgpu buffer whose device + // thread-locals have already gone can abort the process. The device owns it. + Some(b) => std::mem::forget(b), // NOSONAR None => { RETIRED_BYTES.fetch_add(size, Ordering::Relaxed); }