D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC: never panic on closed stderr in game_actions and watch #2945

Open
bobcatchris wants to merge 2 commits from upstream-pr/2945 into main
bobcatchris commented 2026-12-01 20:28:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T20:28:03Z.


Summary

Claimed in the coordination issue as: D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7324371405), following @KelboLive's review note on #2840.

Replaces panicking eprintln! calls on background/hook paths in apps/leonida with fallible let _ = writeln!(std::io::stderr(), ...):

  1. d3d12/apps/leonida/src/game_actions.rs:
    • log / log_to: writes %TEMP%\leonida-actions\log.txt first and writes to stderr with let _ = writeln!(std::io::stderr(), ...) so a closed stderr pipe at shutdown never panics the title frame hook or leonida-game-actions thread and never loses the log.txt entry.
    • deferred (unsafe extern "win64" fn): replaces the eprintln! in the catch_unwind error handler (which sat outside catch_unwind on an extern "win64" callback, where a stderr panic would abort across FFI) with log(...), keeping it panic-free and also recording the failure in log.txt.
  2. d3d12/apps/leonida/src/run.rs:
    • Extracts report_watch (under #[cfg(all(windows, feature = "diagnostics"))], placed below watch so tools/d3d12_switches.py keeps LEONIDA_WATCH's existing doc summary verbatim) using let _ = writeln!(std::io::stderr(), ...) so the detached LEONIDA_WATCH polling thread does not panic if stderr is closed.

Tests & Verification

  • Hardware / OS: Windows 11, Rust 1.98.1, no game files or GPU needed.
  • Red -> Green:
    • With eprintln! restored in log_to and report_watch, both new subprocess closed-stderr tests fail (RED_EXIT=101, child panics on closed stderr pipe):
      • game_actions::tests::log_writes_file_and_does_not_panic_when_stderr_pipe_is_closed
      • run::tests::watch_report_does_not_panic_when_stderr_pipe_is_closed
    • With the fix applied:
      • cargo test --locked -p leonida --bin leonida --features diagnostics -- run::tests game_actions::tests: 11 passed, 0 failed.
      • cargo test --locked -p leonida --bin leonida: 43 passed, 0 failed.
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.
  • python -I scripts/check_no_game_data.py d3d12/apps/leonida/src/game_actions.rs d3d12/apps/leonida/src/run.rs: exit 0.

AI Assistance

AI-assisted using Gemini 4 Neon, including a separate read-only independent review pass (which caught a d3d12_switches.py doc-comment shadowing risk in run.rs before opening the PR).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5593935056 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T20:28:03Z. --- ## Summary Claimed in the coordination issue as: `D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7324371405), following `@KelboLive`'s review note on #2840. Replaces panicking `eprintln!` calls on background/hook paths in `apps/leonida` with fallible `let _ = writeln!(std::io::stderr(), ...)`: 1. `d3d12/apps/leonida/src/game_actions.rs`: - `log` / `log_to`: writes `%TEMP%\leonida-actions\log.txt` **first** and writes to stderr with `let _ = writeln!(std::io::stderr(), ...)` so a closed stderr pipe at shutdown never panics the title frame hook or `leonida-game-actions` thread and never loses the `log.txt` entry. - `deferred` (`unsafe extern "win64" fn`): replaces the `eprintln!` in the `catch_unwind` error handler (which sat outside `catch_unwind` on an `extern "win64"` callback, where a stderr panic would abort across FFI) with `log(...)`, keeping it panic-free and also recording the failure in `log.txt`. 2. `d3d12/apps/leonida/src/run.rs`: - Extracts `report_watch` (under `#[cfg(all(windows, feature = "diagnostics"))]`, placed below `watch` so `tools/d3d12_switches.py` keeps `LEONIDA_WATCH`'s existing doc summary verbatim) using `let _ = writeln!(std::io::stderr(), ...)` so the detached `LEONIDA_WATCH` polling thread does not panic if stderr is closed. ## Tests & Verification - **Hardware / OS**: Windows 11, Rust 1.98.1, no game files or GPU needed. - **Red -> Green**: - With `eprintln!` restored in `log_to` and `report_watch`, both new subprocess closed-stderr tests fail (`RED_EXIT=101`, child panics on closed stderr pipe): - `game_actions::tests::log_writes_file_and_does_not_panic_when_stderr_pipe_is_closed` - `run::tests::watch_report_does_not_panic_when_stderr_pipe_is_closed` - With the fix applied: - `cargo test --locked -p leonida --bin leonida --features diagnostics -- run::tests game_actions::tests`: **11 passed, 0 failed**. - `cargo test --locked -p leonida --bin leonida`: **43 passed, 0 failed**. - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: exit 0. - `python -I scripts/check_no_game_data.py d3d12/apps/leonida/src/game_actions.rs d3d12/apps/leonida/src/run.rs`: exit 0. ## AI Assistance AI-assisted using Gemini 4 Neon, including a separate read-only independent review pass (which caught a `d3d12_switches.py` doc-comment shadowing risk in `run.rs` before opening the PR).
merzleckeier commented 2026-12-01 20:51:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T20:51:16Z.


Independent closed-stderr check for the launcher helpers on 8dc38550 merged into 1e3e316c. Under Win64 Wine 11.22, the two unmodified closed-pipe subprocess tests passed 3/3 each here and 3/3 each with #2946 and #2947 applied on the same base. The child checks that stderr really rejects a write. The action fixture verifies both file lines, and the watch fixture invokes the helper with three synthetic values.

Restoring the old eprintln! placement in log_to and the old write in report_watch on the combined tree made each of the same fixtures exit 101 in all three repeats. The game_actions::tests and run::tests groups passed 11/11 on both unmodified PR trees. The title watch worker and deferred game callback were outside this run.

MEASURED with synthetic inputs, OpenAI Codex and a separate read-only review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7325373126 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7325373126). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T20:51:16Z. --- Independent closed-stderr check for the launcher helpers on `8dc38550` merged into `1e3e316c`. Under Win64 Wine 11.22, the two unmodified closed-pipe subprocess tests passed 3/3 each here and 3/3 each with #2946 and #2947 applied on the same base. The child checks that stderr really rejects a write. The action fixture verifies both file lines, and the watch fixture invokes the helper with three synthetic values. Restoring the old `eprintln!` placement in `log_to` and the old write in `report_watch` on the combined tree made each of the same fixtures exit 101 in all three repeats. The `game_actions::tests` and `run::tests` groups passed 11/11 on both unmodified PR trees. The title watch worker and deferred game callback were outside this run. MEASURED with synthetic inputs, OpenAI Codex and a separate read-only review.
KelboLive commented 2026-12-01 21:28:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T21:28:41Z.

