startup: start DirectStorage status-array slots complete with S_OK #1840
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1847"
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 R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T19:29:13Z.
Refs #1843 (slice 1)
Change
factory_create_status_arrayinsrc/startup_stubs/xcrdapi.cppused to set every new slot toE_PENDING. SoIsComplete(i)was false, andGetHResult(i)returnedE_PENDING, for a slot nothing had been enqueued into. A caller that polls a ring slot before its first use would wait forever.New slots now start complete with
S_OK.EnqueueStatusstill marks its slotE_PENDINGuntil the entries before it have run. Completion and out-of-range handling are unchanged.Source: Microsoft's Win32 implementation of the API, in Xbox-GDK-Samples (MIT),
Samples/System/SimpleDirectStorageCombo/DirectStorageWin32/DirectStorageWin32WrapperStatusArray.cpp:There, only
EnqueueStatusmarks a slot not complete.docs/startup-runtime.mdrecords the behaviour and the source.Fixture
startup_stub_consumer dstorage-status-initialruns from thestartup_stubscheck:S_OK. Index 4 stays refused: not complete,E_INVALIDARG.EnqueueStatusputs slot 2 behind it. While held, slot 2 reads not complete withE_PENDING, and slots 0, 1 and 3 keepS_OK.S_OK.Control: restoring the
E_PENDINGinitialization makes the check fail at the first fresh slot:dstorage-status-initial: fresh slot 0 complete=0 hr=0x8000000a, exit 10.Verification
Tested
f8101db1on main82749f0f. Windows 10 22H2 build 19045.6456, MSVC fromtools/dev.ps1. No GPU is involved.startup_stubs(the BCPack summary,dstorageanddstorage-pages) still pass, and so doesstartup_storage_directory_batch.startup_stubs, so this check runs locally (#1149 tracks running the stand-in checks in CI).Slice 2 (
RetrieveErrorRecordand the error event) will be a separate PR.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:36:37Z.
Review: COMMENTED
Peer review of head
f8101db16f67169544cd89cf140f225f05129923.Result: no P1/P2 defects found in the diff and the Linux checks. This head was not built or run on Windows in this review: the C++ change and the new consumer check (
dstorage-status-initial) are verified by reading only.Read in full: the diff (
src/startup_stubs/xcrdapi.cpp,tests/startup_stub_consumer.cpp,tests/startup_stub_check.py,docs/startup-runtime.md) and the status-array code around it.factory_create_status_arraynow starts every slot atS_OK.status_is_completeisresults[i] != E_PENDINGandstatus_get_hresultreturns the slot, so a slot nothing was enqueued into reads complete withS_OK. An index past the capacity still reports not complete andE_INVALIDARG.E_PENDINGis nowqueue_enqueue_status(xcrdapi.cpp:1188), which sets it when the entry is enqueued, before Submit. The worker completes the slot in order (:756), andfail_unstarted(:918) completes it on the failure path, so a status entry that is recorded or deferred never stays pending. Every existing consumer check that polls a slot does so afterEnqueueStatuson that slot (for example lines 551-553, 581-583, 750-755, 1151-1154, 1299-1300, 1570-1584), so none of them can now see the slot complete before its turn.S_OK, plus the out-of-range index; then a fence-signal entry that holds the worker,EnqueueStatuson slot 2 behind it, and a check that slot 2 isE_PENDINGwhile slots 0, 1 and 3 stayS_OK; after releasing the worker, slot 2 completes withS_OKand the gate records the resume. The hold uses the sameSubmitGateandhold_workerpattern as the existing check at line 1290, and every symbol it uses is declared above it. The pending state is set at enqueue time, so the "held" assertion does not depend on timing.Non-blocking notes (P3):
src/startup_stubs/xcrdapi.cpp:55still says "E_PENDING until a status is enqueued" forresults, which now describes the old initial state.docs/startup-runtime.md:729("nothing is left atE_PENDING") still holds.tests/startup_stub_check.pythe new block was inserted between the comment "# Page arrays changed between EnqueueRequest and Submit..." and thedstorage-pagesrun it describes, so that comment now sits above the wrong block.Linux checks run locally in a clean worktree at this head:
git diff --check origin/main...HEAD: cleantests/docs_links_check.py: passed (18 files, 370 links)tests/bidi_controls_check.py: passed (1322 files)tests/startup_stub_check.py: not runnable on Linux (it needs the Windows consumer executable and loads DLLs throughctypes.WinDLL).No local mutation was possible: the behavior lives in the Windows-only consumer and stub DLL. Suggested mutation for a Windows run: change the initial value back to
E_PENDINGinfactory_create_status_array;dstorage-status-initialshould then fail on its first fresh-slot check.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T19:49:26Z.
I kept the initial/pending/completed status checks and widened only the new fixture's synthetic queue descriptor. The shim records 40 bytes at CreateQueue, so the former 32-byte array let the diagnostic read eight bytes outside the fixture. With the 40-byte aligned array, Release rebuilt and dstorage-status-initial passed, including the held pending slot and completion. The production status change is unchanged.