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

+16 -1
View File
@@ -491,7 +491,7 @@ fn uav_barrier() -> D3D12_RESOURCE_BARRIER {
}
#[cfg(test)]
mod tests {
pub(crate) mod tests {
use super::*;
use windows::Win32::Foundation::HANDLE;
use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0;
@@ -521,10 +521,24 @@ void main() {
event: HANDLE,
clamp: Clamp,
worker: Clamp,
/// Last, so given up last.
_turn: std::sync::MutexGuard<'static, ()>,
}
/// The software adapter is one test's at a time. Two tests that compile
/// and run shaders on it at once (it is one device for the process) make
/// `d3d10warp.dll` (10.0.26100) crash now and then: access violations in
/// its own shader compiler, on its own worker threads, in 12% of runs of
/// all tests and 3% of runs of these alone on two threads; none in 100
/// runs one after the other.
pub(crate) fn warp_turn() -> std::sync::MutexGuard<'static, ()> {
static TURN: std::sync::Mutex<()> = std::sync::Mutex::new(());
TURN.lock().unwrap_or_else(|e| e.into_inner())
}
impl WarpHarness {
fn new() -> Option<Self> {
let turn = warp_turn();
// SAFETY: plain DXGI WARP query and D3D12 test harness setup.
unsafe {
let factory: IDXGIFactory4 =
@@ -563,6 +577,7 @@ void main() {
event,
clamp,
worker,
_turn: turn,
})
}
}