D3D12-LOADER-PROFILE-AND-STACKS-SAFETY: fix handle leaks, CPU underflow, and stderr panics #2947

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

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


Summary

Claimed in the coordination issue as: D3D12-LOADER-PROFILE-AND-STACKS-SAFETY (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7324863065).

Fixes thread-handle leaks, unsigned CPU-time underflow, and closed-stderr panics in leonida-loader's diagnostic sampler and stack dumper:

  1. d3d12/crates/leonida-loader/src/profile.rs:
    • Adds impl Drop for Thread to close every non-null OpenThread handle once on drop (and removes the manual CloseHandle inside write()), so handles are never leaked if File::create / writeln! fails or profile() unwinds.
    • Makes cpu(HANDLE) return Option<u64> checking GetThreadTimes(...) != 0 with saturating_add, keeps t.now monotonic (t.now = now.max(t.now)), and uses saturating_sub for t.now - t.last and t.now - t.first so a failed query cannot panic with subtract underflow in debug builds or wrap to u64::MAX in release builds.
    • Replaces panicking eprintln! calls on the detached LEONIDA_PROFILE thread with fallible let _ = writeln!(std::io::stderr(), ...).
  2. d3d12/crates/leonida-loader/src/stacks.rs:
    • Wraps each OpenThread handle in an RAII ThreadHandle guard, drops it immediately after reading the thread's frames/name/start (before stderr writes), and replaces eprintln! in dump_stacks() with fallible let _ = writeln!(std::io::stderr(), ...).