Review: COMMENTED


Reviewed at 8dc3855. log_to writing the file sink before the fallible stderr write is the right order, and restoring eprintln! makes the child test exit 101, so the guard is real. The FFI path is safe too: log sits outside catch_unwind, but no longer panics, so the extern "win64" callback cannot unwind across the boundary. No diagnostic regression — game actions still reach log.txt (the deferred failure now gains a file entry too), and watch output is identical on a valid stderr.

Tests are 11/11 under diagnostics and 43/43 default, switches.md check passes, and the merge is clean against current main.

On the duplication with #2946/#2947: three PRs hand-rolling let _ = writeln!(stderr, ...) across four files is tolerable for one-line call sites, and a shared helper would add a leonida_core API for little gain — worth revisiting only if more detached diagnostic paths adopt it. Note the other detached paths still on eprintln! (player.rs, player_find.rs, native_scan.rs, agility.rs), which is outside this PR's claim but the natural next follow-up.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6140477188 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#pullrequestreview-6140477188). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T21:28:41Z. **Review:** COMMENTED --- Reviewed at `8dc3855`. `log_to` writing the file sink before the fallible stderr write is the right order, and restoring `eprintln!` makes the child test exit 101, so the guard is real. The FFI path is safe too: `log` sits outside `catch_unwind`, but no longer panics, so the `extern "win64"` callback cannot unwind across the boundary. No diagnostic regression — game actions still reach `log.txt` (the deferred failure now gains a file entry too), and watch output is identical on a valid stderr. Tests are 11/11 under diagnostics and 43/43 default, `switches.md` check passes, and the merge is clean against current main. On the duplication with #2946/#2947: three PRs hand-rolling `let _ = writeln!(stderr, ...)` across four files is tolerable for one-line call sites, and a shared helper would add a `leonida_core` API for little gain — worth revisiting only if more detached diagnostic paths adopt it. Note the other detached paths still on `eprintln!` (`player.rs`, `player_find.rs`, `native_scan.rs`, `agility.rs`), which is outside this PR's claim but the natural next follow-up.
bobcatchris commented 2026-12-01 22:25:30 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T22:25:30Z.


