gpu(watch): re-publish placeholder holes missed in guard races #191

Closed
github-bot wants to merge 1 commit from gh-pr/191/head into gh-pr/191/base
Owner

@⁠Androtim on GitHub · 2026-11-30 03:13 UTC · original
Androtim:feat/iter188-watch-placeholder-race-fix → main · +93 −1 · 1 files · 1 commits · closed without merging

Summary

  • Add Guards::told to track absent blocks explicitly notified by title_memory_allocated (cleared on remap, free, kernel write, or reappearance).
  • During guard(), check whether remaining uncommitted unsure ranges are still placeholders; any absent placeholder blocks not in told are promoted back into held and PUBLISHED at the next query instead of staying stuck in repeated VirtualQuery syscalls after a race between unmapping and protection.
  • Added unit test watch::many_askers_tests::a_hole_noted_absent_in_a_race_is_known_at_the_next_asking.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy (311 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu watch:: -- --test-threads=1 (53 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings
**@⁠Androtim** on GitHub · 2026-11-30 03:13 UTC · [original](https://github.com/Androtim/MiniVI/pull/191) `Androtim:feat/iter188-watch-placeholder-race-fix` → `main` · +93 −1 · 1 files · 1 commits · closed without merging ## Summary - Add `Guards::told` to track absent blocks explicitly notified by `title_memory_allocated` (cleared on remap, free, kernel write, or reappearance). - During `guard()`, check whether remaining uncommitted `unsure` ranges are still placeholders; any `absent` placeholder blocks not in `told` are promoted back into `held` and `PUBLISHED` at the next query instead of staying stuck in repeated `VirtualQuery` syscalls after a race between unmapping and protection. - Added unit test `watch::many_askers_tests::a_hole_noted_absent_in_a_race_is_known_at_the_next_asking`. ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy` (`311 files ok`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu watch:: -- --test-threads=1` (`53 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:17:13 +00:00
github-bot closed this pull request 2026-12-01 20:17:13 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 04:04 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: needs-work · CI (check): passing

Reviewed crates/victory-gpu/src/watch.rs (CI is passing, and the new unit test a_hole_noted_absent_in_a_race_is_known_at_the_next_asking covers the single-threaded promotion/told path).

The idea of promoting absent placeholder holes back into Guards::held / PUBLISHED while respecting title_memory_allocated via Guards::told makes sense, but introducing promotion in guard() exposes two concrete race/invariant bugs:

  1. title_memory_allocated misses absent && !held blocks (crates/victory-gpu/src/watch.rs):
    title_memory_allocated only iterates g.held.range(...) before inserting into g.told. If a block is currently in g.absent but not in g.held — either because it was missed in a protect race, or because a concurrent guard() call has released GUARDS while running uncommitted_end / placeholder on unsure — title_memory_allocated will not insert it into g.told. The subsequent promotion loop in guard() then checks g.absent.contains(block) && !g.told.contains(block) and promotes the block into g.held and PUBLISHED anyway.
    Iterating g.absent.range(...) in title_memory_allocated (inserting into g.told, and removing from g.held + clearing PUBLISHED if present) closes both cases.

  2. guard()'s came loop can break the g.held ⊆ g.absent invariant (crates/victory-gpu/src/watch.rs):
    Because guard() now promotes absent blocks into g.held and sets PUBLISHED, two concurrent guard() calls can both snapshot the same block into unsure. If one promotes block to g.held + PUBLISHED and the other later observes it as committed (came) and runs g.absent.remove(block), block is left dangling in g.held and PUBLISHED. Since kernel_writing, title_memory_freed, and title_memory_changed all iterate g.absent.range(...) to clean up g.held/PUBLISHED, a dangling held/PUBLISHED entry will not be cleaned up by them and will cause published() to report a committed block as clean/known.
    Clearing g.held and PUBLISHED in the came loop (if g.held.remove(block) { PUBLISHED.clear(block); }) preserves the invariant.

(Minor note: in guard(), unsure currently runs placeholder(block) / NtQueryVirtualMemory even for blocks already in g.told, only to skip them later; skipping placeholder() for told blocks would avoid unnecessary syscalls.)

To change the verdict:

  • Update title_memory_allocated to mark all g.absent blocks in the range in g.told (while removing any present in g.held and clearing PUBLISHED).
  • In guard()'s for &(block, view) in &came loop, also remove block from g.held and clear PUBLISHED if it was present.
  • Add a unit test covering title_memory_allocated called on an absent && !held block so it is not promoted into g.held/PUBLISHED on the next guard() call.

Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-30 04:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/191#issuecomment-7268446777) <!-- minivi-triage v1 head=7fcbebc62a00db32db9ace72108e3fc02f5c1d8c verdict=needs-work ci=passing at=2026-11-30T04:05:12Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-work` · **CI (`check`):** `passing` Reviewed `crates/victory-gpu/src/watch.rs` (CI is passing, and the new unit test `a_hole_noted_absent_in_a_race_is_known_at_the_next_asking` covers the single-threaded promotion/told path). The idea of promoting `absent` placeholder holes back into `Guards::held` / `PUBLISHED` while respecting `title_memory_allocated` via `Guards::told` makes sense, but introducing promotion in `guard()` exposes two concrete race/invariant bugs: 1. **`title_memory_allocated` misses `absent && !held` blocks (`crates/victory-gpu/src/watch.rs`)**: `title_memory_allocated` only iterates `g.held.range(...)` before inserting into `g.told`. If a block is currently in `g.absent` but not in `g.held` — either because it was missed in a `protect` race, or because a concurrent `guard()` call has released `GUARDS` while running `uncommitted_end` / `placeholder` on `unsure` — `title_memory_allocated` will not insert it into `g.told`. The subsequent promotion loop in `guard()` then checks `g.absent.contains(block) && !g.told.contains(block)` and promotes the block into `g.held` and `PUBLISHED` anyway. Iterating `g.absent.range(...)` in `title_memory_allocated` (inserting into `g.told`, and removing from `g.held` + clearing `PUBLISHED` if present) closes both cases. 2. **`guard()`'s `came` loop can break the `g.held ⊆ g.absent` invariant (`crates/victory-gpu/src/watch.rs`)**: Because `guard()` now promotes `absent` blocks into `g.held` and sets `PUBLISHED`, two concurrent `guard()` calls can both snapshot the same `block` into `unsure`. If one promotes `block` to `g.held` + `PUBLISHED` and the other later observes it as committed (`came`) and runs `g.absent.remove(block)`, `block` is left dangling in `g.held` and `PUBLISHED`. Since `kernel_writing`, `title_memory_freed`, and `title_memory_changed` all iterate `g.absent.range(...)` to clean up `g.held`/`PUBLISHED`, a dangling `held`/`PUBLISHED` entry will not be cleaned up by them and will cause `published()` to report a committed block as clean/known. Clearing `g.held` and `PUBLISHED` in the `came` loop (`if g.held.remove(block) { PUBLISHED.clear(block); }`) preserves the invariant. *(Minor note: in `guard()`, `unsure` currently runs `placeholder(block)` / `NtQueryVirtualMemory` even for blocks already in `g.told`, only to skip them later; skipping `placeholder()` for `told` blocks would avoid unnecessary syscalls.)* ### To change the verdict: - Update `title_memory_allocated` to mark all `g.absent` blocks in the range in `g.told` (while removing any present in `g.held` and clearing `PUBLISHED`). - In `guard()`'s `for &(block, view) in &came` loop, also remove `block` from `g.held` and clear `PUBLISHED` if it was present. - Add a unit test covering `title_memory_allocated` called on an `absent && !held` block so it is not promoted into `g.held`/`PUBLISHED` on the next `guard()` call. --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 01:39 UTC · original

Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

**@⁠Androtim** on GitHub · 2026-12-01 01:39 UTC · [original](https://github.com/Androtim/MiniVI/pull/191#issuecomment-7297738831) Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

Pull request closed

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/Androtim--MiniVI!191
No description provided.