Tests & Verification

  • Hardware / OS: Windows 11, Rust 1.98.1, no game files or GPU needed.
  • Red -> Green:
    • Added profile::tests::cpu_handles_invalid_handle_and_write_saturates_underflow, profile::tests::profile_writes_file_and_closes_handles_when_stderr_pipe_is_closed, and stacks::tests::dump_stacks_does_not_panic_when_stderr_pipe_is_closed.
    • Reverting saturating_sub and writeln! to t.now - t.first and eprintln!: 3/3 FAIL (RED_EXIT=101, attempt to subtract with overflow + closed-stderr panics).
    • With the fix:
      • cargo test --locked -p leonida-loader --lib --features diagnostics -- profile::tests stacks::tests: 6 passed, 0 failed.
      • cargo test --locked -p leonida-loader --lib: 83 passed, 0 failed (excluding unrelated pre-existing memory_at race fixed in #2939).
  • python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: exit 0.
  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-loader/src/profile.rs d3d12/crates/leonida-loader/src/stacks.rs: exit 0.

AI Assistance

AI-assisted using Gemini 4 Neon, including a separate read-only independent review pass (APPROVE).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5594083970 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T20:36:56Z. --- ## Summary Claimed in the coordination issue as: `D3D12-LOADER-PROFILE-AND-STACKS-SAFETY` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7324863065). Fixes thread-handle leaks, unsigned CPU-time underflow, and closed-stderr panics in `leonida-loader`'s diagnostic sampler and stack dumper: 1. `d3d12/crates/leonida-loader/src/profile.rs`: - Adds `impl Drop for Thread` to close every non-null `OpenThread` handle once on drop (and removes the manual `CloseHandle` inside `write()`), so handles are never leaked if `File::create` / `writeln!` fails or `profile()` unwinds. - Makes `cpu(HANDLE)` return `Option<u64>` checking `GetThreadTimes(...) != 0` with `saturating_add`, keeps `t.now` monotonic (`t.now = now.max(t.now)`), and uses `saturating_sub` for `t.now - t.last` and `t.now - t.first` so a failed query cannot panic with subtract underflow in debug builds or wrap to `u64::MAX` in release builds. - Replaces panicking `eprintln!` calls on the detached `LEONIDA_PROFILE` thread with fallible `let _ = writeln!(std::io::stderr(), ...)`. 2. `d3d12/crates/leonida-loader/src/stacks.rs`: - Wraps each `OpenThread` handle in an RAII `ThreadHandle` guard, drops it immediately after reading the thread's frames/name/start (before stderr writes), and replaces `eprintln!` in `dump_stacks()` with fallible `let _ = writeln!(std::io::stderr(), ...)`. ## Tests & Verification - **Hardware / OS**: Windows 11, Rust 1.98.1, no game files or GPU needed. - **Red -> Green**: - Added `profile::tests::cpu_handles_invalid_handle_and_write_saturates_underflow`, `profile::tests::profile_writes_file_and_closes_handles_when_stderr_pipe_is_closed`, and `stacks::tests::dump_stacks_does_not_panic_when_stderr_pipe_is_closed`. - Reverting `saturating_sub` and `writeln!` to `t.now - t.first` and `eprintln!`: **3/3 FAIL** (`RED_EXIT=101`, `attempt to subtract with overflow` + closed-stderr panics). - With the fix: - `cargo test --locked -p leonida-loader --lib --features diagnostics -- profile::tests stacks::tests`: **6 passed, 0 failed**. - `cargo test --locked -p leonida-loader --lib`: **83 passed, 0 failed** (excluding unrelated pre-existing `memory_at` race fixed in #2939). - `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md`: exit 0. - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-loader/src/profile.rs d3d12/crates/leonida-loader/src/stacks.rs`: exit 0. ## AI Assistance AI-assisted using Gemini 4 Neon, including a separate read-only independent review pass (APPROVE).
merzleckeier commented 2026-12-01 20:51:49 +00:00 (Migrated from github.com)

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


Independent handle ownership and CPU-total checks under Wine on 4b8ae458 merged into 1e3e316c. Both stock closed-stderr fixtures passed 3/3 in isolation and 3/3 in the same build with #2945 and #2946. Restoring the original first eprintln! in each of profile and dump_stacks on the combined tree made the respective child tests exit 101 in all three repeats. The exact profile and stacks groups passed 6/6.

I added the same test-only probe to both trees. It opened a real Windows handle to the test’s own thread and checked it with GetHandleInformation before and after dropping its owner. On main a successful write closed it inside write. After a missing-directory error the main handle remained open even after dropping the owner, so the probe closed it. On the PR the handle stayed open through either write outcome and closed on owner drop. All three repeats per tree agreed.

A separate probe put 50,000 then 10,000 synthetic 100 ns ticks into the report writer. The optimized main build wrote 1844674407370951 ms and the PR wrote 0 ms in all repeats. A naturally failing OS time query was outside the fixture.

MEASURED under Wine 11.22 with OpenAI Codex and a separate read-only review.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7325387073 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7325387073). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T20:51:49Z. --- Independent handle ownership and CPU-total checks under Wine on `4b8ae458` merged into `1e3e316c`. Both stock closed-stderr fixtures passed 3/3 in isolation and 3/3 in the same build with #2945 and #2946. Restoring the original first `eprintln!` in each of `profile` and `dump_stacks` on the combined tree made the respective child tests exit 101 in all three repeats. The exact profile and stacks groups passed 6/6. I added the same test-only probe to both trees. It opened a real Windows handle to the test’s own thread and checked it with `GetHandleInformation` before and after dropping its owner. On main a successful write closed it inside `write`. After a missing-directory error the main handle remained open even after dropping the owner, so the probe closed it. On the PR the handle stayed open through either write outcome and closed on owner drop. All three repeats per tree agreed. A separate probe put 50,000 then 10,000 synthetic 100 ns ticks into the report writer. The optimized main build wrote `1844674407370951` ms and the PR wrote `0` ms in all repeats. A naturally failing OS time query was outside the fixture. MEASURED under Wine 11.22 with OpenAI Codex and a separate read-only review.
KelboLive commented 2026-12-01 21:28:26 +00:00 (Migrated from github.com)

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

Review: COMMENTED


