GPU: release presenter mutex before recursive two-plane fallback #1459

Manually merged
github merged 1 commit from github-bot/gh-1459 into main 2026-11-29 08:20:52 +00:00 AGit
Owner

@⁠steven-seagull27 on GitHub · 2026-11-28 20:20 UTC · original
steven-seagull27:fix/presenter-lock-drop → main · +3 −3 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

Commit c9876bf refactored self.presenter from Mutex<Option<Presenter>> to Mutex<Presentation> (let mut presentation = self.presenter.lock()...; let Presentation { presenter, retry } = &mut *presentation;), leaving drop(presenter) in all three two-plane composer fallback paths inside Host::present_planes (crates/victory-gpu/src/host.rs lines 10800, 10843, and 10903).

Because presenter is now &mut Option<Presenter>, drop(presenter) is a no-op (flagged by dropping_references) while the MutexGuard presentation remains held across the recursive self.present_planes(texture, state_u32, None, frame, video) call — causing a guaranteed self-deadlock on self.presenter.lock() whenever two-plane composer creation or recording falls back to the base plane.

This change drops presentation instead of presenter at all three fallback sites, releasing the lock before recursing and clearing all three dropping_references warnings.

Verification (synthetic tests only)

  • Base: 923e38c, Windows 11 x64, Rust 1.98.1 MSVC.
  • cargo test --locked -p victory-gpu --lib host::tests -- --nocapture: 71 passed, 0 failed.
  • cargo check --locked -p victory-gpu --all-features: passes with zero warnings in host.rs (all 3 dropping_references warnings cleared).
  • Minimal 3-line fix in crates/victory-gpu/src/host.rs (pre-existing lower.rs size warning in xtask policy untouched).

AI-assisted. Synthetic verification only.

**@⁠steven-seagull27** on GitHub · 2026-11-28 20:20 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1459) `steven-seagull27:fix/presenter-lock-drop` → `main` · +3 −3 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC Commit `c9876bf` refactored `self.presenter` from `Mutex<Option<Presenter>>` to `Mutex<Presentation>` (`let mut presentation = self.presenter.lock()...; let Presentation { presenter, retry } = &mut *presentation;`), leaving `drop(presenter)` in all three two-plane composer fallback paths inside `Host::present_planes` (`crates/victory-gpu/src/host.rs` lines 10800, 10843, and 10903). Because `presenter` is now `&mut Option<Presenter>`, `drop(presenter)` is a no-op (flagged by `dropping_references`) while the `MutexGuard` `presentation` remains held across the recursive `self.present_planes(texture, state_u32, None, frame, video)` call — causing a guaranteed self-deadlock on `self.presenter.lock()` whenever two-plane composer creation or recording falls back to the base plane. This change drops `presentation` instead of `presenter` at all three fallback sites, releasing the lock before recursing and clearing all three `dropping_references` warnings. ### Verification (synthetic tests only) - Base: `923e38c`, Windows 11 x64, Rust 1.98.1 MSVC. - `cargo test --locked -p victory-gpu --lib host::tests -- --nocapture`: **71 passed, 0 failed**. - `cargo check --locked -p victory-gpu --all-features`: passes with zero warnings in `host.rs` (all 3 `dropping_references` warnings cleared). - Minimal 3-line fix in `crates/victory-gpu/src/host.rs` (pre-existing `lower.rs` size warning in `xtask policy` untouched). AI-assisted. Synthetic verification only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 20:22:56 +00:00
Author
Owner

@⁠babuakhil on GitHub · 2026-11-28 21:05 UTC · original

Independent confirmation: I hit the same bug from clippy on main (923e38c) and arrived at the identical three-line change before finding this PR.

Cause, as I read it: c9876bf (swap-chain retry) changed let mut presenter = self.presenter.lock()… into let mut presentation = …; let Presentation { presenter, retry } = &mut *presentation;. From then on drop(presenter) drops only the &mut, so the three base-plane fallbacks call present_planes again while still holding the guard, and that call locks the same Mutex on the same thread. Dropping presentation restores what drop(presenter) did before c9876bf.

Checked here (Windows 11, RTX 3060, Rust 1.98.1), with this change on 923e38c:

  • builds; the borrow checker accepts dropping the guard at all three sites
  • the three dropping_references errors are gone from both clippy builds (with and without --all-features)
  • cargo test -p victory-gpu --lib --locked: 5 of 5 full runs passed. Two earlier runs each had one failure: descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes, which also fails on plain main (1 of 10 runs alone), and watch::tests::faults_that_take_no_lock_tell_the_same; watch tests fail now and then on main too (another one did in my runs without this change), and neither area is touched here

Not checked: the fallback paths themselves. They only run when the composer can't be made or the composite can't be recorded, which no test reaches, and I haven't run the game.

Note for CI: on current main, clippy stops at two victory-shader errors (lower.rs: an unused colour, a manual checked division) before it reaches victory-gpu, so CI won't show these dropping_references errors until those are fixed. #1470 also lists "a hang on the present's fallback" and may overlap.

**@⁠babuakhil** on GitHub · 2026-11-28 21:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1459#issuecomment-7245765737) Independent confirmation: I hit the same bug from clippy on `main` (`923e38c`) and arrived at the identical three-line change before finding this PR. **Cause, as I read it:** `c9876bf` (swap-chain retry) changed `let mut presenter = self.presenter.lock()…` into `let mut presentation = …; let Presentation { presenter, retry } = &mut *presentation;`. From then on `drop(presenter)` drops only the `&mut`, so the three base-plane fallbacks call `present_planes` again while still holding the guard, and that call locks the same `Mutex` on the same thread. Dropping `presentation` restores what `drop(presenter)` did before `c9876bf`. **Checked here** (Windows 11, RTX 3060, Rust 1.98.1), with this change on `923e38c`: - builds; the borrow checker accepts dropping the guard at all three sites - the three `dropping_references` errors are gone from both clippy builds (with and without `--all-features`) - `cargo test -p victory-gpu --lib --locked`: 5 of 5 full runs passed. Two earlier runs each had one failure: `descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes`, which also fails on plain `main` (1 of 10 runs alone), and `watch::tests::faults_that_take_no_lock_tell_the_same`; `watch` tests fail now and then on `main` too (another one did in my runs without this change), and neither area is touched here **Not checked:** the fallback paths themselves. They only run when the composer can't be made or the composite can't be recorded, which no test reaches, and I haven't run the game. Note for CI: on current `main`, clippy stops at two `victory-shader` errors (`lower.rs`: an unused `colour`, a manual checked division) before it reaches `victory-gpu`, so CI won't show these `dropping_references` errors until those are fixed. #1470 also lists "a hang on the present's fallback" and may overlap.
Author
Owner

@⁠nick0451 on GitHub · 2026-11-28 21:44 UTC · original

A smoke test in play: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. A release build of this PR merged onto main 923e38c, run in turn with main and three other PR builds. Series S, DLSS Performance, frame generation off. The same frozen save, outdoors on a balcony, standing still. Two rounds, each run 40 s to settle and 60 s measured, then a screenshot.

  • No crash, hang, device loss or ERROR line in about 7 minutes of play. The two-plane composer fallback this fixes was not reached in this scene, so this shows only that the change does no harm on the normal present path.
  • fps in round 2: 23.8 against main 23.0-23.5 (round 1 was slow for every new build in the session).
  • The change reads right: drop(presentation) releases the guard before the recursive present_planes, where drop(presenter) only dropped a reference.

Tested with an AI assistant (Claude Code); results are from this PC.

**@⁠nick0451** on GitHub · 2026-11-28 21:44 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1459#issuecomment-7246237820) A smoke test in play: RTX 3090 24 GB (driver 610.88), i9-14900K, Windows 11. A release build of this PR merged onto main `923e38c`, run in turn with main and three other PR builds. Series S, DLSS Performance, frame generation off. The same frozen save, outdoors on a balcony, standing still. Two rounds, each run 40 s to settle and 60 s measured, then a screenshot. - No crash, hang, device loss or `ERROR` line in about 7 minutes of play. The two-plane composer fallback this fixes was not reached in this scene, so this shows only that the change does no harm on the normal present path. - fps in round 2: 23.8 against main 23.0-23.5 (round 1 was slow for every new build in the session). - The change reads right: `drop(presentation)` releases the guard before the recursive `present_planes`, where `drop(presenter)` only dropped a reference. Tested with an AI assistant (Claude Code); results are from this PC.
github manually merged commit a91f9b1ef5 into main 2026-11-29 08:20:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1459
No description provided.