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

+12 -1
View File
@@ -1099,6 +1099,7 @@ mod tests {
/// driver is what a run with `VICTORY_INPLACE_PROBE=1` adds.
#[test]
fn warp_probe_opens_title_like_memory_and_the_gpu_sees_its_bytes() {
let _turn = crate::indirect::tests::warp_turn();
let Some(device) = warp() else { return };
if device.cast::<ID3D12Device13>().is_err() {
eprintln!("no ID3D12Device13 here: parts of an allocation cannot be opened");
@@ -1122,6 +1123,7 @@ mod tests {
/// whole is turned down without asking the host.
#[test]
fn warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset() {
let _turn = crate::indirect::tests::warp_turn();
let Some(device) = warp() else { return };
if device.cast::<ID3D12Device13>().is_err() {
return;
@@ -1142,7 +1144,16 @@ mod tests {
assert!(same((start + 16) as *const u8, &[0xa5; 64]), "the GPU's write is at the title's address");
drop(placed);
// Half of it decommitted: turned down, the host not asked.
assert_ne!(mem::VirtualFree(base.add(2 * K64).cast(), K64, mem::MEM_DECOMMIT), 0);
// The heap lets go of the pages a moment after its last
// reference, if the adapter is busy with other tests' work.
let gone = (0..500).any(|_| {
let done = mem::VirtualFree(base.add(2 * K64).cast(), K64, mem::MEM_DECOMMIT) != 0;
if !done {
std::thread::sleep(std::time::Duration::from_millis(10));
}
done
});
assert!(gone, "the heap keeps the pages");
assert!(matches!(place_part(&device, start, len), Err(None)));
mem::VirtualFree(base.cast(), 0, mem::MEM_RELEASE);
}