hle/dstorage: fix queue error reset, event handle duplication, close/release races, and pointer validation #80
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/81"
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 ivall/xcl. Originally posted by certified-retart on 2026-11-23T01:52:59Z.
Summary
Fixes several queue lifecycle, error-reporting, and pointer-validation bugs in
crates/xcl/src/hle/dstorage.rs:RetrieveErrorRecordnever cleared errors or reseterror_event:ResetEvent(q.error_event)underq.errors.lock()(the same mutex held byQueueInner::failwhen callingSetEvent, avoiding lost notifications).GetErrorEventreturned the internalHANDLEdirectly:error_eventwithDuplicateHandle(..., DUPLICATE_SAME_ACCESS)(matchingfile_get_handle), so the caller can close its returned handle viaCloseHandlewithout invalidating the queue's internal event or causing a double-close inQueueInner::drop.Release()could leak the worker thread andQueueInner:refs.load() == 1pre-check beforefetch_subwith a single atomicfetch_sub(1, Ordering::AcqRel) - 1 == 0check so exactly one thread takesworkerand tears down theArc<QueueInner>↔ worker thread cycle.Close()vs.Enqueue*()/Submit()races and in-flight worker completion:workerthenpending(matchingsubmit()'s lock order) inqueue_closeand checkedclosedunder the respective locks insubmit(),enqueue(), andenqueue_request(), preventing post-close enqueues or worker respawns.closedis set inQueueInner::run(marking remaining submitted statusesE_QUEUE_CLOSED) and waited outside queue locks on aworker_activecondvar inqueue_closeso no worker touches caller buffers afterClose()returns (including for concurrentClose()callers).workerbefore dropping any unsent batch on spawn/send failure so fenceRelease()cannot re-enter while holding the mutex.Entry::Refusedso errors are published in queue order (and skipped if closed before execution).readable()andstatus_vtbl()inqueue_enqueue_status, andreadable()on fence + vtable inqueue_enqueue_signal.Tests
error_record_resets_after_retrieval_and_event_is_duplicatedqueue_release_concurrent_breaks_worker_cyclequeue_validates_status_and_fence_pointers_and_closed_rejects_workcargo test -p xcl --lib hle::dstorage::tests -- --test-threads=2: 8 passed; 0 failed.Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T10:36:37Z.
Merged. Fortnite reads all of its data through DirectStorage – with this it still loads to its splash screen, no DirectStorage errors in the log. Tested on Windows 11 with an RX 9070 (RDNA4):
cargo test --workspacegreen with the retail samples (shader pack, console DLLs, texture archive), lib tests also withXCL_SPLIT_WAVE64=1; Unicorn Overlord, Minecraft and Fortnite run with this round merged. Thanks!