The fix itself is sound: Thread/ThreadHandle Drop now cover the failure paths (profile.rs:52-61, stacks.rs:100-110), every CPU delta is saturating with a monotonic now (profile.rs:148-153, :191), and stderr writes can no longer panic. Three of the four mutations are caught (now - first, a no-op Thread::drop, and eprintln! in stacks) — good.

One blocker: the regression tests live behind feature = "diagnostics" (lib.rs:40-43), and CI runs cargo test --workspace --exclude xtask --locked with no features (.github/workflows/d3d12.yml:76). So the default --lib run is 84 tests, none of the new ones compile, and the PR body's "83 passed" run proves nothing about this change. Either add a diagnostics test step or the guards can silently regress.

Second: the stacks handle-close guard is untested — making ThreadHandle::drop a no-op leaves all three stacks::tests green, while the equivalent profile mutation is caught. One more assertion would close it.

Minor: if the first cpu() fails, first = 0 makes the reported milliseconds a lifetime total rather than since profiling began — worth a comment or a None state. And #2588 is unrelated: it is the 64 MB GPU worker stack, not this diagnostic stack dumper, so there is no duplication between them.

Merge is clean against current main, and no other open PR touches profile.rs/stacks.rs.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6140473005 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#pullrequestreview-6140473005). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T21:28:26Z. **Review:** COMMENTED --- The fix itself is sound: `Thread`/`ThreadHandle` `Drop` now cover the failure paths (`profile.rs:52-61`, `stacks.rs:100-110`), every CPU delta is saturating with a monotonic `now` (`profile.rs:148-153`, `:191`), and stderr writes can no longer panic. Three of the four mutations are caught (`now - first`, a no-op `Thread::drop`, and `eprintln!` in `stacks`) — good. One blocker: **the regression tests live behind `feature = "diagnostics"`** (`lib.rs:40-43`), and CI runs `cargo test --workspace --exclude xtask --locked` with **no features** (`.github/workflows/d3d12.yml:76`). So the default `--lib` run is 84 tests, none of the new ones compile, and the PR body's "83 passed" run proves nothing about this change. Either add a diagnostics test step or the guards can silently regress. Second: the `stacks` handle-close guard is untested — making `ThreadHandle::drop` a no-op leaves all three `stacks::tests` green, while the equivalent `profile` mutation is caught. One more assertion would close it. Minor: if the first `cpu()` fails, `first = 0` makes the reported milliseconds a lifetime total rather than since profiling began — worth a comment or a `None` state. And #2588 is unrelated: it is the 64 MB GPU worker stack, not this diagnostic stack dumper, so there is no duplication between them. Merge is clean against current main, and no other open PR touches `profile.rs`/`stacks.rs`.
bobcatchris commented 2026-12-01 22:24:48 +00:00 (Migrated from github.com)

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


Updated in fast-forward commit b07f64346 to address all three review points from @KelboLive:

  1. Default-feature CI test coverage (lib.rs): Switched mod profile; and mod stacks; to #[cfg(all(windows, any(feature = "diagnostics", test)))] (with #[cfg_attr(not(feature = "diagnostics"), allow(dead_code))] on profile_on_schedule / dump_stacks_on_schedule) so all 6 profile::tests and stacks::tests compile and run in CI's default cargo test --workspace --exclude xtask --locked without touching workflow YAML.
  2. stacks handle-close test (stacks.rs): Added an OpenThread + ThreadHandle drop + GetHandleInformation == 0 assertion inside the single-threaded child of dump_stacks_does_not_panic_when_stderr_pipe_is_closed. Confirmed that making ThreadHandle::drop a no-op fails the test (STACKS_DROP_RED_EXIT=101).
  3. Thread.first: Option<u64> (profile.rs): Changed first to Option<u64> so a failed initial cpu() query does not leak a thread's pre-profile lifetime CPU total into the next sample (baseline is initialized on the first successful Some(now), or 0 ms if cpu() never succeeds), and covered first: None in cpu_handles_invalid_handle_and_write_saturates_underflow.

