Skip to content

Views guarded while they are mapped stay writable - #102

Open
Castyan wants to merge 2 commits into
DexNom:mainfrom
Castyan:watch-guard-race
Open

Castyan wants to merge 2 commits into
DexNom:mainfrom
Castyan:watch-guard-race

Conversation

@Castyan

@Castyan Castyan commented Nov 26, 2026

Copy link
Copy Markdown

On main, independent of #61 and #64. Split out of #64.

What

  • 935bf44 Views guarded while they are mapped stay writable. Ported from avatarmanz/VIctory-7900XTX@160d222 (its watch part, adapted to our aliased blocks and clean sets). A refresh on another thread could guard a view's new blocks between the mapping and its notification. The notification then forgot them while leaving them read-only, so the title's next write was an access violation nobody caught. A test reproduced it as a STATUS_ACCESS_VIOLATION before the fix. The watch tests now forget their guards before freeing their memory.
  • 1240d8b frame's next-tick wait is checked by its time-out, not the wall clock.

Before: watch::tests::a_view_mapped_beside_a_guarded_one_makes_it_check_again failed about 1 run in 100 under load. After: 0 failures in 100 pairs of the victory-gpu test binary run two at a time, plus 100 ordinary runs (measured on the #64 tree).

Checks (RTX 5060, at 1240d8b on main)

cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean. cargo test --workspace --locked: 684 passed, 0 failed, 12 ignored.

🤖 Generated with Claude Code

Castyan and others added 2 commits November 26, 2026 20:29
The runtime maps a view and then tells the write watch (xmem's map). A
copy's refresh on another thread can guard the new blocks in between:
it finds them mapped, or committed where it knew them absent. The
telling then forgot them and left them read-only, so the title's next
write to one was an access violation nobody takes (the handler finds the
block neither guarded nor writable). A test does exactly that: it maps a
view, guards it, then tells the watch. Before, the view stayed read-only
and the write ended the process with STATUS_ACCESS_VIOLATION.

Told of a new view, the watch now gives the write access back
(title_memory_remapped). Before an unmapping it only forgets
(title_memory_unmapping, new): xmem's unmap uses it, and so does map
when committing the view fails and it goes back to a placeholder.

The watch's tests forget their guards before their memory is freed:
another test's memory could get the address and inherit them. The
journal test no longer expects the address's history to be empty.
Under two test binaries at once, of 200 pairs before, one run failed in
the watch (a_view_mapped_beside_a_guarded_one_makes_it_check_again);
none of 100 pairs and 100 plain runs after.

Ported from avatarmanz/VIctory-7900XTX 160d222 (its watch part, adapted
to our aliased blocks and clean sets).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tick test required the wait for the next tick to end within 50 ms,
which a loaded PC exceeds at times (2 of 150 runs with compilations
going). A wait ends on its tick only if the tick is no further than its
time-out, and the next tick is at most one interval (2 ms) away: with a
2 ms time-out it must return S_OK, whatever the scheduler does. That is
stricter than 50 ms and no longer timed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant