fix(gpu): missing WakeByAddressAll in fence::written and 10s MADE stall on non-sharing I/O errors in pipeline::samplers::open_alone #318

Closed
opened 2026-12-02 09:14:13 +00:00 by RUIZ-Enrique-25002136 · 1 comment
RUIZ-Enrique-25002136 commented 2026-12-02 09:14:13 +00:00 (Migrated from github.com)
Contributor

Imported from Androtim/MiniVI. Originally posted by RUIZ-Enrique-25002136 on 2026-12-02T09:14:13Z.


Summary

Two synchronization/stall bugs exist in crates/victory-gpu:

  1. fence::written updates a fence's value and signals registered Win32 events, but omits WakeByAddressAll (unlike fence::set), stranding WaitOnAddress waiters on bottom-of-pipe fence writes.
  2. pipeline::samplers::open_alone retries for 10 full seconds while holding the global MADE mutex on any std::fs::OpenOptions::open error, rather than only retrying on ERROR_SHARING_VIOLATION (32).

Evidence (file:line & Code Proof)

1. Missing WakeByAddressAll in fence::written

  • crates/victory-gpu/src/fence.rs:198-203 (fence::set):
    drop(waiters);
    #[cfg(windows)]
    unsafe {
        windows_sys::Win32::System::Threading::WakeByAddressAll((&raw const fence.value).cast());
    }
    
  • crates/victory-gpu/src/fence.rs:209-229 (fence::written):
    let mut waiters = fence.waiters.lock().unwrap_or_else(|e| e.into_inner());
    let value = fence.value.load(Ordering::Acquire);
    waiters.retain(|&(wanted, event)| {
        let reached = wanted <= value;
        if reached {
            set_event(event);
        }
        !reached
    });
    // Missing WakeByAddressAll((&raw const fence.value).cast())
    
    fence::block_until (fence.rs:158-163) waits on &fence.value via WaitOnAddress(..., 10), and guest code can also wait directly via WaitOnAddress(..., INFINITE).

2. Unfiltered 10s Retry Under MADE Mutex in pipeline::samplers::open_alone

  • crates/victory-gpu/src/pipeline/samplers.rs:151-170 (open_alone):
    loop {
        match std::fs::OpenOptions::new().read(true).write(true).create(true).truncate(false).share_mode(0).open(dir.join(FILE)) {
            Ok(file) => return Some(file),
            Err(e) if began.elapsed() < Duration::from_secs(10) => {
                // (32: another process has it open.)
                let _ = e;
                std::thread::sleep(Duration::from_millis(5));
            }
            Err(e) => { ... return None; }
        }
    }
    
    Compare with crates/victory-gpu/src/pipeline/library.rs:103, which gates retries specifically on e.raw_os_error() == Some(32) (ERROR_SHARING_VIOLATION). Here sync() calls open_alone while holding the global MADE mutex (samplers.rs:176).

Impact

  • fence::written: unnecessary 10 ms slices in fence::block_until and potential indefinite hangs for guest WaitOnAddress(..., INFINITE) waits on bottom-of-pipe fence writes.
  • open_alone: permanent I/O errors (ERROR_ACCESS_DENIED, ERROR_PATH_NOT_FOUND, read-only directory) stall prime() and every unseen static-sampler know() call for 10 seconds while blocking all shader/pipeline worker threads on MADE.

AI-Ready Fix Specification

  1. In crates/victory-gpu/src/fence.rs (fence::written), capture let addr = (&raw const fence.value).cast();, drop waiters and live, and call windows_sys::Win32::System::Threading::WakeByAddressAll(addr); under #[cfg(windows)] (matching fence::set).
  2. In crates/victory-gpu/src/pipeline/samplers.rs (open_alone), gate the retry arm on e.raw_os_error() == Some(32) && began.elapsed() < Duration::from_secs(10) so permanent errors fail fast.
  3. Verify with cargo clippy --workspace --all-targets --locked -- -D warnings and cargo test -p victory-gpu --locked -- --test-threads=1 on Windows CI.