Re-verified locally (Windows 11, Rust 1.98.1):

  • cargo clippy --locked -p leonida-loader --all-targets -- -D warnings: 0 warnings, exit 0.
  • cargo build --locked -p leonida-loader --all-targets: 0 warnings, exit 0.
  • cargo test --locked -p leonida-loader --lib -- profile::tests stacks::tests: 6 passed, 0 failed.
  • cargo test --locked -p leonida-loader --lib --features diagnostics -- profile::tests stacks::tests: 6 passed, 0 failed.
  • tools/d3d12_switches.py --check & scripts/check_no_game_data.py: exit 0.

AI-assisted, including a separate read-only independent review pass (APPROVE).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7327804929 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7327804929). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-01T22:24:48Z. --- Updated in fast-forward commit `b07f64346` to address all three review points from `@KelboLive`: 1. **Default-feature CI test coverage (`lib.rs`)**: Switched `mod profile;` and `mod stacks;` to `#[cfg(all(windows, any(feature = "diagnostics", test)))]` (with `#[cfg_attr(not(feature = "diagnostics"), allow(dead_code))]` on `profile_on_schedule` / `dump_stacks_on_schedule`) so all 6 `profile::tests` and `stacks::tests` compile and run in CI's default `cargo test --workspace --exclude xtask --locked` without touching workflow YAML. 2. **`stacks` handle-close test (`stacks.rs`)**: Added an `OpenThread` + `ThreadHandle` drop + `GetHandleInformation == 0` assertion inside the single-threaded child of `dump_stacks_does_not_panic_when_stderr_pipe_is_closed`. Confirmed that making `ThreadHandle::drop` a no-op fails the test (`STACKS_DROP_RED_EXIT=101`). 3. **`Thread.first: Option<u64>` (`profile.rs`)**: Changed `first` to `Option<u64>` so a failed initial `cpu()` query does not leak a thread's pre-profile lifetime CPU total into the next sample (baseline is initialized on the first successful `Some(now)`, or `0` ms if `cpu()` never succeeds), and covered `first: None` in `cpu_handles_invalid_handle_and_write_saturates_underflow`. Re-verified locally (Windows 11, Rust 1.98.1): - `cargo clippy --locked -p leonida-loader --all-targets -- -D warnings`: 0 warnings, exit 0. - `cargo build --locked -p leonida-loader --all-targets`: 0 warnings, exit 0. - `cargo test --locked -p leonida-loader --lib -- profile::tests stacks::tests`: **6 passed, 0 failed**. - `cargo test --locked -p leonida-loader --lib --features diagnostics -- profile::tests stacks::tests`: **6 passed, 0 failed**. - `tools/d3d12_switches.py --check` & `scripts/check_no_game_data.py`: exit 0. AI-assisted, including a separate read-only independent review pass (APPROVE).
MoonEyes commented 2026-12-02 12:32:04 +00:00 (Migrated from github.com)

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


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:7345481910 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7345481910). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:32:04Z. --- 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).
Kal0s-design commented 2026-12-02 15:14:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T15:14:07Z.


Ran natively on Windows 11, head b07f64346 merged into main (43fc605ed, clean merge; main has since advanced one commit that only touches a PowerShell script), Rust 1.98.1. This adds process-wide handle counts and a real failing GetThreadTimes call to the Wine results above.

Check on the merge Result
cargo test --locked -p leonida-loader (default features) 96 + 2 + 1 passed, 0 failed
cargo test --locked -p leonida-loader --features diagnostics --lib 96 passed, 0 failed
cargo clippy --locked -p leonida-loader --all-targets -- -D warnings, with and without diagnostics clean
cargo check --locked --workspace --all-targets builds

Handle counts. I used a throwaway test with 8 extra parked threads (12 other threads in total). It read GetProcessHandleCount before and after 100 profile() cycles (12 ms window, 4 ms rate) and 100 dump_stacks() calls. On main I put back main's profile.rs/stacks.rs and ran the same test.

