Shaders: dxc::cached_only leaks TLS on panic (and console_mesh bypasses it), and xcl shaders --direct leaks detached threads / mislabels panics as timeouts #1896
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1896
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@microwave805 on GitHub · 2026-11-24 22:37 UTC · original
Static audit on
main @ 689f2dbfound three reliability issues in shader compilation probes and thexcl shaders --directCLI harness:1.
dxc::cached_only()leaksCACHED_ONLY = truethread-local state on paniccrates/xcl/src/gpu/recomp/dxc.rs:876-882f()panics and is caught by an outercatch_unwind(or test runner),CACHED_ONLYstays stuck attrueon that thread forever, causing every subsequentdxc::compile_cached/dxc::defer()call on that thread to silently fail as a cache miss instead of compiling.CACHED_ONLY(to its previous value, supporting nesting too) in an RAIIDropguard.2.
pso::console_mesh()bypassesdxc::cached_only()during cold Direct DXIL mesh buildscrates/xcl/src/gpu/recomp/pso.rs:750-762XCL_DIRECT_DXIL=1is enabled and a mesh pipeline is probed underdxc::cached_only()(non-blocking PSO creation),console_mesh()immediately runskernel::translate_mesh()on the caller's thread without checkingdxc::defer(), blocking the render thread on cold mesh translation. (Note: open PR#1788addsdxc::defer()for compute PSO cache probes, but does not coverconsole_mesh().)dxc::defer()before running coldtranslate_mesh()when not already cached (matching#1788's compute path).3.
xcl shaders --directleaks unbounded detached 256 MiB-stack threads on timeouts and mislabels panics as timeoutscrates/xcl/src/shaders.rs:1925-1953--direct(and--direct --lanes) spawns a detachedstd::thread::spawnand waits onrx.recv_timeout(timeout). Insidetranslate_mode/compute_with, translation itself spawns a 256 MiB-stack worker thread. When multiple programs hit timeouts in a whole-pack sweep, each timed-out thread (plus its 256 MiB stack) remains running and detached with no concurrency cap or cancellation, exhausting virtual/physical memory and CPU.shaders.rs:1931and1942:unwrap_or_elsecollapses bothRecvTimeoutError::TimeoutANDRecvTimeoutError::Disconnected(which happens when the spawned thread panics beforetx.send(...), e.g. incompute_withwhich has no outercatch_unwindon line 1940) into"timeout: over N s", masking real panics as timeouts!RecvTimeoutError::TimeoutvsRecvTimeoutError::Disconnected(reporting"panic"on disconnect, and wrappingcompute_withincatch_unwind), and bound active timed-out worker slots (or share a bounded pool / cooperative cancellation flag insideLw/opt).AI use
main @ 689f2dband issue drafting.@JJAutoCompare on GitHub · 2026-11-25 00:36 UTC · original
Local regression results for item 3. A patch on base commit
8c4a46a3c2d50498691cbda79cbbf4fadb45fbe8makes bothxcl shaders --directand--direct --lanesreport a worker that exits without replying aspanic: shader worker disconnected. An expired wait still reportstimeout: over N s.cargo test --locked -p xcl --lib shaders::tests::direct_worker_panic_is_distinct_from_timeout -- --exactran in debug mode on Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 (driver 32.0.101.9175), and Rust 1.100.0 MSVC. The test requires no GPU. With the old mapping it failed because the panic was classified asTimeout. With the fix restored, 1 passed, 0 failed, 0 ignored, and 0 skipped.git diff --checkpassed.The patch is local and uncommitted. Full workspace tests, shader-pack sweeps, and retail smoke runs remain unverified.
AI use: Codex in T3 Code (gpt-6.2-sol) wrote the patch and regression test, ran the checks, and drafted this report.
@JJAutoCompare on GitHub · 2026-11-25 00:32 UTC · original · edited 2026-11-25 00:41 UTC
Follow-up to the targeted diagnostic test report. #1997 covers the same panic/timeout distinction and adds a limit on concurrent timed-out translations, so the narrower local patch can be set aside. I left a review on #1997 about releasing a worker slot before publishing its result. The cached-only mesh probe is outside both changes.
@Decodere on GitHub · 2026-11-25 03:57 UTC · original
Taking the item 2 follow-up for
console_geometry()(crates/xcl/src/gpu/recomp/pso.rs, Part of #1269 / related to #1896): addif dxc::defer() { return Err("DXIL not compiled yet".into()); }on the direct DXIL path beforekernel::translate_geometry(matchingcompile_console_shader/compile_console_mesh), with a deterministic syntheticdxc::cached_onlyregression test.AI use: Google Antigravity (Gemini 4 Neon).