Skip to content

warm: 36 host pipelines die with "thread 'main' has overflowed its stack" (even with 64 MB), game then waits 10 s per frame and faces stay black (Linux, Wine + vkd3d-proton, RADV) #2621

Backlog

Description

@Pengoyoyo

What happens

leonida.exe warm makes 83,123 of 83,159 known pipelines, but 36 of them never finish: the worker process prints thread 'main' (36) has overflowed its stack and is then reported as hung for 180 s (in warm-bad.txt). The stack is not too small: 1 MB and 64 MB both overflow, so this looks like unbounded recursion. In the game the same pipelines stay under "SHADERS COMPILING: N LEFT" forever, and the title's draws that need them are missing (skin/faces are black in the intro cutscene).

Commit

cc0f662a7 (Launcher: the approximate temporal resolves, sun shadow masks and light clusters in the paired form)

System

Arch-based Linux (CachyOS), kernel 7.3, Ryzen 5 7600, Radeon RX 6750 XT (12 GB), Mesa 26.3.1 (RADV), Wine 11.23 (Wayland driver), Rust 1.98.1 (the pinned toolchain), leonida.exe cross-built on Linux with clang-cl/lld-link and an xwin SDK 10.0.26100 (profile diag, features diagnostics,mimalloc). vkd3d-proton: the pinned 3.1, and also a newer development build (vkd3d-1.1-5742-g2576c0b4a, 3.2.0 in its log); DXVK's dxgi.dll and Microsoft's d3dcompiler_47.dll in the prefix (see "Linux notes").

Where

A tool run by hand (leonida.exe warm, d3d12/ runtime)

