fix(gpu/texture/ahead): TOCTOU race in claim()/listed() and failed copy-queue batches still flip descriptors #317
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Androtim/MiniVI. Originally posted by RUIZ-Enrique-25002136 on 2026-12-02T09:14:12Z.
Summary
Two concurrency/error-handling bugs exist in the asynchronous copy-queue texture uploader (
crates/victory-gpu/src/texture/ahead.rs):copy.ahead = PENDINGand inserting the job intoON_THEIR_WAYallows concurrent copy-queue and direct-queue uploads/state transitions to the sameID3D12Resource.Worker::copy(&jobs, value)returnsErr,Worker::workstill callsfinish(jobs)unconditionally, marking failed textures uploaded and flipping shader-visible descriptors to uninitialized VRAM (and resetting a potentially still-in-flight command allocator).Evidence (
file:line& Code Proof)Bug A — TOCTOU Window Between
claim()andlisted()crates/victory-gpu/src/texture/ahead.rs:107-110, 125-147(claim):crates/victory-gpu/src/texture/ahead.rs:177-187(listed): Between CASNONE -> PENDING(line 125) andway.push(...)(line 144),claim()allocates staging outsideON_THEIR_WAY. A concurrentlisted(©)seesErr(PENDING), locksON_THEIR_WAY, finds no entry forcopy.serial, and returns immediately—allowing the direct-queue list to copy intocopy.textureconcurrently with the copy-queue upload. Likewise, a concurrentclaim()at lines 107-109 seesPENDINGwith noON_THEIR_WAYentry and falls back to a direct-queue upload.Bug B — Unconditional
finish(jobs)& Allocator Reset AfterWorker::copyErrorcrates/victory-gpu/src/texture/ahead.rs:259-264(Worker::work) &320-358(finish):finish(jobs)unconditionally setsjob.staging.uploaded.store(true, Relaxed),job.staging.dirty.store(false, Relaxed),job.copy.ahead.store(DONE, Release), and runs alljob.thendescriptor-flip callbacks even whenself.copyfailed. Moreover, ifself.copyfailed afterExecuteCommandLists(e.g.,SignalorSetEventOnCompletionfailed), the next iteration callsself.allocator.Reset()without confirmed GPU completion.Impact
VICTORY_UPLOAD_AHEAD=1.Worker::copypermanently suppresses re-uploads for every texture in the batch and exposes uninitialized VRAM to shaders.AI-Ready Fix Specification
claim()/listed()synchronization: Track an in-flight reservation state forcopy.serial(e.g., insert a reservation entry in a set/map guarded byON_THEIR_WAYbefore/atomically withNONE -> PENDING, and notifyLANDEDifstaging()returnsNoneor the job is turned down) solisted()andclaim()wait onLANDEDwhenevercopy.ahead == PENDINGuntil the job either entersON_THEIR_WAYor reverts toNONE/LISTED.Worker::work/finish: Passok: boolintofinish(jobs, ok). When!ok:BYTES, remove entries fromON_THEIR_WAY, revertjob.copy.aheadtoLISTED(orNONE), leaveuploaded = falseanddirty = true, do not runjob.thencallbacks, and notifyLANDED.ExecuteCommandListsran inWorker::copybeforeSignal/SetEventOnCompletionfailed, retire/recreate the command allocator instead of resetting it immediately.Imported from Androtim/MiniVI. Originally posted by github-actions[bot] on 2026-12-02T09:14:20Z.
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:%LOCALAPPDATA%\victory\logs\: the newest.logfrom that run (the console prints its path at startup on theLog: ...line).%LOCALAPPDATA%\victory\data\<TitleId>\crashes.log, and if present, the newest.crash.login%LOCALAPPDATA%\victory\data\<TitleId>\temp\.Please also include:
play-minivi.ps1preset, DLSS/FG/RT, customVICTORY_*vars) and commit SHA(Clean-room policy: please only attach text logs/screenshots — do not upload copyrighted game files or executables.)