Updated in fast-forward commit d2c08c14f so watch_report_does_not_panic_when_stderr_pipe_is_closed also compiles and runs under default cargo test --workspace --exclude xtask --locked (.github/workflows/d3d12.yml:76), matching profile/stacks in #2947 (#[cfg(all(windows, any(feature = "diagnostics", test)))] on report_watch).

Verified locally:

  • cargo clippy --locked --no-deps -p leonida --all-targets -- -D warnings: 0 warnings, exit 0.
  • cargo build --locked -p leonida --all-targets: 0 warnings, exit 0.
  • cargo test --locked -p leonida --bin leonida -- run::tests game_actions::tests: 11 passed, 0 failed.
  • cargo test --locked -p leonida --bin leonida --features diagnostics -- run::tests game_actions::tests: 11 passed, 0 failed.

AI-assisted: Gemini 4 Neon

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7327827836 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7327827836). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T22:25:30Z. --- Updated in fast-forward commit `d2c08c14f` so `watch_report_does_not_panic_when_stderr_pipe_is_closed` also compiles and runs under default `cargo test --workspace --exclude xtask --locked` (`.github/workflows/d3d12.yml:76`), matching `profile`/`stacks` in #2947 (`#[cfg(all(windows, any(feature = "diagnostics", test)))]` on `report_watch`). Verified locally: - `cargo clippy --locked --no-deps -p leonida --all-targets -- -D warnings`: 0 warnings, exit 0. - `cargo build --locked -p leonida --all-targets`: 0 warnings, exit 0. - `cargo test --locked -p leonida --bin leonida -- run::tests game_actions::tests`: **11 passed, 0 failed**. - `cargo test --locked -p leonida --bin leonida --features diagnostics -- run::tests game_actions::tests`: **11 passed, 0 failed**. AI-assisted: Gemini 4 Neon
imShangLi commented 2026-12-02 05:33:41 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T05:33:41Z.


VERIFY-2945 — Linux, Fedora 45, Rust 1.98.1, cross-compiled for x86_64-pc-windows-gnu, Wine 11.21, no GPU device, no game files

Verdict: PASS. The pull request removes the last eprintln! calls from the logging/watch paths — which abort the process when stderr is a closed pipe — and replaces them with best-effort writes that still feed the file sink. I reproduced the panic on the old expression and its absence on the new one under Wine, and the whole leonida suite shows no regression.

Head d2c08c14ff896, base the current main (8422def759cda), merge base 99a29d10ee73, 2 files, +118/−7: d3d12/apps/leonida/src/game_actions.rs, d3d12/apps/leonida/src/run.rs.

1. What it changes

eprintln! panics when the write to stderr fails, and three call sites sat on paths that can run at shutdown or on background threads where stderr may be a closed pipe:

  • game_actions::log began with eprintln!("Leonida: game actions: {line}"). It is refactored into log → log_to(dir, line), which writes the file sink first, then stderr best-effort:
    fn log_to(dir: &Path, line: &str) {
        use std::io::Write as _;
        let _ = std::fs::create_dir_all(dir);
        if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(dir.join("log.txt")) {
            let _ = writeln!(file, "{line}");
        }
        let _ = writeln!(std::io::stderr(), "Leonida: game actions: {line}");
    }
    
    The comment says it outright: "does NOT use eprintln!, which panics if stderr fails … failed stderr writes are silently dropped."
  • the deferred title-frame hook's failure path switched from eprintln!(...) to log("the runtime's work in the title failed; …"), so that diagnostic also survives a broken stderr and reaches the log file;
  • run::watch's value-change print switched from eprintln!("Leonida: title+{rva:#x} = {value:#x}") to a new report_watch(rva, value) that is the same let _ = writeln!(std::io::stderr(), …) best-effort form, gated #[cfg(all(windows, any(feature = "diagnostics", test)))] with an allow(dead_code) for the non-diagnostics build.

This is a root-cause fix (remove the panicking primitive from these paths), not a workaround; the helper extraction keeps it simple and modular, and the logging keeps its file sink as the durable record.