100 cycles main PR
profile(), file written +0 +0
profile(), output directory missing (File::create fails) +1201 (12 per cycle, one per opened thread) +1 (one-off, not per cycle)
dump_stacks(), stderr open +0 +0

On main every failed write leaks one handle per thread that choose opened. With the PR this is gone.

CPU delta when the time query fails after a success. I used a real thread handle opened with THREAD_SUSPEND_RESUME only, so GetThreadTimes actually fails (access denied). It went into choose() with last = 50_000, 20 runs each.

main PR
debug build: choose() panics (attempt to subtract with overflow) 20/20 0/20
release build: failing thread ranked first among the busiest 20/20 (the delta wraps to near u64::MAX) 0/20 (delta 0)

The synthetic entry had the lowest thread id. A zero delta therefore sorts it last, because ties go by id descending, and only a wrapped delta puts it first. So the release row has an effect beyond the report file. On main, a thread whose time query fails after a success jumps to the top of the busiest list for the next choose interval (1 s). It stays there until last catches up at 0. With the PR its delta is 0.

Not checked: stack-walk robustness (bad frame pointers, guard pages). This PR does not change frames_of/unwind_into. Also not checked: the in-game run that the render-path gate asks for.

GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7349976687 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7349976687). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T15:14:07Z. --- Ran natively on Windows 11, head `b07f64346` merged into `main` (`43fc605ed`, clean merge; main has since advanced one commit that only touches a PowerShell script), Rust 1.98.1. This adds process-wide handle counts and a real failing `GetThreadTimes` call to the Wine results above. | Check on the merge | Result | |---|---| | `cargo test --locked -p leonida-loader` (default features) | 96 + 2 + 1 passed, 0 failed | | `cargo test --locked -p leonida-loader --features diagnostics --lib` | 96 passed, 0 failed | | `cargo clippy --locked -p leonida-loader --all-targets -- -D warnings`, with and without `diagnostics` | clean | | `cargo check --locked --workspace --all-targets` | builds | **Handle counts.** I used a throwaway test with 8 extra parked threads (12 other threads in total). It read `GetProcessHandleCount` before and after 100 `profile()` cycles (12 ms window, 4 ms rate) and 100 `dump_stacks()` calls. On main I put back main's `profile.rs`/`stacks.rs` and ran the same test. | 100 cycles | main | PR | |---|---|---| | `profile()`, file written | +0 | +0 | | `profile()`, output directory missing (`File::create` fails) | **+1201** (12 per cycle, one per opened thread) | +1 (one-off, not per cycle) | | `dump_stacks()`, stderr open | +0 | +0 | On main every failed write leaks one handle per thread that `choose` opened. With the PR this is gone. **CPU delta when the time query fails after a success.** I used a real thread handle opened with `THREAD_SUSPEND_RESUME` only, so `GetThreadTimes` actually fails (access denied). It went into `choose()` with `last = 50_000`, 20 runs each. | | main | PR | |---|---|---| | debug build: `choose()` panics (`attempt to subtract with overflow`) | 20/20 | 0/20 | | release build: failing thread ranked first among the busiest | 20/20 (the delta wraps to near `u64::MAX`) | 0/20 (delta 0) | The synthetic entry had the lowest thread id. A zero delta therefore sorts it last, because ties go by id descending, and only a wrapped delta puts it first. So the release row has an effect beyond the report file. On main, a thread whose time query fails after a success jumps to the top of the busiest list for the next choose interval (1 s). It stays there until `last` catches up at 0. With the PR its delta is 0. Not checked: stack-walk robustness (bad frame pointers, guard pages). This PR does not change `frames_of`/`unwind_into`. Also not checked: the in-game run that the render-path gate asks for. GPUs tested: n/a (CPU-only tests). AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 17:06:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T17:06:55Z.


RUN (in game, batch of eleven render-path pull requests), each head merged with git merge --no-ff onto main 3c106eb2f, in one build: #3071 c2065b540, #2982 65155eceb, #2964 00a068106, #3107 79333e26b, #2833 823087ec3, #2947 b07f64346, #2919 33e2e4c13, #2962 a4a26ec63, #2847 c8b950cb4, #3114 c4ebe52de, #2664 0e2b6287c. 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 (48 samples) median 16.2, mean 16.1
Rendered fps, last 120 s median 15.1

