Views guarded while they are mapped stay writable; tests take turns on WARP

The runtime maps a view and then tells the write watch. A refresh on another
thread could guard the new blocks in between, and the telling then forgot
them and left them read-only: the title's next write to one was an access
violation nobody takes. Told of a new view, the watch now gives the write
access back; before an unmapping it only forgets, as before.

The test binary's random crashes were d3d10warp.dll's own, with two tests on
the software adapter at once: they take turns now. The watch's tests forget
their guards before their memory is freed (another test's memory could get
the address and inherit them), and three more are no longer tied to other
tests' memory, the adapter's other work or a busy PC's timing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
localandClaude Opus 5.5 committed 2026-11-24 22:09:38 -06:00
1 parent eb50022824
commit 63e18c7da0
6 files changed
+144 -32

No files matched your search

+22 -11
View File
@@ -226,18 +226,29 @@ mod tests {
// origin poll that times out (and starts the frame), then a
// blocking flip wait. Each flip takes its own tick.
const FLIP: u32 = 2;
assert_eq!(set_interval(null, null, 5_000, 3, 0), S_OK);
// (The ticks are far apart, and it may take a few tries: a busy PC
// wakes a wait tens of milliseconds late at times.)
assert_eq!(set_interval(null, null, 60_000, 3, 0), S_OK);
let mut token = 0;
let flips: Vec<u64> = (0..4)
.map(|_| {
let _ = wait(null, 0, 0, std::ptr::null(), TOKEN_ON_TIMEOUT, &mut token);
assert_eq!(
wait(null, FLIP, u32::MAX, std::ptr::null(), 0, &mut token),
S_OK
);
LAST[2].load(Ordering::Relaxed)
})
.collect();
let mut four = || -> Vec<u64> {
(0..4)
.map(|_| {
let _ = wait(null, 0, 0, std::ptr::null(), TOKEN_ON_TIMEOUT, &mut token);
assert_eq!(
wait(null, FLIP, u32::MAX, std::ptr::null(), 0, &mut token),
S_OK
);
LAST[2].load(Ordering::Relaxed)
})
.collect()
};
let mut flips = four();
for _ in 0..10 {
if flips.windows(2).all(|w| w[1] == w[0] + 1) {
break;
}
flips = four();
}
assert!(flips.windows(2).all(|w| w[1] == w[0] + 1), "{flips:?}");
// Even when a flip wait begins on the tick another just ended on.
let (tick, _) = next_tick(FLIP);