runtime: xcrdapi stand-in COM objects are never freed at final Release #2788
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#2788
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?
@triggered02 on GitHub · 2026-11-26 09:18 UTC · original
Commit or build
Upstream
mainat63451c5e.Summary
The DirectStorage stand-in (
src/startup_stubs/xcrdapi.cpp) never frees its COM objects.make(unsigned kind)(line 295) heap-allocates anObject/FileObject/QueueObjectfor everyOpenFile,CreateQueue, andCreateStatusArray, butrelease(Object*)(line 282) only decrements the refcount and, at zero, closes the queue's error event — it neverdeletes the object. The factory is a process singleton, so every file/queue/status object created during a run leaks for the life of the process.Evidence (code read on
main)make()(line 295)newsQueueObject/FileObject/Object; nothing ever deletes them.Why a naive delete-at-zero is not the fix
queue_worker(line 953) runsfor (;;), holds the rawselfpointer with noAddRef, and never exits; its thread handle isCloseHandled right afterResumeThread. Deleting the queue at refcount zero would leave the worker running on freed memory.Object* array(status),void* fence, and read the request's sourceFileObject*at run time, noneAddRefed. A guestRelease()of a file or status array while an entry is pending would dangle.So a correct fix needs a worker shutdown/join protocol plus reference accounting for entry-held objects (and the factory singleton must stay alive), not just
delete thisat zero.Synthetic repro (proposed, source-built, no game data)
A fixture that drives the stand-in factory directly:
deleteat refcount zero without the worker shutdown / entry accounting -> the queue case must crash or fail.Acceptance: a new
startup_xcrdapi_lifetimeCTest (no GPU adapter required).Not established
OpenFile+ 34 queue/status creations in a 300 s diagnostic run), so this is a correctness leak, not a multi-GiB commit-pressure source. It is filed separately from the texture/heap commit work (#2379, #1199).AI-assisted; code read on
main, synthetic repro proposed.@RenzoWit35 on GitHub · 2026-11-26 10:20 UTC · original
I can take this. Plan: pending entries hold a reference on their status array and source file; at the last release a queue is marked closing and its worker finishes the submitted entries and then frees the queue and its work (a queue without a worker is freed directly), so nothing blocks inside Release. Test
startup_xcrdapi_lifetime: a test-side fence whose Signal blocks holds the worker while the file, status array and queue are released; a live-object count must stay non-zero until the gate opens and then reach zero. Fail-first control: delete at refcount zero without the hand-off must fail the count check. Source-built, no GPU, no title data.AI-assisted.
@Not-Saii on GitHub · 2026-11-26 11:49 UTC · original
Verified on
mainat25eb746e(Windows x64,devpreset, no GPU needed):ctest --preset dev --no-tests=error -R 'xcrdapi' --output-on-failurepasses 2/2.startup_xcrdapi_lifetimepasses, andstartup_xcrdapi_lifetime_naive_control(WILL_FAIL) catches the delete-at-zero mutant. Fixed by #2800; this can be closed.