For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain.

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; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean).

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352918216 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7352918216). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T17:06:55Z. --- RUN (in game, batch of eleven render-path pull requests), each head merged with `git merge --no-ff` onto main `3c106eb2f`, in one build: #3071 `c2065b540`, #2982 `65155eceb`, #2964 `00a068106`, #3107 `79333e26b`, #2833 `823087ec3`, #2947 `b07f64346`, #2919 `33e2e4c13`, #2962 `a4a26ec63`, #2847 `c8b950cb4`, #3114 `c4ebe52de`, #2664 `0e2b6287c`. 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 (48 samples) | median 16.2, mean 16.1 | | Rendered fps, last 120 s | median 15.1 | For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain. 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; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean). AI-assisted (Claude Code).
MoonEyes commented 2026-12-02 18:00:53 +00:00 (Migrated from github.com)

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


Triage of head b07f64346 (merge base 66c79286f, 342 commits behind; git merge-tree against current main 45dc41f95: no conflicts).

3 files in leonida-loader (+276/-34).

CI green on the head (6 checks).

Existing verification: Verified on this head by @merzleckeier (Wine), @Kal0s-design (native, handle counts and a failing GetThreadTimes), and in @MoonEyes's in-game batch.

This check: Not re-reviewed in depth. Process note: the author's update comment literally contains $(git rev-parse --short HEAD) instead of a commit id, so the thread does not name which commit addressed @KelboLive's points; the head is b07f64346.

I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.

Verdict: ready (verified natively, under Wine and in game on this head).

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


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353861338 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7353861338). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:00:53Z. --- **Triage of head `b07f64346` (merge base `66c79286f`, 342 commits behind; `git merge-tree` against current `main` `45dc41f95`: no conflicts).** 3 files in `leonida-loader` (+276/-34). CI green on the head (6 checks). **Existing verification:** Verified on this head by @merzleckeier (Wine), @Kal0s-design (native, handle counts and a failing `GetThreadTimes`), and in @MoonEyes's in-game batch. **This check:** Not re-reviewed in depth. Process note: the author's update comment literally contains `$(git rev-parse --short HEAD)` instead of a commit id, so the thread does not name which commit addressed @KelboLive's points; the head is `b07f64346`. I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here. **Verdict: ready** (verified natively, under Wine and in game on this head). 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:23 +00:00 (Migrated from github.com)

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


@MoonEyes Updated the unexpanded commit reference in the comment above to exact head b07f64346 (already covered by your 17:06:55Z in-game batch PASS and marked ready).

AI-assisted: Gemini 4 Neon

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358700089 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7358700089). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-12-02T21:02:23Z. --- @MoonEyes Updated the unexpanded commit reference in the comment above to exact head `b07f64346` (already covered by your `17:06:55Z` in-game batch PASS and marked `ready`). AI-assisted: Gemini 4 Neon
fiestorra commented 2026-12-03 05:14:33 +00:00 (Migrated from github.com)

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


VERIFY-2947 — 90 tests del loader pasan, y el título dice tres cosas que son la misma

d3d12/crates/leonida-loader/src/profile.rs  | 203 ++++++++++++++++++++++++++---
d3d12/crates/leonida-loader/src/stacks.rs   | 103 +++++++++++++--
d3d12/crates/leonida-loader/src/lib.rs      |   4 +-
3 files changed, 276 insertions(+), 34 deletions(-)

cargo test -p leonida-loader --lib          90 passed; 0 failed

El título: fix handle leaks, CPU unde… — fugas de handles, y algo de CPU en profile y stacks. Y los tres ficheros cuentan la misma historia: profile.rs es donde se guarda el perfil de la ejecución, stacks.rs donde se capturan las pilas, y lib.rs el que los une.

