HLE: retain IDStorageFile references across queued DirectStorage read requests #2521
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2523"
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 Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T15:16:38Z.
Problem
dstorage::enqueue_requeststored rawRequestvalues without callingAddRefon file-backedrequest.source(Instance<File>), unlikeenqueue_statuswhich retains itsStatusArray.Under DirectStorage / COM rules, a caller may call
Release()on anIDStorageFileimmediately after enqueueing reads. Doing so dropsBox<Instance<File>>and closes the underlying OS file handle while the request is still queued or running on a worker thread, causing a heap use-after-free.Fix
ReadRequestwrappingRequest+ optionalInstance<File>reference:ReadRequest::newcallsadd_ref_instancefor non-null file-backed requests, andDropreleases the reference (covering completion, closed lanes, and queue teardown).execute()finishes and beforelanes.finish()publishes status completion so callers see the OS handle closed once status reportsS_OK.Testing
queued_file_read_survives_caller_releasing_fileincrates/victory-hle/src/modules/dstorage.rs.cargo test -p xtask --lockedpasses asset policy.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:53:25Z.
Automated triage for the maintainers. Needs work.
The change itself reads cleanly:
ReadRequestin crates/victory-hle/src/modules/dstorage.rs takes a reference on the file inenqueue_requestand drops it afterexecuteor when the request is discarded. But it changes runtime behaviour on an assumption the code on main explicitly makes the other way (read_into: "a file object we created; the title keeps it open"), and the PR gives no evidence that the title, or the real runtime, releases a file while reads on it are still queued, or that queued requests keep the file alive. The new test asserts the new reference count rather than a documented behaviour. What would move this forward: a reference (public documentation of the queue's file lifetime rules, or a trace showing the title releasing a file with reads in flight). CI: thecheckjob passes.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-25T20:05:31Z.
Closing per triage — checked Microsoft's DirectStorage documentation and confirmed the caller is required to keep
IDStorageFilealive until queued requests complete, matchingmain's existing assumption. Thanks for the review!Pull request closed