HLE: retain DirectStorage file references across queued reads #2441
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2441"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by fuzeofficlal on 2026-11-29T13:04:26Z.
Problem
enqueue_requestincrates/victory-hle/src/modules/dstorage.rscopied the rawRequeststruct (including itssourcefile pointer) without retaining a reference onInstance<File>. Unlikeenqueue_status(which callsadd_ref_instanceand releases onStatus::drop), if a title released its final reference to a file object after enqueueing/submitting a read,release::<File>dropped theInstance<File>and closed the underlying host file handles while the request was still queued or running, causing the worker thread to dereference freed memory inread_into,source_path, orErrorRecord::of.Fix
CopyHeldFile(Option<NonNull<Instance<File>>>)owned byReadand moved intoJob:add_ref_instanceon enqueue for file-backed non-null requests (options & MEMORY_SOURCE == 0).releaseinDropwhen the request completes, is rejected by a closed queue, or is discarded when the lane closes.Jobby value intoLanes::finish, construct anyErrorRecordwhilefileis still alive, and dropfilebefore callinglane.failed/lane.flush()so the host file handles are guaranteed closed before completion or error events are published to the title.request.sourceinread_into(returningErr(E_INVALIDARG)).Verification
modules::dstorage::tests(queued_reads_keep_the_file_open_until_completion,closing_a_queue_releases_unsubmitted_file_reads,read_into_rejects_a_null_source).VIctory-NVIDIA:cargo test --locked -p victory-hle --lib modules::dstorage::tests -- --test-threads=1cargo test --locked -p victory-hle -- --test-threads=1cargo clippy --locked -p victory-hle --all-targets(no new warnings)cargo run --quiet --locked -p xtask -- policy --stagedImported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-29T13:25:58Z.
Review: APPROVED
Tested locally merged onto
main(829188e9).crates/victory-hle/src/modules/dstorage.rs.cargo test -p victory-hle --lib dstoragepassed (32 passed; 0 failed; 2 ignored, including the newqueued_reads_keep_the_file_open_until_completionandclosing_a_queue_releases_unsubmitted_file_readstests) with 0 warnings invictory-hle.Important lifetime fix preventing use-after-release of DirectStorage file handles across queued reads. LGTM.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).