HLE: retain IDStorageFile references across queued DirectStorage read requests #2523
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2523
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2523/head"
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?
@reeledMarek on GitHub · 2026-11-25 15:16 UTC · original
reeledMarek:fix/hle-dstorage-file-lifetime→main· +74 −17 · 1 files · 1 commits · closed without mergingProblem
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.@Marvisak on GitHub · 2026-11-25 15:53 UTC · original
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
@reeledMarek on GitHub · 2026-11-25 20:05 UTC · original
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