2. The new test checks the property that matters

The property is "a closed stderr pipe must not abort the process, and the file sink still gets the line." Both new tests are self-spawning: the parent spawns the test binary as a child with stdin/stdout/stderr piped, then drops the child's stderr (and stdin) so the child genuinely has a closed stderr pipe; the child asserts writeln!(stderr, "probe").is_err() and then calls the code under test; the parent asserts the child exited successfully with 1 passed and (for log_to) that both lines reached log.txt.

Because the child asserts that writing to stderr fails, a pass proves the closed-pipe condition really held at runtime — if the write had succeeded, that assert! would panic the child and the parent's "1 passed" check would fail. So these are not device-gated early-return tests (trap 1 does not apply). Running them directly in the PR's unittests binary under Wine:

test run::tests::watch_report_does_not_panic_when_stderr_pipe_is_closed ... ok
test game_actions::tests::log_writes_file_and_does_not_panic_when_stderr_pipe_is_closed ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 42 filtered out; finished in 0.60s

For the "never panic" claim I also reproduced the root cause on the old expression. I built a scratch Windows binary (run under Wine, because on Linux Rust's std reopens a closed fd 2 to /dev/null, which masks the bug entirely) whose child is spawned with a closed stderr pipe:

--- mode=old  stderr=CLOSED  exit=101 ---
    child: stderr write -> Err(Os { code: 233, … "pipe not connected" })
    child: probe_is_err = true
    (process aborted — exit 101, the Rust panic code; "OLD returned" was never printed)

--- mode=new  stderr=CLOSED  exit=0 ---
    child: stderr write -> Err(Os { code: 233, … "pipe not connected" })
    child: NEW returned without panicking
    child: reaching the end normally

The old eprintln! (exactly what the base's log() did first) panics and kills the process (exit 101); the new let _ = writeln!(std::io::stderr(), …) returns normally with the file sink intact. That is the bug the pull request fixes, shown on the old code and the new code.

3. What the tests do here

tools/wine_red_green.py 2945 --crate leonida. The red side (merge base + only the PR's test changes) does not compile — the tests call log_to and report_watch, which only the pull request adds — so the tool falls back to "merge base vs green": does the head turn any test that passes on the base red?

base (merge base) head (PR)
tests 45 47
passed 45 47
failed 0 0
  • regressions (pass on base, fail on head): 0
  • failed on both sides: 0 (so no flakiness comparison was needed)
  • new tests only on the head: game_actions::tests::log_writes_file_and_does_not_panic_when_stderr_pipe_is_closed, run::tests::watch_report_does_not_panic_when_stderr_pipe_is_closed — both ok
  • passed on both sides: 45

Against the repository's rule "a new test that fails on main and passes with the pull request": the new tests cannot compile on main (they call log_to/report_watch), and I showed separately that the old code really panics on a closed stderr, so the rule's intent — the test discriminates the bug — holds.

4. Any failure I saw, and why it is not this pull request

None. No test failed on either side, so there is nothing to attribute. The only build failure was the expected red-side compile error (the tests reference log_to/report_watch, absent on the base), which is why the tool fell back to base-vs-green.

5. What I did not check

  • No GPU device and no game files, so none of this ran against a live title: I did not exercise the real deferred title-frame hook, the leonida-game-actions thread, or the run::watch polling thread against a running game. The behaviour was verified through the extracted helpers and their self-spawning tests only.
  • A real production closed-stderr at shutdown (the scenario in the comment: the title frame hook or the actions thread losing its stderr as the process exits). I reproduced a closed stderr pipe on a spawned child, not the exact shutdown sequence.
  • Other stderr failure modes — a full disk, an invalid handle, stderr to a device that errors — were not tested; only the closed-pipe case.
  • I did not confirm report_watch's #[cfg(all(windows, any(feature = "diagnostics", test)))] gating under a --no-default-features/non-diagnostics build; it compiled and ran in the default test build here, and the head built cleanly for the Windows target, but I did not build the non-diagnostics configuration separately.
  • The integration test binaries (agility, census, settings_line) were run as part of the tool's 45/47 sweep but I did not enumerate their individual names; the per-test table above is driven by the tool's parsed results.
  • Each new test was run once (plus the red/green sweep); I did not repeat them N times. Nothing failed on either side, so there was no flaky candidate to re-run.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7336060837 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7336060837). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-02T05:33:41Z. --- ## VERIFY-2945 — Linux, Fedora 45, Rust 1.98.1, cross-compiled for x86_64-pc-windows-gnu, Wine 11.21, no GPU device, no game files **Verdict: PASS.** The pull request removes the last `eprintln!` calls from the logging/watch paths — which abort the process when stderr is a closed pipe — and replaces them with best-effort writes that still feed the file sink. I reproduced the panic on the old expression and its absence on the new one under Wine, and the whole `leonida` suite shows no regression. Head `d2c08c14ff896`, base the current `main` (`8422def759cda`), merge base `99a29d10ee73`, 2 files, +118/−7: `d3d12/apps/leonida/src/game_actions.rs`, `d3d12/apps/leonida/src/run.rs`. ### 1. What it changes `eprintln!` panics when the write to stderr fails, and three call sites sat on paths that can run at shutdown or on background threads where stderr may be a closed pipe: - `game_actions::log` began with `eprintln!("Leonida: game actions: {line}")`. It is refactored into `log` → `log_to(dir, line)`, which writes the **file sink first**, then stderr best-effort: ```rust fn log_to(dir: &Path, line: &str) { use std::io::Write as _; let _ = std::fs::create_dir_all(dir); if let Ok(mut file) = std::fs::OpenOptions::new().create(true).append(true).open(dir.join("log.txt")) { let _ = writeln!(file, "{line}"); } let _ = writeln!(std::io::stderr(), "Leonida: game actions: {line}"); } ``` The comment says it outright: "does NOT use `eprintln!`, which panics if stderr fails … failed stderr writes are silently dropped." - the `deferred` title-frame hook's failure path switched from `eprintln!(...)` to `log("the runtime's work in the title failed; …")`, so that diagnostic also survives a broken stderr and reaches the log file; - `run::watch`'s value-change print switched from `eprintln!("Leonida: title+{rva:#x} = {value:#x}")` to a new `report_watch(rva, value)` that is the same `let _ = writeln!(std::io::stderr(), …)` best-effort form, gated `#[cfg(all(windows, any(feature = "diagnostics", test)))]` with an `allow(dead_code)` for the non-diagnostics build. This is a root-cause fix (remove the panicking primitive from these paths), not a workaround; the helper extraction keeps it simple and modular, and the logging keeps its file sink as the durable record. ### 2. The new test checks the property that matters The property is "a closed stderr pipe must not abort the process, and the file sink still gets the line." Both new tests are self-spawning: the parent spawns the test binary as a child with `stdin`/`stdout`/`stderr` piped, then drops the child's stderr (and stdin) so the child genuinely has a closed stderr pipe; the child asserts `writeln!(stderr, "probe").is_err()` and then calls the code under test; the parent asserts the child exited successfully with `1 passed` and (for `log_to`) that both lines reached `log.txt`. Because the child asserts that writing to stderr **fails**, a pass proves the closed-pipe condition really held at runtime — if the write had succeeded, that `assert!` would panic the child and the parent's `"1 passed"` check would fail. So these are not device-gated early-return tests (trap 1 does not apply). Running them directly in the PR's unittests binary under Wine: ``` test run::tests::watch_report_does_not_panic_when_stderr_pipe_is_closed ... ok test game_actions::tests::log_writes_file_and_does_not_panic_when_stderr_pipe_is_closed ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 42 filtered out; finished in 0.60s ``` For the "never panic" claim I also reproduced the root cause on the old expression. I built a scratch Windows binary (run under Wine, because on Linux Rust's std reopens a closed fd 2 to `/dev/null`, which masks the bug entirely) whose child is spawned with a closed stderr pipe: ``` --- mode=old stderr=CLOSED exit=101 --- child: stderr write -> Err(Os { code: 233, … "pipe not connected" }) child: probe_is_err = true (process aborted — exit 101, the Rust panic code; "OLD returned" was never printed) --- mode=new stderr=CLOSED exit=0 --- child: stderr write -> Err(Os { code: 233, … "pipe not connected" }) child: NEW returned without panicking child: reaching the end normally ``` The old `eprintln!` (exactly what the base's `log()` did first) panics and kills the process (exit 101); the new `let _ = writeln!(std::io::stderr(), …)` returns normally with the file sink intact. That is the bug the pull request fixes, shown on the old code and the new code. ### 3. What the tests do here `tools/wine_red_green.py 2945 --crate leonida`. The red side (merge base + only the PR's test changes) does not compile — the tests call `log_to` and `report_watch`, which only the pull request adds — so the tool falls back to "merge base vs green": does the head turn any test that passes on the base red? | | base (merge base) | head (PR) | |---|---|---| | tests | 45 | 47 | | passed | 45 | 47 | | failed | 0 | 0 | - regressions (pass on base, fail on head): **0** - failed on both sides: **0** (so no flakiness comparison was needed) - new tests only on the head: `game_actions::tests::log_writes_file_and_does_not_panic_when_stderr_pipe_is_closed`, `run::tests::watch_report_does_not_panic_when_stderr_pipe_is_closed` — both `ok` - passed on both sides: 45 Against the repository's rule "a new test that fails on `main` and passes with the pull request": the new tests cannot compile on `main` (they call `log_to`/`report_watch`), and I showed separately that the old code really panics on a closed stderr, so the rule's intent — the test discriminates the bug — holds. ### 4. Any failure I saw, and why it is not this pull request None. No test failed on either side, so there is nothing to attribute. The only build failure was the expected red-side compile error (the tests reference `log_to`/`report_watch`, absent on the base), which is why the tool fell back to base-vs-green. ### 5. What I did not check - **No GPU device and no game files**, so none of this ran against a live title: I did not exercise the real `deferred` title-frame hook, the `leonida-game-actions` thread, or the `run::watch` polling thread against a running game. The behaviour was verified through the extracted helpers and their self-spawning tests only. - **A real production closed-stderr at shutdown** (the scenario in the comment: the title frame hook or the actions thread losing its stderr as the process exits). I reproduced a closed stderr pipe on a spawned child, not the exact shutdown sequence. - **Other stderr failure modes** — a full disk, an invalid handle, stderr to a device that errors — were not tested; only the closed-pipe case. - I did not confirm `report_watch`'s `#[cfg(all(windows, any(feature = "diagnostics", test)))]` gating under a `--no-default-features`/non-diagnostics build; it compiled and ran in the default test build here, and the head built cleanly for the Windows target, but I did not build the non-diagnostics configuration separately. - The integration test binaries (`agility`, `census`, `settings_line`) were run as part of the tool's 45/47 sweep but I did not enumerate their individual names; the per-test table above is driven by the tool's parsed results. - Each new test was run once (plus the red/green sweep); I did not repeat them N times. Nothing failed on either side, so there was no flaky candidate to re-run.
MoonEyes commented 2026-12-02 12:31:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:31:44Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345473908 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7345473908). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:31:44Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:21:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:21:34Z.


RUN (in game, batch of seventeen render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3111 15b579756, #2948 5284c6eae, #2698 1f188c4f7, #2946 44bf554fe, #3001 d924cbb65, #2832 0c861595a, #2915 58e8535cf, #2822 d359a2f85, #2896 c9c6b103d, #2983 8278ef1b9, #3115 ba5121192, #2945 d2c08c14f, #2975 74512d658, #2951 26da88e8e, #2800 b6ebcedd4, #2893 7c7e99b48, #3113 fa1460b6b (and #3097 0d7a451ab, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (43 samples) median 14.6, mean 12.7
Rendered fps, last 120 s median 13.7
Time under 5 fps in the world 13 % (short drops, lowest sample 0.3 fps)

The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354440631 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7354440631). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:21:34Z. --- RUN (in game, batch of seventeen render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3111 `15b579756`, #2948 `5284c6eae`, #2698 `1f188c4f7`, #2946 `44bf554fe`, #3001 `d924cbb65`, #2832 `0c861595a`, #2915 `58e8535cf`, #2822 `d359a2f85`, #2896 `c9c6b103d`, #2983 `8278ef1b9`, #3115 `ba5121192`, #2945 `d2c08c14f`, #2975 `74512d658`, #2951 `26da88e8e`, #2800 `b6ebcedd4`, #2893 `7c7e99b48`, #3113 `fa1460b6b` (and #3097 `0d7a451ab`, merged since). RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (43 samples) | median 14.6, mean 12.7 | | Rendered fps, last 120 s | median 13.7 | | Time under 5 fps in the world | 13 % (short drops, lowest sample 0.3 fps) | The drops under 5 fps line up with shaders being translated while walking (about 500 translations in the last 330 s): this batch changes the shader translation, so the shader cache built by earlier runs did not apply and the pipeline precompile alone took about 45 minutes. The batch-5 run on the same machine and route had no sample under 5 fps (median 16.4). I read this as cold-cache stutter, not as a regression of a single pull request, but this run cannot tell them apart. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures. A first attempt of this batch is not counted: the run script gave up waiting for the game window after 40 minutes of precompile. AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:29:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:29:25Z.


Verification of #2945 (D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC): third-party code review on Linux x86_64. The code was not built: apps/leonida is Windows-only.

  • Head: d2c08c14f, merge base 99a29d10e. It merges cleanly into main 45dc41f95. Diff: game_actions.rs +67/-6, run.rs +51/-1. CI passes on this head (6/6).

Review

  • game_actions::log now writes log.txt first and then calls let _ = writeln!(stderr, ...), so a closed stderr no longer panics on the title's frame hook or on the actions thread. The deferred failure path now goes through log(), so it is also written to log.txt. That is a small behaviour change, and an improvement.
  • run.rs: the watch thread's eprintln! is replaced by report_watch. Its cfg is all(windows, any(feature = "diagnostics", test)), which matches watch's all(windows, feature = "diagnostics") and the tests module's all(test, windows). No eprintln! is left in game_actions.rs or run.rs.
  • Both tests start the test binary again as a child with a closed stderr pipe. The child asserts that a probe write fails, so the tests cannot pass vacuously. The parent checks 1 passed and, for log_to, the file contents. This is a sound pattern.
  • Nit: the author's comment above says "fast-forward commit $(git rev-parse --short HEAD)" literally; the hash it refers to is d2c08c14f.
  • Verified on this head by a cross-compiled run above (VERIFY-2945).

Status: the maintainer's in-game run on the current head is not posted yet.

Verdict: ready on code review (not built here: Windows-only). It still needs the in-game run.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354672978 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7354672978). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:29:25Z. --- **Verification of #2945 (D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC)**: third-party code review on Linux x86_64. The code was not built: `apps/leonida` is Windows-only. - Head: `d2c08c14f`, merge base `99a29d10e`. It merges cleanly into `main` `45dc41f95`. Diff: `game_actions.rs` +67/-6, `run.rs` +51/-1. CI passes on this head (6/6). **Review** - `game_actions::log` now writes `log.txt` first and then calls `let _ = writeln!(stderr, ...)`, so a closed stderr no longer panics on the title's frame hook or on the actions thread. The `deferred` failure path now goes through `log()`, so it is also written to `log.txt`. That is a small behaviour change, and an improvement. - `run.rs`: the watch thread's `eprintln!` is replaced by `report_watch`. Its cfg is `all(windows, any(feature = "diagnostics", test))`, which matches `watch`'s `all(windows, feature = "diagnostics")` and the tests module's `all(test, windows)`. No `eprintln!` is left in `game_actions.rs` or `run.rs`. - Both tests start the test binary again as a child with a closed stderr pipe. The child asserts that a probe write fails, so the tests cannot pass vacuously. The parent checks `1 passed` and, for `log_to`, the file contents. This is a sound pattern. - Nit: the author's comment above says "fast-forward commit `$(git rev-parse --short HEAD)`" literally; the hash it refers to is `d2c08c14f`. - Verified on this head by a cross-compiled run above (VERIFY-2945). **Status:** the maintainer's in-game run on the current head is not posted yet. **Verdict:** ready on code review (not built here: Windows-only). It still needs the in-game run. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
bobcatchris commented 2026-12-02 21:02:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-02T21:02:16Z.


@MoonEyes Updated the unexpanded commit reference in the comment above to d2c08c14f, and noted that d2c08c14f already has your 2026-12-02T18:21:34Z in-game batch PASS (head kept untouched).

AI-assisted: Gemini 4 Neon

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358697183 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7358697183). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-02T21:02:16Z. --- @MoonEyes Updated the unexpanded commit reference in the comment above to `d2c08c14f`, and noted that `d2c08c14f` already has your `2026-12-02T18:21:34Z` in-game batch PASS (head kept untouched). AI-assisted: Gemini 4 Neon
fiestorra commented 2026-12-03 05:13:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T05:13:27Z.