<!-- greyfinch-sync:Androtim/MiniVI:issue:6741194146 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/issues/318). Originally posted by [RUIZ-Enrique-25002136](https://github.com/RUIZ-Enrique-25002136) on 2026-12-02T09:14:13Z. --- ## Summary Two synchronization/stall bugs exist in `crates/victory-gpu`: 1. `fence::written` updates a fence's value and signals registered Win32 events, but omits `WakeByAddressAll` (unlike `fence::set`), stranding `WaitOnAddress` waiters on bottom-of-pipe fence writes. 2. `pipeline::samplers::open_alone` retries for 10 full seconds while holding the global `MADE` mutex on **any** `std::fs::OpenOptions::open` error, rather than only retrying on `ERROR_SHARING_VIOLATION` (`32`). ## Evidence (`file:line` & Code Proof) ### 1. Missing `WakeByAddressAll` in `fence::written` - **`crates/victory-gpu/src/fence.rs:198-203` (`fence::set`):** ```rust drop(waiters); #[cfg(windows)] unsafe { windows_sys::Win32::System::Threading::WakeByAddressAll((&raw const fence.value).cast()); } ``` - **`crates/victory-gpu/src/fence.rs:209-229` (`fence::written`):** ```rust let mut waiters = fence.waiters.lock().unwrap_or_else(|e| e.into_inner()); let value = fence.value.load(Ordering::Acquire); waiters.retain(|&(wanted, event)| { let reached = wanted <= value; if reached { set_event(event); } !reached }); // Missing WakeByAddressAll((&raw const fence.value).cast()) ``` `fence::block_until` (`fence.rs:158-163`) waits on `&fence.value` via `WaitOnAddress(..., 10)`, and guest code can also wait directly via `WaitOnAddress(..., INFINITE)`. ### 2. Unfiltered 10s Retry Under `MADE` Mutex in `pipeline::samplers::open_alone` - **`crates/victory-gpu/src/pipeline/samplers.rs:151-170` (`open_alone`):** ```rust loop { match std::fs::OpenOptions::new().read(true).write(true).create(true).truncate(false).share_mode(0).open(dir.join(FILE)) { Ok(file) => return Some(file), Err(e) if began.elapsed() < Duration::from_secs(10) => { // (32: another process has it open.) let _ = e; std::thread::sleep(Duration::from_millis(5)); } Err(e) => { ... return None; } } } ``` Compare with `crates/victory-gpu/src/pipeline/library.rs:103`, which gates retries specifically on `e.raw_os_error() == Some(32)` (`ERROR_SHARING_VIOLATION`). Here `sync()` calls `open_alone` while holding the global `MADE` mutex (`samplers.rs:176`). ## Impact - `fence::written`: unnecessary 10 ms slices in `fence::block_until` and potential indefinite hangs for guest `WaitOnAddress(..., INFINITE)` waits on bottom-of-pipe fence writes. - `open_alone`: permanent I/O errors (`ERROR_ACCESS_DENIED`, `ERROR_PATH_NOT_FOUND`, read-only directory) stall `prime()` and every unseen static-sampler `know()` call for 10 seconds while blocking all shader/pipeline worker threads on `MADE`. ## AI-Ready Fix Specification 1. In `crates/victory-gpu/src/fence.rs` (`fence::written`), capture `let addr = (&raw const fence.value).cast();`, drop `waiters` and `live`, and call `windows_sys::Win32::System::Threading::WakeByAddressAll(addr);` under `#[cfg(windows)]` (matching `fence::set`). 2. In `crates/victory-gpu/src/pipeline/samplers.rs` (`open_alone`), gate the retry arm on `e.raw_os_error() == Some(32) && began.elapsed() < Duration::from_secs(10)` so permanent errors fail fast. 3. Verify with `cargo clippy --workspace --all-targets --locked -- -D warnings` and `cargo test -p victory-gpu --locked -- --test-threads=1` on Windows CI.
github-actions[bot] commented 2026-12-02 09:14:23 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Androtim/MiniVI. Originally posted by github-actions[bot] on 2026-12-02T09:14:23Z.


Please attach both logs from the run that went wrong so we can investigate without guessing. Paste %LOCALAPPDATA% into the File Explorer address bar to find them:

  1. Play log in %LOCALAPPDATA%\victory\logs\: the newest .log from that run (the console prints its path at startup on the Log: ... line).
  2. Crash log: %LOCALAPPDATA%\victory\data\<TitleId>\crashes.log, and if present, the newest .crash.log in %LOCALAPPDATA%\victory\data\<TitleId>\temp\.

Please also include:

  • GPU & VRAM, Windows version (10 or 11)
  • MiniVI preset / launcher flags (play-minivi.ps1 preset, DLSS/FG/RT, custom VICTORY_* vars) and commit SHA

(Clean-room policy: please only attach text logs/screenshots — do not upload copyrighted game files or executables.)

<!-- greyfinch-sync:Androtim/MiniVI:comment:7340586859 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/issues/318#issuecomment-7340586859). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-02T09:14:23Z. --- Please attach both logs from the run that went wrong so we can investigate without guessing. Paste `%LOCALAPPDATA%` into the File Explorer address bar to find them: 1. **Play log** in `%LOCALAPPDATA%\victory\logs\`: the newest `.log` from that run (the console prints its path at startup on the `Log: ...` line). 2. **Crash log**: `%LOCALAPPDATA%\victory\data\<TitleId>\crashes.log`, and if present, the newest `.crash.log` in `%LOCALAPPDATA%\victory\data\<TitleId>\temp\`. Please also include: - **GPU & VRAM**, **Windows version** (10 or 11) - **MiniVI preset / launcher flags** (`play-minivi.ps1` preset, DLSS/FG/RT, custom `VICTORY_*` vars) and **commit SHA** *(Clean-room policy: please only attach text logs/screenshots — do not upload copyrighted game files or executables.)*
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Androtim/MiniVI#318
No description provided.