From bedd85e4edb7ab9b71d261507427f71bf3569e51 Mon Sep 17 00:00:00 2001 From: Exorion <8749995+Exorion1er@users.noreply.github.com> Date: Tue, 24 Nov 2026 01:15:23 +0100 Subject: [PATCH] GPU: keep a guarded block's write fault from being declined in a race The write-fault handler opens the guarded block under the guard lock, then, if it found none, asks whether the address is writable without it. Between the two, another thread's fault could open the block and a copy could guard it again: the handler then saw a read-only block that is in fact ours, declined the fault, and the title crashed on a plain write (seen 1-3 minutes into the world under Wine, where exception dispatch is slow enough to hit it every run). The lock is now held across both checks, so a block that is not ours while it is held really is not ours. Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/watch.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/victory-gpu/src/watch.rs b/crates/victory-gpu/src/watch.rs index a64e3e3..1cbe2b7 100644 --- a/crates/victory-gpu/src/watch.rs +++ b/crates/victory-gpu/src/watch.rs @@ -247,12 +247,15 @@ fn install() { return EXCEPTION_CONTINUE_SEARCH; } let at = r.ExceptionInformation[1]; - if open(&mut guards(), at, at + 1) { + // Held across both checks: another thread may have opened the block + // since this one faulted, and a copy may have guarded it again since + // (then it is ours again, not read-only for some other reason). + let mut g = guards(); + if open(&mut g, at, at + 1) { #[cfg(feature = "diagnostics")] crate::copystat::add(crate::copystat::C::GuardFaults, 1); return EXCEPTION_CONTINUE_EXECUTION; } - // Another thread may have opened the block since this one faulted. if writable(at) { EXCEPTION_CONTINUE_EXECUTION } else {