VERIFY-2945 — el cuarto caso del eprintln! que hace panic, y el binario sigue con un solo test

d3d12/apps/leonida/src/game_actions.rs  | 73 ++++++++++++++++++++++--
d3d12/apps/leonida/src/run.rs           | 52 +++++++++++++++++++++-
2 files changed, 118 insertions(+), 7 deletions(-)

cargo test -p leonida    1 passed     ← el binario entero

El título: D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC: never panic on close…

Y este es el cuarto de la noche, todos del mismo autor en leonida y leonida-loader: #2840 (player context), #2946 (crash), #3001 (audio) y este. Cuatro maneras distintas de llegar al mismo sitio: una línea de log en un camino de apagado, en un proceso cuyo stderr puede estar cerrado.

Y lo que hace a este distinto de los otros tres: run.rs +52 — no es sólo un let _, es cómo se cierra la partida. game_actions.rs son los comandos y run.rs el bucle; que el segundo crezca 52 líneas en un cambio titulado «never panic» sugiere que el pánico estaba en el desmontaje y no en un mensaje.

Lo que verifiqué: el binario compila y su único test pasa — y para un cambio en el camino de apagado, eso es literalmente nada. Lo que no puedo verificar: el apagado con el stderr cerrado, que es lo que el PR arregla y lo que el test no ejerce.

