fix(hle/dstorage): use-after-free of Instance<File> in queued requests and WALLS_FILES/factory resource leaks #319
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
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
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
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/Androtim--MiniVI#319
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@RUIZ-Enrique-25002136 on GitHub · 2026-12-02 09:14 UTC · original
Summary
Two memory/handle safety issues exist in
crates/victory-hle/src/modules/dstorage.rs:Instance<File>:enqueue_requestcopies a rawRequestpointer (request.source) into the queue without incrementing theFileCOM refcount or releasing it on completion, unlikeenqueue_status.WALLS_FILESLeak / Address Aliasing & Factory Leaks on Nullout:open_filepushes(file as usize, kept)toWALLS_FILESunconditionally with no cleanup onFiledrop, andopen_file/create_status_array/create_queueallocateInstance/ Win32 eventHANDLE/ schedulerLanebefore checkingout.is_null().Evidence (
file:line& Code Proof)1. Use-After-Free of
Instance<File>in Queued Readscrates/victory-hle/src/modules/dstorage.rs:1516(enqueue_status, safe pattern): callsadd_ref_instance(array)and releases it inStatus::drop(dstorage.rs:1479-1483).crates/victory-hle/src/modules/dstorage.rs:1497-1504(enqueue_request): Whenrequest.options & MEMORY_SOURCE == 0,release::<File>(dstorage.rs:99-107) freesBox<Instance<File>>as soon as the caller drops itsIDStorageFilerefcount to 0 (e.g., right afterSubmit()). Worker threads later dereferencerequest.source.cast::<Instance<File>>()inread_into(dstorage.rs:2035) andErrorRecord::of(dstorage.rs:638).2.
WALLS_FILESGrowth / Address Aliasing & Null-outFactory Leakscrates/victory-hle/src/modules/dstorage.rs:163-164(open_file) &847-860(walls_request):open_fileunconditionally appends(file as usize, kept)toWALLS_FILESeven whenVICTORY_WALLS_TRACEis off, andFilenever removes its entry on release.walls_requestscansfiles.iter().find(|f| f.0 == source)from the front, matching stale freed entries when heap addresses are reused.crates/victory-hle/src/modules/dstorage.rs:164(open_file),187(create_status_array),229-243(create_queue):All three allocate
Instance::create(...)(andcreate_queue:229-232creates a Win32 event viaCreateEventWand inserts aLaneintolanes.lanes) beforeput(out, ...)checksout.is_null()and returnsE_POINTER.Impact
IDStorageFilewhile requests referencing it remain queued or in flight.WALLS_FILESgrowth, misattributed file paths on pointer reuse, and leakedInstance/ Win32 eventHANDLE/ schedulerLaneobjects onE_POINTER.AI-Ready Fix Specification
enqueue_request, whenrequest.options & MEMORY_SOURCE == 0 && !request.source.is_null(), calladd_ref_instance(request.source.cast::<Instance<File>>())and attach an RAII guard (orimpl DroponReadandJob, transferring ownership when moving fromReadtoJobinLanes::start) that callsrelease::<File>on completion orclose_lane.if out.is_null() { return E_POINTER; }at the entry ofopen_file,create_status_array, andcreate_queuebefore allocating anyInstance,CreateEventWhandle, orLane.WALLS_FILES(switched to aHashMap<usize, String>) whenwalls_trace() > 0, and remove the entry whenFileis dropped inrelease::<File>.release::<File>and null-outearlyE_POINTER.@github-actions[bot] on GitHub · 2026-12-02 09:14 UTC · original
Please attach both logs from the run that went wrong so we can investigate without guessing. Paste
%LOCALAPPDATA%into the File Explorer address bar to find them:%LOCALAPPDATA%\victory\logs\: the newest.logfrom that run (the console prints its path at startup on theLog: ...line).%LOCALAPPDATA%\victory\data\<TitleId>\crashes.log, and if present, the newest.crash.login%LOCALAPPDATA%\victory\data\<TitleId>\temp\.Please also include:
play-minivi.ps1preset, DLSS/FG/RT, customVICTORY_*vars) and commit SHA(Clean-room policy: please only attach text logs/screenshots — do not upload copyrighted game files or executables.)
github-bot referenced this issue2026-12-02 13:30:02 +00:00