HLE/dstorage: retain IDStorageFile COM reference across queued reads #621
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!621
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-621"
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?
@AscilCH on GitHub · 2026-11-25 03:25 UTC · original
AscilCH:fix/hle-dstorage-retain-file-ref-on-enqueue→main· +120 −19 · 1 files · 1 commits · openProblem
In
crates/victory-hle/src/modules/dstorage.rs,enqueue_statusproperly retained a COM reference onIDStorageStatusArrayviaadd_ref_instance/Status::drop, whileenqueue_requestpushed rawCopyRequeststructs into the scheduler without retainingrequest.sourcewhen backed by anIDStorageFile.Under DirectStorage COM rules, titles may call
IDStorageFile::Release()immediately afterIDStorageQueue::EnqueueRequest()(even beforeSubmit()), relying on the queue to hold an internal reference until the read finishes. Without retaining the file,Release()immediately freedInstance<File>and closed its OS file handle while the read sat inunsubmitted,reads, or a running workerJob, causing a worker use-after-free inread_into().Fix
QueuedReadholdingrequest: Requestandfile: Option<FileRef>, callingadd_ref_instanceon construction for supported file-backed requests (options & !SUPPORTED == 0 && options & MEMORY_SOURCE == 0 && !source.is_null()) andreleaseonrelease_file()/Drop.job.request.release_file()inwork()afterexecute()and before lockinglanes/ callinglanes.finish(), ensuring the COM refcount and OS file handle are released before status completion becomes visible to the title.releasing_file_after_enqueue_keeps_it_alive_until_read_completesandclosing_queue_with_unsubmitted_file_read_releases_file_ref.Verification
cargo test -p victory-hle --locked dstorage -- --test-threads=1: 16 passed, 0 failedcargo xtask policy: 169 files okcargo clippy -p victory-hle --no-deps --all-targets --locked -- -D warnings: cleancargo clippy -p victory-hle --all-targets --all-features --locked -- -D warnings: clean(AI-assisted; synthetic unit tests only, no game data.)
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.