Y este PR es el quinto de la noche con el mismo tema de handles: #3003 (EventHandle), #2994 (Worker), #2946 (crash), este y el event_handle de #2587. Cinco autores distintos escribiendo Drop a mano en el mismo repositorio — y ninguno de ellos está equivocado en su fichero.

Lo que eso dice del código, sin criticar a nadie: si cinco personas necesitan cerrar un HANDLE correctamente y cada una escribe su Drop, la tercera o la cuarta se va a olvidar de un caso. Un OwnedHandle en el crate — ya lo dije en #2994 — es lo que convierte cinco implementaciones en una.

Y lo que este PR añade sobre los otros cuatro: no es sólo un Drop: profile.rs crece 203 líneas y stacks.rs 103, así que el autor encontró el camino entero, no el punto donde falló.

Lo que verifiqué: 90 tests del crate en verde, con la suite entera de leonida-loader — y ese crate es el que más ha crecido en tests esta noche (#2889 91, #2890 86, #2891 86, #2946 85, este 90).
Lo que no: la fuga de handles de verdad — necesita un proceso con la sesión larga y un contador de handles, que es lo que #3003 intentaba con un hijo y lo que a esta máquina le faltó para poder decirlo.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7368527446 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2947#issuecomment-7368527446). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T05:14:33Z. --- ## VERIFY-2947 — 90 tests del loader pasan, y el título dice tres cosas que son la misma ``` d3d12/crates/leonida-loader/src/profile.rs | 203 ++++++++++++++++++++++++++--- d3d12/crates/leonida-loader/src/stacks.rs | 103 +++++++++++++-- d3d12/crates/leonida-loader/src/lib.rs | 4 +- 3 files changed, 276 insertions(+), 34 deletions(-) cargo test -p leonida-loader --lib 90 passed; 0 failed ``` **El título**: **`fix handle leaks, CPU unde…`** — **fugas de handles, y algo de CPU en `profile` y `stacks`.** **Y los tres ficheros cuentan la misma historia**: **`profile.rs` es donde se guarda el perfil de la ejecución, `stacks.rs` donde se capturan las pilas, y `lib.rs` el que los une.** **Y este PR es el quinto de la noche con el mismo tema de handles**: **`#3003` (EventHandle), `#2994` (Worker), `#2946` (crash), este y el `event_handle` de `#2587`.** **Cinco autores distintos escribiendo `Drop` a mano en el mismo repositorio** — **y ninguno de ellos está equivocado en su fichero.** **Lo que eso dice del código, sin criticar a nadie**: **si cinco personas necesitan cerrar un `HANDLE` correctamente y cada una escribe su `Drop`, la tercera o la cuarta se va a olvidar de un caso.** **Un `OwnedHandle` en el crate — ya lo dije en `#2994` — es lo que convierte cinco implementaciones en una.** **Y lo que este PR añade sobre los otros cuatro**: **no es sólo un `Drop`: `profile.rs` crece 203 líneas y `stacks.rs` 103, así que el autor encontró el camino entero, no el punto donde falló.** **Lo que verifiqué**: **90 tests del crate en verde, con la suite entera de `leonida-loader`** — **y ese crate es el que más ha crecido en tests esta noche (`#2889` 91, `#2890` 86, `#2891` 86, `#2946` 85, este 90).** **Lo que no**: **la fuga de handles de verdad** — **necesita un proceso con la sesión larga y un contador de handles, que es lo que `#3003` intentaba con un hijo y lo que a esta máquina le faltó para poder decirlo.**
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/2947:upstream-pr/2947'
git switch 'upstream-pr/2947'

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/2947'
git switch 'upstream-pr/2947'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2947'
git switch 'upstream-pr/2947'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2947'
git switch 'main'
git merge --squash 'upstream-pr/2947'
git switch 'main'
git merge --ff-only 'upstream-pr/2947'
git switch 'main'
git merge 'upstream-pr/2947'
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!2947
No description provided.