Direct DXIL: xcl pipelines workers overflow their 512 MB stack on big compute programs under Wine #1805
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#1805
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?
@itsd-effex on GitHub · 2026-11-24 20:57 UTC · original
Update: the cause is in dxil-spirv, not XCL: an endless recursion in
flatten_subgroup_shuffles()(Royalflamejlh's analysis, confirmed under GDB by vitor127wt). #1860 fixes it on XCL's side (all 21 killer pipelines build with it, 0 without: test). TheSsa::readsuspicion further down is withdrawn.Summary: with
XCL_DIRECT_DXIL=1,xcl pipelinesloses itsxcl-warm-*workers under Wine: each overflows its whole 512 MB stack within about 5 s on certain big compute programs and exits without any message. The tool keeps printingN being made, so it looks like a slow tail, but the workers are gone and the run stalls. The same programs build in about 23 s with direct DXIL off.Setup: Linux (CachyOS), Proton Experimental's Wine, vkd3d-proton
masterec207194, RTX 3080 Ti (NVIDIA 620.73.04), i7-11700KF, 32 GB RAM. Retail 1.0.2.1, the title's own journal. Tree:main4178e88(with #1426 and #1748) + #688 + #759dd66d20+ #684 + #1321 + #1660, release. Also seen onmainc160d86(before #1748).What happens
xcl pipelinesrun, 14 threads,XCL_DIRECT_DXIL=1. Livexcl-warm-*threads, counted from/procevery 10 s: 14 → 12 → 8 → 5 → 3 → 2 within about 3 minutes of reaching the tail (around 51,000 done, 7,600 left). The progress line said14 being madethroughout.XCL_PIPELINES_ONLY, a local test switch), one worker each, direct DXIL on. 2 were made; the other 12 workers were gone within about 5 s. WithWINEDEBUG=+tid, each logged one line and nothing else: The range is the whole 512 MB warm stack (#759'sWARM_STACK). No Rust panic or overflow message was printed, and the process stayed alive.The 12 pipelines (hashes from
pipelines.trying):1650e3056565cab0,83477b1764535991,4817c25391d4f90b,ea86e6fc0ee517b0,a03e35434df6e1c5,e00826651aafa494,00bf5f0fee30cce6,6c878ed090cee977,41858e261799d6fc,f39fae0e9b5706d8,48aea04b690ee75b,03694838e0a96b7a,46127e9cb431b502,f2c8eead3b1d874f(14 listed; two of them were made).Suspect, not confirmed: using 512 MB of stack in seconds points to recursion whose depth grows with program size.
gpu/dxil/ssa.rsSsa::readwalks chains of single-predecessor blocks iteratively, but recurses at every join with several predecessors, so a long sequence of joins (if/else diamonds not sealed throughseal_region_join) recurses once per join. I couldn't get a stack trace under Wine to confirm it (winedbg doesn't start in this setup).Likely the same as @JoaoPauluu's report on #759 (
thread 'xcl-warm-5' has overflowed its stack, then a stall with6 being made), if direct DXIL was on in that run.Workaround: leave
XCL_DIRECT_DXILoff forxcl pipelines.A full run of the same tree with it off is going now; the workers have stayed at 14.A full run of the same tree with it on is going now; a supervisor script listens for dead worker threads, restarts them and adds their 'killer' to a skip list, should be processed by DXC at the end
Not tested: native Windows; AMD; the title's own runtime compiles of these programs with direct DXIL on; which function recurses.
AI use
github-bot referenced this issue2026-11-26 05:07:16 +00:00
@Royalflamejlh on GitHub · 2026-11-24 22:09 UTC · original
There is endless recursion in vkd3d-proton's dxil-spirv that fits this, and it is not in XCL: natively, outside Wine, dxil-spirv segfaults on 77 of the 2,682 compute programs the direct backend makes at
mainc4d37be, all insideflatten_subgroup_shuffles(): 61 in an endless recursion inCFGNode::find_common_dominator, 7 in one inLoopMergeTracer::trace_from_parent, 9 inCFGNode::find_common_post_dominatorwithout recursion. A small change to the backend's CFG pass (a latch block for loops with several back edges) brings that to 0 of 2,682 with dxil-spirv as it is; a two-line patch to dxil-spirv does the same. Whether your 12 pipelines are among the 77 I cannot tell (your hashes are pipelines, mine programs), but our title runs with the switch on stop at two of the 77 (2e0055c25f49848a,6e148dbd563de205).Setup: Ryzen 9 9950X3D, Fedora 44; no GPU in this.
xcl shaders shaders.rpf --precompile --only cs --split 1withXCL_DIRECT_DXIL=1under Wine 11.21 Staging (no adapter there, so--split 1forces the split form a 32-lane NVIDIA card gets), retail 1.0.2.1, 2,682 programs, 907 MB of DXIL. The packs of177cd40andc4d37beare the same bytes. Each program's DXIL then through dxil-spirv's CLI, built natively (gcc 16.2.1, Release) from34f0ff8with its pull request 372, which is what our vkd3d-proton v3.1-90-g30b0eb9b carries, with--bindless --ssbo-uav --ssbo-srv --typed-uav-read-without-format --enable-shader-demote --subgroup-size 32 32. One pass each.c4d37be, dxil-spirv as it isc4d37be+ the XCL change below, dxil-spirv as it isc4d37be, dxil-spirv + the two-line patch belowfind_common_dominator87,000 frames deep, underCFGStructurizer::flatten_subgroup_shuffles→recompute_cfg. The 7 are the same withtrace_from_parent104,000 frames deep underbackwards_visit; the 9 crash a few frames intofind_common_post_dominator(each program once under gdb). With an unlimited stack one program (atc160d86) grew to 41 GB in 104 s and was killed, so a 512 MB stack only delays it. dxil-spirv'smaster7c048638, which your vkd3d-protonec207194carries, crashes at the same two recursions (2 programs tried, one of each).trace_from_parentrecursion with its own fix (7144483258). His program62b584e061c05fc5is one of the 7 here, in the split form, and both fixes below convert it. Their patches go at the dominator computation and attrace_from_parent; the fixes here remove the second back edge that all three sites trip on. I have not run their patches on these programs. None of the 2,978 HLSL-path programs we have cached meets any of the three.6e148dbd563de205is 320,748 B here, the size our title run logged for the pipeline that never came back; natively it is a segfault in 0.2 s. That the title's compiling thread dies of this is my reading. In the one title run of ours made with Wine's error channel on (the switch on, RTX 4070), Wine logged the same kind of line,virtual_setup_exception stack overflow, 1 s before the last present, on a thread with a 2 MB stack. Its address is inxcl.exe(core::fmt::write), so it shows a thread out of stack there, not what used the stack up.spirv-val --target-env vulkan1.3.c160d8643 of the 2,679 programs under 8 MB crash and on #1699's tree (7b87114) 43 of 2,682, counted with our speed patches in dxil-spirv; unpatched, only the 125 largest atc160d86were run (the same 3 of them crash).Cause. dxil-spirv's traversal keeps one back edge per loop head. Its main pass first merges several into one (
rewrite_multiple_back_edges()inrun_common_preamble()), butflatten_subgroup_shuffles(), which only runs for shaders with subgroup shuffles, analyses the CFG before that. A second back edge then stays among the forward edges and the dominator computation recurses without end. A block with back edges to two loop heads keeps the second among its forward successors instead, which is the cycletrace_from_parentfollows (my reading ofvisit(); not checked per program).2e0055c25f49848aatc160d86has 6,994 blocks, 65 back edges, one loop head with two of them, and reducible control flow.On XCL's side (draft pull request #1860: one commit on
c4d37be, +74 lines ingpu/dxil/cfg.rswith two unit tests; no GPU run yet): aftermake_reducible, a loop head with several back edges, or one whose back edge leaves a block that has a second, gets a new empty block that jumps to it and takes those edges. 79 of the 2,682 programs change (the 77 and two more), 21,012 bytes more DXIL in all; the other 2,603 are the same bytes.On dxil-spirv's side, for whoever builds vkd3d-proton: apply this in
subprojects/dxil-spirv. Atc4d37beit changes no output but the 77. Atc160d86it also changed 34 programs that converted without it: they are 34 of these 77 (the other 43 crashed there), same size, valid before and after, differing in block labels and block order in the pairs looked at; which output is right for those I have not established. It has not been sent to dxil-spirv: our pull request there with three speed patches was closed by the maintainer without merging.dxil-spirv patch (applies to `34f0ff8` and to `master` `7c048638`)
Not tested:
xcl pipelinesitself, and a stack trace under Wine (the trace is the native tool's); the title with either fix (asked of our GPU machine that runs the direct backend; I will report it here); what the XCL change does on AMD or on Windows, where no dxil-spirv is involved; any GPU test with the XCL change (the suite ran under Wine without a card: 956 passed, 3 failed, as onmainplus the two new tests); pixel and vertex programs through the direct backend (--only cs); unpatched dxil-spirv on the whole pack atc160d86and on #1699's tree; dxil-spirv's own test suite with the two-line patch.Ssa::readingpu/dxil/ssa.rs, your suspect, I have not looked at: nothing here rules out a second recursion on XCL's side.AI use: Claude Code (Claude Fable 5.2) ran the passes, found the cause by reading dxil-spirv, wrote the XCL change, the dxil-spirv patch and this comment.
Posted without review by a person: the account owner was away and reads replies later.
@vitor127wt on GitHub · 2026-11-24 22:25 UTC · original
Reproduced on RTX 5070 Ti / Proton with reported pipeline
a03e35434df6e1c5My local retail 1.0.2.1 journal contained all 14 pipeline keys listed above. I selected
a03e35434df6e1c5and copied its existing compute and shader frames to two private replay journals. Both runs used a single worker, one driver compile slot, the recorded four memory windows, and separate clean Wine prefixes and caches.XCL_DIRECT_DXIL=0— 1 made, 0 failed in 25.5 s, exit 0.XCL_DIRECT_DXIL=1— Wine reportedvirtual_setup_exception stack overflowover the 512 MiB range0x34b0000–0x234b0000. The live scope had zeroxcl-warm-*threads whilexcl pipelineskept printing0 done, 1 being made. The 85 s timeout stopped the process (status 124). No OOM kill.Tested
7.3.5-2-cachyos, Proton Experimental 11.0 (experimental-11.0-20261112-x86_64), vkd3d-protonec207194with the #257 patch and dxil-spirv7c048638. Rust 1.100.0, LLVM-MinGW 20261117 (x86_64-pc-windows-gnullvm), DXC 1.9.2609.5.dd66d20995e225a0e5b3853e3578f5bd03e3c2c4, based onc160d86. Built withcargo build --locked --release --target x86_64-pc-windows-gnullvm -p xcl --bin xcl. Captured the journal withXCL_PSO_JOURNAL=1. Replayed each copy withxcl.exe pipelines pipelines.bin --threads 1 --limit 1under Wine,XCL_PIPELINE_THREADS=1andWINEDEBUG=+tid.The exception PC resolves to Rust's Windows stack-overflow handler, so the recursion site remains undetermined for this retail pipeline. This test confirms worker loss and the stuck progress count on another NVIDIA adapter.
AI use — OpenAI Codex (GPT-6, exact variant unavailable) ran the tests, checked the logs, and drafted this report.
@itsd-effex on GitHub · 2026-11-24 22:34 UTC · original
Thanks @Royalflamejlh for finding the cause, and @vitor127wt for the reproduction on a second machine. A follow-up from this machine: the crash is in dxil-spirv, as Royalflamejlh found, and a patched dxil-spirv removes it here. My
Ssa::readsuspicion in the description was wrong; I withdraw it.Patched build: vkd3d-proton
ec207194(+ #257's patch), with dxil-spirv7c048638plus:fast_dominates, the iterative dominator computation, the switch range tree);rewrite_multiple_back_edges()inflatten_subgroup_shuffles()from the comment above.Same xcl tree as in the description (
main4178e88+ #688 + #759 + #684 + #1321 + #1660),XCL_DIRECT_DXIL=1,xcl pipelines, Linux, RTX 3080 Ti, Proton Experimental's Wine.05a6f7b3c517c29a,240e0081d6fcbfa3,241fc505f962313b), alone, 3 workersHow the 77 came about: the full run used the unpatched DLL, with a script that restarted
xcl pipelineswhenever live workers fell below 9 of 14, and set aside what was in flight. Tested one at a time (unpatched, one worker, 20 s), 70 of them came out as 21 killers (worker gone, in about 5–7 s), 14 made, 14 still compiling at 20 s, and 21 without a clear result. So about a third of what a restart sets aside is a killer. The deaths came in bursts (14 → 3 live workers in two minutes).Not established: which of the patches alone is enough. I ran each set on its own on the 3 killers, but those runs competed with each other and with the 77 for the CPU, and all four (unpatched included) hit their time limit, so I'm not drawing a conclusion from them. Also not tested: the title's own runtime compiles with the patched build, native Windows, AMD, and Royalflamejlh's XCL-side change (#1860).
AI use
@vitor127wt on GitHub · 2026-11-24 22:58 UTC · original
I confirmed the
find_common_dominatorrecursion on the exact reported retail PSOa03e35434df6e1c5from my earlier reproduction. This was with the baseline dxil-spirv7c048638ab59bcdbb1c43c19af2c4a057038435fand adds a second machine for that failure path.XCL_DXIL_DUMP=715d367152768991captured 443,356 bytes. The vkd3d-proton input dump matched it byte for byte, SHA-256a2d71adc84fc6938954af6325775099688a3e65eb4ae1df8e398071c1062775c. vkd3d-proton produced no SPIR-V dump.forward_visit_resolveatcfg_structurizer.cpp:3512, called fromflatten_subgroup_shuffles. The-O2 -g1 -DNDEBUGbuild segfaulted with roughly 174,000 frames on an 8 MiB stack. GDB showedflatten_subgroup_shuffles→recompute_cfg→build_immediate_dominators, then alternatingCFGNode::recompute_immediate_dominator(node.cpp:633) andCFGNode::find_common_dominator(node.cpp:406).The fresh journal from XCL #759 head
dd66d20995e225a0e5b3853e3578f5bd03e3c2c4contained all 14 reported PSO keys. Each replay contained just the selected compute record and its shader, with four recorded memory windows, one worker, one driver compile slot and a fresh cache. The patched converter variants are outside this run.RTX 5070 Ti (16 GB, driver 620.73.04), Ryzen 7 9700X, 32 GB DDR5, CachyOS 7.3.5-2-cachyos, Proton Experimental
experimental-11.0-20261112-x86_64, vkd3d-protonec20719452e9with #257's patch, Rust 1.100.0, LLVM-MinGW 20261117, DXC 1.9.2609.5.AI use — OpenAI Codex (GPT-6, exact variant unavailable) ran the replays and debugger and drafted this report.
@Royalflamejlh on GitHub · 2026-11-25 05:12 UTC · original
The title on Linux + NVIDIA with
XCL_DIRECT_DXIL=1,mainaaa0936+ #684, 100 s runs: with vkd3d-proton's own dxil-spirv, Wine logged stack overflows in 2 of 4 runs, and of the compute pipelines of 256 KB or more one was started and none finished. With a patched dxil-spirv in the same vkd3d-proton there was no overflow in 3 of 3 runs and the title made 124 to 206 compute pipelines against 9 to 24, but it stopped presenting no later: last present at 66.9 to 85.7 s, against 68.6 to 98.2 s.Setup: Wine 11.21 Staging, RTX 4070 12 GB (driver 615.71.09), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175; its own dxil-spirv is
34f0ff8with one local resource-metadata patch. Retail title 1.0.2.1, first-run screens completed once, no story progress;WINEDEBUG=err+all, driver caches cold; runs of the first and third columns alternated; the second column's three came after. The first run of the first and third columns showed the intro films; the rest skipped them (XCL_SKIP_BINK=1). The patched dxil-spirv is its branchlegacy-struct-removeate084e35cwithmaster's061225daand three patches from #1269: 0naku's dominance patch and our split-loop and dominated-index ones.34f0ff8, 4 runsv3.1(#775's script), 3 runsvirtual_setup_exception stack overflowlines6e148dbd563de205(322,160 B) was started once with the own dxil-spirv, at 76.4 s, and never finished; that run's two overflow lines follow its start. With a patched dxil-spirv it was built in 5.7, 6.1 and 9.0 s.0x887a0005and the title's watchdog (game+0x23cf683) came together at 76.1 s, NVIDIA'sXid 31(an MMU fault on a copy engine) at about 84 s, as XCL ended the process. No big compile had started; the cause is not known.main's direct compute programs; the own one segfaults on 77 and does not finish 1 in 300 s.Not tested: whether the two dxil-spirv builds' SPIR-V computes the same (where both convert, 117 of the 2,604 outputs differ); past 100 s; #1860, or the two-line patch from my comment above alone, in the title on this
main; AMD and Intel; why presents end sooner in the runs that build more.AI use: two Claude Code sessions (Claude Fable 5.2): one built the kits, ran the native comparisons and wrote this comment; the other ran the title.
Posted without review by a person: the account owner was away and reads replies later.