Command and steps

  1. Play once so the runs record pipelines (LEONIDA_PIPELINE_BOOK=1), then run leonida.exe shaders <shaders.rpf> (25,689 shaders in the cache, 200 "do not translate").
  2. leonida.exe warm (no --used: it made 0 pipelines because early-pipelines.txt was empty; I believe that is because my runs ended by closing the window or killing Wine, not through the title's own exit, but I did not verify that).
    Result: 83123 made in 1163 s (5 have no host pipeline, 36 ended their process); ms each: median 2.2, p90 39.9, p99 219.4, most 2165.
  3. warm-bad.txt has 36 lines, all <key> hung for 180 s. Their numbers in known-pipelines.bin are close together (about 50,800 to 52,650 of 83,559), and their entries are all 51 bytes (the median entry is 637 bytes). I did not check the stage; I assume they are single-shader (probably compute) pipelines.
  4. One of them alone: leonida.exe warm --these <number> (I used a number from the list above). It prints at <number>, never made <number>, and stderr shows:
thread 'main' (36) has overflowed its stack
err:virtual:virtual_setup_exception stack overflow 2112 bytes addr 0x... stack 0x...

It happened every time I ran this one (several runs). I only ran this single pipeline by hand; the other 35 were all reported as hung for 180 s by the full warm run, I did not check each one separately.

Output / what I measured

  • After the message the main thread is a zombie (Z), all other threads sleep in futex_wait, CPU use is 0 %. warm waits 180 s and writes the pipeline to warm-bad.txt.
  • The faulting address is in Wine's ntdll.dll (offset about 0x2e130), not in leonida.exe, so it is the guard page being hit, not a symbol I could name.
  • Linking leonida.exe with /STACK:67108864 (checked in the PE header: SizeOfStackReserve 0x4000000, and the Wine log shows a 64 MB stack region) gives the same overflow. So it is a runaway recursion, not a larger-stack problem.
  • VKD3D_SHADER_DUMP_PATH writes the .dxil of that pipeline (about 360 KB) but no .spv, so it never gets past the DXIL to SPIR-V step (vkd3d-proton dxil-spirv) or an earlier step in Leonida's own code. I cannot tell which. I am not attaching the DXIL (game data).
  • RADV_DEBUG=llvm, ACO_DEBUG=noopt and RADV_DEBUG=nocache,nongg change nothing: it is not the driver's compiler.

In the game

play-linux.sh sets LEONIDA_PIPELINE_WAIT_MS=10000. With the 36 pipelines never finishing the game waits up to 10 s per frame (the window title shows about 0.1 FPS, "SHADERS COMPILING: 14 LEFT"). With LEONIDA_PIPELINE_WAIT_MS=0 the intro cutscene runs at 12 to 13 FPS ("6 LEFT" stays), but characters' faces are black and characters in dark scenes look like silhouettes. I assume that is the missing pipelines, but I did not prove it. I could not play past the cutscenes.

Activity

  1. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    That message is almost certainly stack depth in the compiler, not a pipeline your build lacks, and you can confirm or kill the theory in one re-run without changing anything.

    The test, on your machine:

    ulimit -s 65536        # 64 MB of stack for the process, instead of the usual 8 MB
    leonida.exe warm

    If the 36 finish, it is stack depth and the fix is a bigger stack (or an iterative path) in whatever thread compiles them. If the same 36 still die, it is not the stack and the theory is refuted - either way you learn something that no amount of log reading would tell you.

    Why I think it is that: a driver's shader compiler recurses over the program, and thread 'main' has overflowed its stack is exactly what that looks like when the recursion is deeper than the stack of that thread. #2588 (open, d3d12/crates/leonida-gpu/src/pipeline/make.rs) is the same problem in the pipeline worker threads: it gives each one 64 MB with a comment naming the cause - NVIDIA's compiler overflowing the default 2 MB on a world compute program and being refused as out of memory.

    Two differences worth keeping in mind, which is why I am not calling that pull request your fix:

    • GPU: pipeline workers get a 64 MB stack for the driver's compiler #2588 raises the stack of the threads it creates, named leonida-pipelines-<i>. Your message says thread 'main', so on the path you hit, the compile may be running on a thread that is not one of those;
    • your card is RADV, and the NVIDIA comment describes a different compiler with the same failure mode.

    So the useful answer for the issue is whether the stack is the cause - the ulimit run - and then whether the warm path compiles on a worker or on the main thread. If it is the main thread, #2588 is the right shape of fix but not the whole one, and that is worth saying in its thread with your numbers.

    One thing I would not paste into this thread: the names of the 36 programs. They are game-derived; the count and the error line are enough.

    Written with an AI assistant.

  2. merzleckeier commented on Nov 29, 2026

    @merzleckeier
    Contributor

    I prepared a diagnostic follow-up on current main. The warm supervisor now reads the child's Rust stack-overflow diagnostic, terminates that child, and records compiler process stack overflow in warm-bad.txt. A silent child still takes the ordinary no-progress timeout. Pipelines already reported as completed are retained. Tested commit 3098f5ffd

    MEASURED. Synthetic subprocess A/B. The old supervisor reported a timeout for a child that emitted the overflow line and stayed alive. The new supervisor reported the overflow and ended the child before the watchdog deadline. Removing only the early termination failed that regression test. The full Windows x64 CLI test binary under Wine 11.22 passed 36/36 on the base and 39/39 with the change.

    The compiler failure itself still needs diagnosis. GitHub currently blocks an upstream PR from this account at its open-PR limit, so I am sharing the tested branch here. Coordination claim

    Synthetic fixtures only. AI-assisted with OpenAI Codex.

  3. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    I have a free pull-request slot, so I can open that branch for you if you point me at it.

    The limit lifted on this account after two of my pull requests were accepted into main - the same wall you hit. So if you give me the fork and branch name (or just the head SHA and the repository it lives in), I will open the pull request with your authorship in the body and your coordination claim quoted, and I will run its tests here before doing it so the body carries a second machine's result rather than only yours.

    I looked through merzleckeier/mandy's branches and did not want to guess: the closest names I can see are codex/windows-crash-stack-utf8 and codex/pr2275-gpu-copy-during-warmup, and neither is obviously "the warm supervisor reads the child's overflow line". Opening the wrong branch under your name would be worse than asking.

    Two things I would add to the body from my side, because they are what I have measured on #2621:

    • the reporter's failure is a child stack overflow (thread 'main' has overflowed its stack) while the supervisor reports a timeout - your change makes the supervisor say which of the two happened, which is exactly the distinction I could not make from the log when I answered the issue;
    • your synthetic A/B (old supervisor: timeout; new: overflow reported and child ended before the deadline; removing only the early termination fails the regression) is the kind of evidence that makes a supervisor change reviewable.

    And the part I would keep explicit in the body: the compiler failure itself is still undiagnosed - this makes the failure legible, it does not fix the 36 pipelines that die.

    Written with an AI assistant.

  4. fiestorra commented on Nov 29, 2026

    @fiestorra
    Contributor

    Opened for you, at #2656: #2656

    GitHub refused a cross-fork head (--head merzleckeier:… -> "must be a collaborator"), so I pushed your branch to my fork unchanged and opened it from there:

    git fetch https://github.com/merzleckeier/mandy.git fix/warm-stack-overflow-diagnostic
    git push  <my fork> refs/remotes/mz/warm:refs/heads/mw/warm-stack-overflow-diagnostic
    

    3098f5ffd keeps you as the commit author (merzleckeier <362449027+…>), and the body says in its first line that the branch, the commit and every line are yours and that I am only the slot. If you would rather have it under your own name, say so and I will close this one so you can open it the moment your limit frees - no hurt feelings, and no duplicate left behind.

    What the body says about the change, so it is not only my summary of it: it reads the child's … has overflowed its stack line, ends the child, and reports "compiler process stack overflow" instead of waiting out the watchdog and calling it a timeout; the regression test lives inline in warm.rs (#[cfg(test)]) with your synthetic "overflow" mode; and it states that this makes the failure legible rather than fixing the 36 pipelines.

    What it says about evidence, so the split is honest: your numbers are quoted as yours (old supervisor: timeout; new: overflow reported and child ended before the deadline; removing only the early termination fails the regression; 36/36 base and 39/39 with the change on the Windows x64 CLI binary under Wine 11.22), and it records that I could not re-run any of it - no cargo on this machine, so d3d12/ does not build here. I am not going to sign a green run I did not do, and your measurement deserved to appear as a measurement rather than as a claim by a stranger.

    One thing worth doing before review, since you have the toolchain: the Cargo dependency of apps/leonida was not touched, so if the change needs a new dev-dependency for the subprocess fixture, that would be where a reviewer looks first.

    Written with an AI assistant.

  5. zmasi commented on Nov 30, 2026

    @zmasi
    Contributor

    Opened #2686 (D3D12-LINUX-WARM-DXIL-RECURSION): in VKD3D-Proton 3.1's dxil-spirv (8b48f0e), CFGStructurizer::flatten_subgroup_shuffles() runs recompute_cfg() on shaders with subgroup shuffles before rewrite_multiple_back_edges(), violating !entry.succ_back_edge || entry.succ_back_edge == succ (cfg_structurizer.cpp:3452, HansKristian-Work/dxil-spirv#380) whenever a conditional branch block targets two distinct loop headers — causing unbounded C++ recursion in release builds regardless of /STACK size. #2686 splits dual-back-edge conditional latches and prevents empty-latch folding from re-forming them during DXIL preparation (verified synthetically on Wine + VKD3D-Proton 3.1 + RADV gfx906, RTX 3090, and WARP).

    AI-assisted.

  6. Apersonsnight commented on Dec 1, 2026

    @Apersonsnight

    Environment

    • Windows 11 21H2, Ryzen 5 2600 (6C/12T), 2×8 GB DDR4-2400, RX 6700 XT 12 GB (RDNA2), Adrenalin 26.7.1 / 32.0.21045.1000
    • main downloaded as a zip on 2026-12-01 ~17:30 UTC, built with cargo build --profile diag (Rust + VS Build Tools); no local changes except the patch at the bottom
    • scripts\play-d3d12.ps1 -SeriesS -NoFrameGen -Log, 1080p, LEONIDA_UPSCALE=stretch (no DLSS)
    • A save imported from a working install; the title boots and reaches the world on its own, so this is not a save problem
    • 83,551–88,556 title pipelines known from earlier runs, 19,099–19,100 shaders, pipeline workers workers=8

    What happens

    One compute program never gets a host pipeline on this card:

    compute 39f0e9aeb156a61c   (pipeline key 75ef56014488cd3b103d220dca5d57dd, shader 71,816 bytes, user_data=2 samplers=2)
    

    It is translated, first bound at the world's first frames, and the make never finishes. In the precompile stage that runs before the game, one process ends:

    83,551 pipelines known, 0 made before (ecdc52e7e2d9edd0), 0 bad; 1,674 to make, 8 processes
    1673 made in 374 s (0 have no host pipeline, 1 ended their process); ms each: median 16.2, p90 7712.4, p99 11515.5, most 16426, sum 2630 s
    

    1 ended their process is the wording #2621 uses for its 36 pipelines that never finish (there: thread 'main' has overflowed its stack, diagnosed in that thread as unbounded recursion in the CFG structurizer, with /STACK:64MB not helping). My guess is that this is the same failure on the Windows driver path — a world compute program whose compile does not return — and that the pipeline left over from that process is the one that is never made in the game either. I have not proven that the two lines are the same pipeline; what I can show is that from then on the game asks for one make and never gets it.

    Evidence

    Three consecutive runs, same install, same save. Times UTC.

    1. play-1202-024035, no skip list

    18:40:39.299  pipeline: shader translated stage="compute" hash=39f0e9aeb156a61c masked=false user_data=2 samplers=2
    18:41:46.062  pipeline: first bind pipeline=0x1b506591b80 frame=2790 stage="compute" size=71816 hash=39f0e9aeb156a61c
    18:42:59.942  pipeline::make: a pipeline not made within its wait: its draws are dropped until it is
                  (LEONIDA_PIPELINE_WAIT_ONCE=0: waited for every frame) shaders=[compute 39f0e9aeb156a61c] ms=10000
    18:43:02.199  ERROR host: when the host device went: the submitting thread was between submissions
                  (6 submissions of ours started and not yet seen finished), of 0 lists, for 0.3 ms;
                  pipeline library: make of 75ef56014488cd3b103d220dca5d57dd [compute 39f0e9aeb156a61c]
    

    76 s from first bind to the end, and the pipeline library line still names that pipeline as being made.

    2. play-1202-025044, LEONIDA_SKIP_PIPELINES listing 39f0e9aeb156a61c, LEONIDA_RT_RESOLVE=0

    18:51:45.809  pipeline: first bind pipeline=0x1c182141780 frame=2362 stage="compute" size=71816 hash=39f0e9aeb156a61c
    18:51:56.651  pipeline::make: a pipeline not made within its wait ... shaders=[compute 39f0e9aeb156a61c] ms=10000
    18:51:57.110  pipeline::make: (same, again) ms=10000
    18:52:05.758  ERROR host: when the host device went: ... (3 submissions ...);
                  pipeline library: make of 75ef56014488cd3b103d220dca5d57dd [compute 39f0e9aeb156a61c]
    

    The draw path did skip it; the make was still running when the run ended.

    3. play-1202-025716, same skip list, with the patch below

    18:58:14.756  host: dropped 0.1/frame without a host pipeline: skipped shader 39f0e9aeb156a61c
    18:58:20.584  host: dropped 1.0/frame without a host pipeline: skipped shader 39f0e9aeb156a61c
    18:58:25.054  ERROR host: when the host device went: the submitting thread was preparing a submission
                  (14 submissions of ours started and not yet seen finished), of 3 lists, for 0.7 ms;
                  pipeline library: no call running
    

    75ef56014488cd3b103d220dca5d57dd does not appear anywhere in this log, and the run goes on past the point where the two above ended.

    Why the flag does not help

    pipeline.rs asks the skip list in is_skipped(), which the draw, dispatch and indirect-execution paths call. Pipeline creation goes through pipeline/make.rs:

    fn left_out(shaders: &[Arc<Shader>]) -> Option<&'static str> {
        // LEONIDA_RT_RESOLVE / CS_RaytracingResolve by entry name,
        // LEONIDA_ACTIVATE_RAYS, LEONIDA_SKIP_RT_SHADOW (RT_SHADOW_NAMES)

    left_out looks only at entry names, never at LEONIDA_SKIP_PIPELINES. It is computed once in Pending::new (make.rs:172), and both the precompile path (known.rs) and the first-use path queue through Pending, so a check there covers both.

    So the flag drops the draws and dispatches, as its documentation says, and the pipeline is still made — and making this one is what costs the run.

    Patch I tried (15 lines in pipeline/make.rs, at the top of left_out)

    fn left_out(shaders: &[Arc<Shader>]) -> Option<&'static str> {
        static SKIP_HASHES: OnceLock<std::collections::HashSet<String>> = OnceLock::new();
        let skip = SKIP_HASHES.get_or_init(|| {
            std::env::var("LEONIDA_SKIP_PIPELINES")
                .unwrap_or_default()
                .split(',')
                .map(str::trim)
                .filter(|h| h.len() == 16 && h.bytes().all(|b| b.is_ascii_hexdigit()))
                .map(|h| h.to_ascii_lowercase())
                .collect()
        });
        if !skip.is_empty() && shaders.iter().any(|s| skip.contains(&s.hash)) {
            return Some("shader in LEONIDA_SKIP_PIPELINES");
        }
        static SKIP_RT_RESOLVE: OnceLock<bool> = OnceLock::new();
        // ... unchanged below

    pipeline.rs already has parse_skip_hashes doing the same validation, so the clean version probably shares it instead of parsing twice.

    With this, run 3 gets past the old point for the first time on this machine.

    What still ends the run (separate, in case it is related)

    After the patch it reaches the open world and dies 60–75 s in, at the world's first frames:

    19:00:49.026  2.0 fps, 490.4 ms/frame, 1166 draws/frame, dropped 493 without a host pipeline
    19:00:54.565  5.6 fps, 179.9 ms/frame, 11969 draws/frame, dropped 190 ...
    19:00:58.7    ERROR host: no descriptor heap for depth plane pass
                  error=GPU 设备实例已经暂停。 (0x887A0005) count=1
    19:00:58.702  ERROR host: when the host device went: the submitting thread was preparing a submission
                  (3 submissions of ours started and not yet seen finished), of 2 lists, for 0.6 ms;
                  pipeline library: no call running
    

    Immediately before it, a run of depth textures getting UAV views:

    descriptor::host: unordered access view of a depth texture resource=0x1858a6a6600 view=Some([56, 5, 0, 0, 3, 0, ...])
    resource: depth texture with unordered access ... ResourceDesc { dimension: 3, ..., width: 768, height: 768, ... }
    

    Same phase with LEONIDA_RT_RESOLVE=0 as without (frame 2039 vs 2528, 3 outstanding submissions vs 14), with 8,209 MB of an 11,474 MB budget and 3,790 MB shared at that point. It reads like a fixed point in the world-entry work rather than a queue or VRAM problem. Full logs available; happy to file it separately if it is not something you already know about.

    Also seen, may be known

    • The host pipeline library rarely loads its entries here. In run 1, 78 pipelines were made and 78 of those carry (the library did not load it: 参数错误。 (0x80070057)); 4 loaded. Runs 2 and 3: 7 made, 7 failed to load, 72–73 loaded. Is a library saved by an earlier run expected to load all its entries, or does a 0x80070057 from LoadGraphicsPipeline give up on that key for the rest of the run?
    • LEONIDA_PIPELINE_WORKERS=1 set with $env: before launching does not change pipeline workers workers=8; I now use -More @{...}, so this may be the script's own setting winning. Mentioning it only in case it is not.
    • If GPU: pipeline workers get a 64 MB stack for the driver's compiler #2588 ("pipeline workers get a 64 MB stack for the driver's compiler", open) is the right shape of fix for this, the workers here are spawned with std::thread::Builder::new().name(...) and no stack_size, so they get the default; this compute program is 71,816 bytes against the "world compute program" case in that PR's comment.

    Ask

    Apply the skip list when a pipeline is made (or let is_skipped's pipelines never reach Pending), so LEONIDA_SKIP_PIPELINES means "not compiled" as well as "not drawn". On a cold cache on this card that is the difference between the same make running for the whole run and a run that goes on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions