Repository navigation
hle/dstorage: fix queue error reset, event handle duplication, close/release races, and pointer validation - #81
Merged
Conversation
…release races, and pointer validation
Collaborator
|
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): |
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…cl-dev#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (xcl-dev#59, xcl-dev#60, xcl-dev#68, xcl-dev#69, xcl-dev#78, xcl-dev#81, xcl-dev#84, xcl-dev#88, xcl-dev#89, xcl-dev#93, xcl-dev#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at xcl-dev#59 and the original base-table stub for slots >= scanned). Slot xcl-dev#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
vincentes
added a commit
to vincentes/xcl-wasm
that referenced
this pull request
Nov 24, 2026
In the software D3D12.X device: - The console's frame clock (device xcl-dev#78–xcl-dev#81): SetFrameIntervalX, ScheduleFrameEventX, WaitFrameEventX (the origin hands out the frame's token; S_FALSE at the timeout) and GetFrameStatisticsX, on guest time. The ancillary handles of an event are not signalled. - PresentX (queue xcl-dev#30) goes through the queue like everything else; when the queue gets to it the frame is flipped for the statistics and the back buffer's memory is kept as `d3d.frame` (width, height, format, pixels) for the host to show. Textures are linear in this device: the console's tiling is not modelled. - ClearRenderTargetView (list xcl-dev#52) fills a target of 8 bits a channel; CreateRenderTargetView remembers which resource a descriptor shows. - The device answers QueryInterface for IDXGIDevice / 1 / 2 with an object of that layout; its adapter has the device's LUID and no output. Measured on macOS (aarch64): the test title's "frame clock + PresentX of the title's back buffer" passes, 41 checks in all. `cargo test -p xcl-guest`: 47 passed, 0 failed, run on the staged tree in a separate copy: the working tree does not build at the moment (another agent's half-written crates/xcl/src/hle/export_names.rs). Co-Authored-By: Claude Fable 5.2 <[email protected]>
Michael-Glaser
added a commit
to Michael-Glaser/xcl
that referenced
this pull request
Nov 24, 2026
…vall#104) On newer GDK runtimes (QUEUE_SHIFTED), 20 command list console methods shift up by +2 via NEWER_LIST_SLOTS, leaving 11 older slots (ivall#59, ivall#60, ivall#68, ivall#69, ivall#78, ivall#81, ivall#84, ivall#88, ivall#89, ivall#93, ivall#94) without another shifted method taking their old index. Those slots remained wired directly to the older layout's handlers, so a newer-layout call hit the wrong method. Wrap those orphaned slots in make_layout_split so newer-layout title calls go to a logged stub while older-layout titles keep the handler and non-title callers keep their PC target (including cl_execute_indirect at ivall#59 and the original base-table stub for slots >= scanned). Slot ivall#10 (Reset) stays Reset on both layouts and is not orphaned. Assisted-by: Antigravity (Gemini 4 Neon)
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
…nd backend 1d split 1 of 2 (honest split: route halves stay under the line budget). Device frame-clock slots route on Vulkan objects only: xcl-dev#78 SetFrameIntervalX, xcl-dev#79 ScheduleFrameEventX (with ancillary handle routing), xcl-dev#80 WaitFrameEventX, xcl-dev#81 GetFrameStatisticsX — thin adapters over the Linux twin (d3d12x_frame_linux). register_ancillary remembers the schedule block's handles per type (E_INVALIDARG past the 63-handle cap, like Windows; Linux trusts the block — readable() is windows-only); the clock thread signals each with kernelx SetEvent at fire. Unscheduling clears. Null device keeps logging stubs: no behavior change while XCL_VULKAN_BACKEND is unset. Queue xcl-dev#30 PresentX + the real present follow in 1d(ii). Failing-first: the routing test failed pre-fix (E0599 no VulkanQueue; then E_FAIL at xcl-dev#81 with PresentX still stubbed); passes now (slots + ancillary-signal asserts, serialised on CLOCK_SERIAL with the twin's tests). Gates: check -p xcl --tests EXIT 0 (40 pre-existing warnings, none new); check --workspace EXIT 0; lib 794 passed/0 failed/1 ignored (+1 new). Title e2e + retail controls run at 1d(ii).
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
…nd backend 1d split 2 of 2 (honest split: a real WSI staging present is indivisible at ~350 lines — slicing further would leave dead code or fake success). Queue xcl-dev#30 PresentX routes on Vulkan queues only (VulkanQueue from a Vulkan device; null queues keep the logging stub): plane 0's resource bytes (R8G8B8A8 2D texture; committed Map backing or placed title memory, unmodelled shapes present nothing) upload through the new vulkan_present::present_rgba_image — X window + swapchain, staging-buffer copy, one acquire/submit/present — then mark_flipped(token) for xcl-dev#81. Headless ('no ' display/WSI/device) still flips + S_OK: a console present never fails. Null default unchanged. Failing-first: the 1d routing test failed pre-route (E_FAIL at xcl-dev#81, no flip); passes now end to end (set/schedule/wait/token/present/stats), and present_rgba_image proved REAL on hardware (Intel Arc split-32, 2x2 frame presented in 0.11s, no SKIPPED). Gates: check -p xcl --tests EXIT 0 (40 pre-existing warnings, none new); check --workspace EXIT 0; lib 795 passed/0 failed/1 ignored (--test-threads=4; default-thread full runs flake pre-existing, base too). Title e2e delta 0 (12 FAILs null, stashed baseline 12; 10 on Vulkan, both baselines); FAIL #2 still-failing: the title dies at DXGI GetAdapter/GetDesc before reaching the routed slots (no xcl-dev#78/PresentX in xcl.log) — next slice. Retail HOLDS (SIGSEGV exe+0x2237320, exit 139, called_stubs 20, 0 d3d12, xgr exactly XAsync/XNetworking/XUser).
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 27, 2026
List slots 28/29 count draws into banked occlusion samples and slot 30 writes them as u64s into the results buffer's committed backing (SAMPLES_PER_DRAW each: outer = 2N, inner = single = N, so the title's nesting assert passes on both backends). PC draws (slots 12/13) and console DrawIndexedX (xcl-dev#81) feed the same counter. CopyTextureRegion from a committed 2D RGBA8 render target stashes a pending copy at record time; the S4 Execute flush fills it from the submit's pixels row by row (pitch-aware), so Map reads real offscreen pixels on Vulkan (null Executes drain unwritten — readbacks stay zero). Evidence: new draw_s5_query_resolve_and_readback failed pre-change (slots 28-30 stubs, counts [0,0,0]) and passes post on Arc A770 (null counts [2048,0,1024]; Vulkan outer 2048 + centre green / corner clear); S4 test needed a shared draw_serial mutex (exact global-counter asserts raced under --test-threads=4 once two tests flush). lib 810 passed, 0 failed, 1 ignored (x2 runs); both cargo checks clean; title same-harness delta 0 (null 4 / Vulkan 3) with the triangle FAIL moved past occlusion (null: zeros top-right; Vulkan: clear-blue top-right from the real submit); retail HOLDS (exit 139 @ exe+0x2237320, SIGSEGV fault 0, 20 stubs, 0 d3d12, xgr XAsync/XNetworking/XUser).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.