Skip to content

warm: report compiler process stack overflows (merzleckeier's branch, opened from a free slot) - #2656

Open
fiestorra wants to merge 2 commits into
ProjectLeonida:mainfrom
fiestorra:mw/warm-stack-overflow-diagnostic
Open

fiestorra wants to merge 2 commits into
ProjectLeonida:mainfrom
fiestorra:mw/warm-stack-overflow-diagnostic

Conversation

@fiestorra

@fiestorra fiestorra commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Opening this on behalf of merzleckeier, whose account is blocked from opening an upstream pull request at its own open-PR limit (#2621). The branch, the commit and every line of the change are theirs: fix/warm-stack-overflow-diagnostic, 02de3303a ("warm: report compiler process stack overflows", rebased from their 3098f5ffd onto current main). If you would rather open it yourself, say so and I will close this one.

What it does

d3d12/apps/leonida/src/warm.rs, one file, +113/-9: the leonida warm subprocess supervisor reads the child's stderr for Rust's stack-overflow diagnostic (… has overflowed its stack) and, when it sees it, ends the child and reports "compiler process stack overflow" instead of waiting out the no-progress watchdog and calling it a timeout.

Why it matters for #2621

The reporter's log says thread 'main' has overflowed its stack for 36 of 83,159 pipelines, while the supervisor reports a timeout. Those are two different failures, and a log that cannot tell them apart sends the next reader after the wrong one - which is what happened to me when I first answered the issue.

It also matters that this change is not a fix for the pipelines: it makes the failure legible. The compiler-side overflow is still undiagnosed.

Evidence, from the author

Their measurements, quoted rather than repeated as mine: synthetic subprocess A/B where the old supervisor reported a timeout for a child that emitted the overflow line and stayed alive, and the new one reported the overflow and ended the child before the watchdog deadline; removing only the early termination made that regression test fail. The Windows x64 CLI test binary under Wine 11.22 passed 36/36 on the base and 39/39 with the change. The branch adds its test inline in warm.rs (#[cfg(test)]), so the regression lives with the code.

What I checked here, and what I could not

git merge-tree origin/main refs/pull/…/head   -> clean against 452d1d1b6
one commit, one file, test module included in the diff

Not verified by me: the Rust tests themselves - this machine has no cargo, so d3d12/ does not build here, and I am not going to claim a green run I did not do. That is also why the body quotes the author's numbers instead of replacing them.

AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. Where and on what: the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it.

Written with an AI assistant.

@fiestorra

Copy link
Copy Markdown
Contributor Author

One thing a reviewer of this pull request should know: it will have no Rust test signal until #2648 lands.

The checks on it right now are the general ones (change-scope, no-game-data). No workflow in .github/workflows builds or tests d3d12/ today - that is the gap #2648 fills ("D3D12 runtime", windows-latest, cargo test --workspace --exclude xtask) - so the only test evidence for a change to warm.rs is the author's own run:

36/36 on the base and 39/39 with the change, Windows x64 CLI test binary under Wine 11.22

which is a good measurement and belongs to merzleckeier, not to CI. Nobody approving this should believe the green tick covers it.

What that means practically:

I verified what I could without cargo: the branch merges cleanly with main 452d1d1b6, it is one commit and one file, and the regression test is inline in warm.rs under #[cfg(test)] rather than missing.

Written with an AI assistant.

@merzleckeier

Copy link
Copy Markdown
Contributor

Thanks for opening this and crediting the branch. Let's keep the review here.

MEASURED. I rebuilt the Win64 CLI test binary from this PR's exact GitHub merge a0e6accb8 (3098f5ffd into 452d1d1b6). Under Wine 11.22 on CachyOS, all 39 tests passed. The synthetic overflow case reported the error before the watchdog deadline, and the silent-child control still reported a timeout. Both cases verified that the supervisor retained the completed pipeline record.

The run used CPU-only fixtures. Hosted native Windows Rust coverage is pending in #2648. AI-assisted with OpenAI Codex.

@fiestorra

Copy link
Copy Markdown
Contributor Author

The semantic-tests failure on this pull request is inherited from main, not from the change. main (b8bd37111) still has the interp oracle failing, so a branch cut from it inherits that job failing whatever it contains:

main:  tests/semantic/test_interp_computed_ij_fallback.py  2 failed, 7 passed

#2633 carries the fix and is green on its own. Two ways to clear it here, and I did not take either because this branch is not mine:

The reason it is worth saying out loud: nothing in warm.rs can affect a translator test, and a red tick that is not about the diff is the kind of thing that gets a pull request closed by someone skimming.

Still true: #2656 has no Rust test signal until #2648 lands, so the only evidence for the change is your measurement (36/36 base, 39/39 with it, Wine 11.22).

Written with an AI assistant.

@fiestorra
fiestorra force-pushed the mw/warm-stack-overflow-diagnostic branch from 3098f5f to 02de330 Compare November 30, 2026 11:42
@fiestorra

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (d367675c7) after the semantic-tests failure. Head is now 02de3303a, one commit, and the test that failed passes here.

What was failing and why:

semantic-tests (ubuntu-latest): FAILED: test_interp_computed_ij_fallback (exit code 1)
  "529 files, 6526 tests, 1 files failed"

This branch does not touch that test - its only file is d3d12/apps/leonida/src/warm.rs. The test came from its base, which is 216 commits behind: c717967d0 ("test(semantic): align computed-I/J f16 interp oracle with toward-zero p2 narrow") is not an ancestor of the merge base, so the branch ran the pre-fix oracle.

After the rebase, on this machine:

python3 -m pytest tests/semantic/test_interp_computed_ij_fallback.py -q
9 passed, 13 subtests passed in 1.13s

What the rebase changed: nothing in this branch's own code - the one commit (warm: report compiler process stack overflows, 113 insertions, 9 deletions in warm.rs) applied cleanly; the base moved forward and the inherited test is the corrected one.

What I did not verify: the Rust build. There is no cargo on this machine, so warm.rs has not been compiled here - the semantic-tests job and the Rust CI are the ones that will say.

Why I did it rather than asking: the failure was not this branch's, it was its age, and a rebase is the whole fix. If you would rather keep the head you had (3098f5ffd), say so and I will put it back - the previous commit is unchanged and pushed nowhere else.

Written with an AI assistant.

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

RUN - native Windows red/green (Verified by OreoFR) - Intel Core Ultra 7 155H, Windows 11 Pro 10.0.26300, CPU only.

  • Base: main afb511541; green = main + this PR at 02de3303a (git merge --no-ff, clean, merge tree 39b48b4c7).
  • Toolchain: rustc 1.98.1 (48a229cea 2026-09-01), x86_64-pc-windows-msvc, pinned by d3d12/rust-toolchain.toml. Native Windows, not Wine.
  • Command (from d3d12/, one worktree and one target/ per arm): cargo test -p leonida. No feature flags or --ignored are needed. The new tests are plain #[test], and the fixture re-runs the test binary itself.

Result: PASS (green). A strict red cannot be built, so I ran a substitute red, described below.

Arm leonida bin unit tests tests/agility.rs tests/census.rs
main afb511541 39 passed, 0 failed 2/2 2/2
strict red (main code + the PR's test module) does not compile - -
red variant (PR code, overflow detection disabled) 41 passed, 1 failed not run (cargo stops at the first failing target) not run
green (main + PR) 42 passed, 0 failed (2.52 s) 2/2 2/2
  • New tests: warm::tests::reports_stack_overflow_before_waiting_for_the_timeout, warm::tests::silent_child_still_times_out, and the helper warm::tests::warm_child_fixture (a no-op unless LEONIDA_TEST_WARM_CHILD is set). All three pass natively.
  • Strict red is impossible. The tests call collect_child, which this PR adds, so with main's code cargo test stops with error[E0425]: cannot find function 'collect_child' in this scope (warm.rs:264).
  • Red variant: this is the PR's code with only the overflow branch of the stderr reader changed. It does not set the flag and does not kill the child; it keeps draining. reports_stack_overflow_before_waiting_for_the_timeout then fails at warm.rs:320: left (1, Some("hung for 8 s")), right (1, Some("compiler process stack overflow")). The other two tests still pass. So on native Windows the new test catches the loss of the early detection, as the author found under Wine.
  • Green: the overflow case is reported before the 8 s watchdog deadline, and the silent child still reports hung for 2 s. Both cases keep the one pipeline record that was finished.
  • Counts: main is now at 39 unit tests, compared with merzleckeier's 36 on the older base. The PR adds exactly 3 (39 -> 42). No test process was left running after the arms finished.

Not covered:

  • I did not run a real compiler-process stack overflow. The fixture prints the diagnostic line itself and stays alive.
  • No leonida warm run against a pipeline cache, and no game run.
  • I did not check the 4096-byte line cap against real driver stderr output. The fixture covers an 8192-byte line before the diagnostic line.

This run was AI-assisted (Claude Code, oreofr-agent).

@MoonEyes

Copy link
Copy Markdown
Collaborator

RUN · VERIFY-2656-RTX4060 · by MoonEyes (another person than the author) on head 02de3303a, with #2674 (be2a1ab0f) and #2656 (02de3303a) merged into main 8f41d7d01. Windows 11 Pro 26300, RTX 4060 8 GB, -SeriesS -FrameGen 2, diag build.

  • cargo test -p leonida-pipeline --locked: 8 passed; cargo test -p leonida --locked: 46 passed; 0 failed.
  • Game: two runs of 480 s, the person walking in the world from 345 s. The first after a full translation (846 s before the title, little of it steady) is not counted; the second, warm: the steady world after 151 s, about 450 s of it, about 52 m walked, no device loss, no unhandled exception, the process alive at the end. PASS for the gate of 300 s. The picture was not looked at; no frame rate is claimed.

AI-assisted (Claude Code).

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026
`main` gave `child` a store (`--store`, the list in a file because thousands of
numbers do not fit a command line) and made its stderr null. This branch reads the
child's stderr to notice a stack overflow, so the resolution keeps main's signature
and the store, and keeps stderr piped.

A null stderr matters beyond the lost diagnostics: `collect_child` takes
`(process.stdout, process.stderr)` as a pair and returns early if either is absent,
so with main's `stderr(Stdio::null())` this branch would have reported nothing at all
rather than everything.
@fiestorra

Copy link
Copy Markdown
Contributor Author

done: rebased onto today's main, which is where it was conflicting, and the resolution is not the obvious one - taking main's stderr(Stdio::null()) would have made this branch report nothing at all.

main ad7c62edb, one commit, warm.rs only. git merge origin/main conflicted in child, because main gave it a store:

// main's version
fn child(these: &[usize], store: Option<&Path>, mut each: impl FnMut(usize, f64, bool))
    ...
    command.stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn()

The stderr is the whole point of this branch, and not only for the diagnostics: collect_child starts with

    let (Some(out), Some(err)) = (process.stdout.take(), process.stderr.take()) else {
        return (total, None);
    };

so with stderr(Stdio::null()) there is no process.stderr to take and the function returns before reading anything. The merge keeps main's signature and the --store argument and keeps stderr piped, with a comment saying why.

Verified on the merged tree:

cargo check -p leonida     exit 0
cargo test  -p leonida     exit 0
  ok. 45 passed; 0 failed
  ok. 2 passed;  0 failed
  ok. 2 passed;  0 failed
  ok. 1 passed;  0 failed

The one warning in that build is unused doc comment at crates/leonida-shader/src/emit/lower.rs:1716, which is not this branch and not this file.

What I could not test: the behaviour the branch is for - a compiler child hitting its stack guard. That needs the title and a driver that overflows; what I verified is that the merged code compiles and its unit tests pass.

AI-assisted: yes - DeepSeek v4.1 (flash), which found the conflict by polling its own pull requests rather than by being told.

Written with an AI assistant.

@github-actions github-actions Bot removed the needs rebase Conflicts with the base branch: rebase it on main label Dec 1, 2026

@KelboLive KelboLive left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 2a6dfff4f. The claim matches the code: stderr is piped instead of null (warm.rs:353-359), collect_child matches thread '…' has overflowed its stack, sets the flag and kills the child (:400-407), and the overflow is preferred over the status/hung result once the reader returns (:434-436), so the outer loop marks the pipeline bad instead of waiting out LONGEST. cargo test -p leonida is 50/50 here.

The regression test genuinely guards the early exit: flipping only the matcher suffix makes it fail with (1, Some("hung for 8 s")) against the expected compiler process stack overflow. git merge-tree --write-tree origin/main pr/2656 is clean (9d4a7fd80).

One nit: child() no longer uses each directly, so mut each at warm.rs:335 now warns (variable does not need to be mutable) — drop the mut. The synthetic-diagnostic caveat (the test feeds a crafted line rather than a real overflow) is already stated in the body, and the base being 216 commits behind is harmless here: warm.rs moved only once since then (the count % 1000 → is_multiple_of line), so the logic reviewed is the logic that will land.

@merzleckeier

Copy link
Copy Markdown
Contributor

I followed up on the warm.rs review at 2a6dfff4 + cd0c52fcf. The Win64 app test build reproduced the unused_mut warning in child. Removing mut from child's each parameter removes that warning. The binding in collect_child stays mutable, where the callback is called.

I also added a local negative control for stderr matching. A synthetic child prints one line with a warning prefix before the overflow phrase and one with extra text after it, then stays alive. The supervisor still reports hung for 2 s for that child. The exact diagnostic still reports compiler process stack overflow before the eight-second watchdog, and the quiet control still times out. All four warm tests passed, including the fixture.

MEASURED with the Win64 MSVC target under Wine 11.22, using synthetic subprocesses. No actual stack overflow was required. AI-assisted (Codex).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants