fix(gpu): treat unreadable memory in ValueWait::holds as not holding #3359

Open
reeledMarek wants to merge 1 commit from upstream-pr/3359 into main
reeledMarek commented 2026-11-26 20:25:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T20:25:39Z.


Summary

  • ValueWait::holds documented unreadable memory as not holding, but returned None via read(self.address, self.bytes)?—the same sentinel used for unknown D3D12 comparison functions.
  • Held::pump treats None as an unknown comparison (incrementing done.unknown and leaving ok = true), so queues waiting on unreadable memory ran prematurely instead of staying held, and Held::blocked omitted those waits because it filters for Some(false).
  • Returns Some(false) when read(self.address, self.bytes) returns None, reserving None strictly for unknown comparison functions.
  • Updates comparisons_test_the_masked_value and adds regression test unreadable_memory_holds_the_queue_without_counting_as_unknown.

Verification

  • cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings
  • Ran all 11 hold::tests unit tests directly (rustc --edition 2024 --test)
  • cargo test -p xtask --locked
<!-- greyfinch-sync:Marvisak/VIctory:issue:5516694931 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3359). Originally posted by [reeledMarek](https://github.com/reeledMarek) on 2026-11-26T20:25:39Z. --- ### Summary - `ValueWait::holds` documented unreadable memory as *not holding*, but returned `None` via `read(self.address, self.bytes)?`—the same sentinel used for unknown D3D12 comparison functions. - `Held::pump` treats `None` as an unknown comparison (incrementing `done.unknown` and leaving `ok = true`), so queues waiting on unreadable memory ran prematurely instead of staying held, and `Held::blocked` omitted those waits because it filters for `Some(false)`. - Returns `Some(false)` when `read(self.address, self.bytes)` returns `None`, reserving `None` strictly for unknown comparison functions. - Updates `comparisons_test_the_masked_value` and adds regression test `unreadable_memory_holds_the_queue_without_counting_as_unknown`. ### Verification - `cargo clippy -p victory-gpu --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings` - Ran all 11 `hold::tests` unit tests directly (`rustc --edition 2024 --test`) - `cargo test -p xtask --locked`
Dukestar69 commented 2026-11-26 20:28:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T20:28:31Z.

Review: APPROVED


LGTM — verified on Windows against origin/main (63bcca4).

  • Returning Some(false) instead of None when read(self.address, self.bytes) returns None prevents unreadable wait memory from being treated as an unknown comparison (which previously released the waiting queue segment early).
  • cargo test -p victory-gpu --lib hold:: -- --test-threads=1: 11 passed, 0 failed (including unreadable_memory_holds_the_queue_without_counting_as_unknown).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6080162121 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3359#pullrequestreview-6080162121). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T20:28:31Z. **Review:** APPROVED --- LGTM — verified on Windows against `origin/main` (`63bcca4`). - Returning `Some(false)` instead of `None` when `read(self.address, self.bytes)` returns `None` prevents unreadable wait memory from being treated as an unknown comparison (which previously released the waiting queue segment early). - `cargo test -p victory-gpu --lib hold:: -- --test-threads=1`: 11 passed, 0 failed (including `unreadable_memory_holds_the_queue_without_counting_as_unknown`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Jackster commented 2026-11-26 22:29:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:29:11Z.


Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX:

  • hold::tests::unreadable_memory_holds_the_queue_without_counting_as_unknown by name: 1 passed.
  • cargo test -p victory-gpu --lib: 232 passed / 0 failed / 1 ignored (unpatched 63bcca4 here: 231).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7204720594 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3359#issuecomment-7204720594). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T22:29:11Z. --- Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX: - `hold::tests::unreadable_memory_holds_the_queue_without_counting_as_unknown` by name: 1 passed. - `cargo test -p victory-gpu --lib`: 232 passed / 0 failed / 1 ignored (unpatched `63bcca4` here: 231). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. Synthetic only. AI-assisted.
fuzeofficlal commented 2026-11-26 23:39:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:39:51Z.

Review: APPROVED


Looks good — clean, targeted fix.

Checked crates/victory-gpu/src/hold.rs:46-65 together with its callers in crates/victory-gpu/src/queue.rs:191-246:

  • Unknown comparison functions (!(NEVER..=ALWAYS)) are checked first and still return None (counted in Pumped::unknown and treated as holding).
  • Valid comparisons against unreadable memory now return Some(false) instead of None, so Held::pump keeps the queue waiting without inflating unknown, Held::blocked (hold.rs:213) surfaces the unmet wait consistently, and queue.rs's 2 ms polling timer + 10 s VALVE safety valve handle later mapping or stuck waits cleanly.

Verification (2d906514):

  • cargo xtask policy and cargo clippy -p victory-gpu (default and --features diagnostics, --tests -- -D warnings): passed.
  • hold::tests:: (11/11): passed on both hardware GPU and WARP (--features diagnostics, VICTORY_D3D12_DEBUG=1).
  • Live Windows virtual-memory probe through crate::host::read_into covering PAGE_NOACCESS, PAGE_GUARD, MEM_DECOMMIT, unmapped 0x10000, and an 8-byte cross-page straddle across PAGE_READWRITE | PAGE_NOACCESS: all returned Some(false) with unknown == 0 and unblocked cleanly once recommitted and written.
<!-- greyfinch-sync:Marvisak/VIctory:review:6081562873 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3359#pullrequestreview-6081562873). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:39:51Z. **Review:** APPROVED --- Looks good — clean, targeted fix. Checked `crates/victory-gpu/src/hold.rs:46-65` together with its callers in `crates/victory-gpu/src/queue.rs:191-246`: - Unknown comparison functions (`!(NEVER..=ALWAYS)`) are checked first and still return `None` (counted in `Pumped::unknown` and treated as holding). - Valid comparisons against unreadable memory now return `Some(false)` instead of `None`, so `Held::pump` keeps the queue waiting without inflating `unknown`, `Held::blocked` (`hold.rs:213`) surfaces the unmet wait consistently, and `queue.rs`'s 2 ms polling timer + 10 s `VALVE` safety valve handle later mapping or stuck waits cleanly. Verification (`2d906514`): - `cargo xtask policy` and `cargo clippy -p victory-gpu` (default and `--features diagnostics`, `--tests -- -D warnings`): passed. - `hold::tests::` (11/11): passed on both hardware GPU and WARP (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1`). - Live Windows virtual-memory probe through `crate::host::read_into` covering `PAGE_NOACCESS`, `PAGE_GUARD`, `MEM_DECOMMIT`, unmapped `0x10000`, and an 8-byte cross-page straddle across `PAGE_READWRITE | PAGE_NOACCESS`: all returned `Some(false)` with `unknown == 0` and unblocked cleanly once recommitted and written.
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/3359:upstream-pr/3359'
git switch 'upstream-pr/3359'

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