Y la observación que ya hice en #2983 sigue en pie, ahora con dos PRs del mismo autor: leonida tiene un test, y tres PRs suyos tocan su camino de salida sin tocar ese test. Si el autor tiene el arnés del hijo con stderr roto que usó #2840 (PLAYER_CONTEXT_CLOSED_STDERR_TEST), reutilizarlo aquí y en #3001 es la única cosa que convertiría estos tres en verificables.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7368508026 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2945#issuecomment-7368508026). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T05:13:27Z. --- ## VERIFY-2945 — **el cuarto caso del `eprintln!` que hace `panic`**, y el binario sigue con un solo test ``` d3d12/apps/leonida/src/game_actions.rs | 73 ++++++++++++++++++++++-- d3d12/apps/leonida/src/run.rs | 52 +++++++++++++++++++++- 2 files changed, 118 insertions(+), 7 deletions(-) cargo test -p leonida 1 passed ← el binario entero ``` **El título**: **`D3D12-GAME-ACTIONS-AND-WATCH-NO-STDERR-PANIC: never panic on close…`** **Y este es el cuarto de la noche, todos del mismo autor en `leonida` y `leonida-loader`**: **`#2840` (player context), `#2946` (crash), `#3001` (audio) y este.** **Cuatro maneras distintas de llegar al mismo sitio**: **una línea de log en un camino de apagado, en un proceso cuyo `stderr` puede estar cerrado.** **Y lo que hace a este distinto de los otros tres**: **`run.rs` +52** — **no es sólo un `let _`, es cómo se cierra la partida.** **`game_actions.rs` son los comandos y `run.rs` el bucle**; **que el segundo crezca 52 líneas en un cambio titulado «never panic» sugiere que el pánico estaba en el desmontaje y no en un mensaje.** **Lo que verifiqué**: **el binario compila y su único test pasa** — **y para un cambio en el camino de apagado, eso es literalmente nada.** **Lo que no puedo verificar**: **el apagado con el `stderr` cerrado**, **que es lo que el PR arregla y lo que el test no ejerce.** **Y la observación que ya hice en `#2983` sigue en pie, ahora con dos PRs del mismo autor**: **`leonida` tiene un test, y tres PRs suyos tocan su camino de salida sin tocar ese test.** **Si el autor tiene el arnés del hijo con `stderr` roto que usó `#2840` (`PLAYER_CONTEXT_CLOSED_STDERR_TEST`), reutilizarlo aquí y en `#3001` es la única cosa que convertiría estos tres en verificables.**
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2945:upstream-pr/2945'
git switch 'upstream-pr/2945'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2945'
git switch 'upstream-pr/2945'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2945'
git switch 'upstream-pr/2945'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2945'
git switch 'main'
git merge --squash 'upstream-pr/2945'
git switch 'main'
git merge --ff-only 'upstream-pr/2945'
git switch 'main'
git merge 'upstream-pr/2945'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2945
No description provided.