HLE/dstorage: retain IDStorageFile COM reference across queued reads #621
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from fxceless/victory-fork. Originally posted by AscilCH on 2026-11-25T03:25:56Z.
Problem
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
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.