startup-runtime: d3d12_xs wrap() does not check _aligned_malloc, so a failed allocation becomes an access violation #2653
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#2653
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?
@Not-Saii on GitHub · 2026-11-26 00:35 UTC · original
Commit or build
mainatd371ce46c57bf972f225616d462f99486f323f77,releasepreset.Reproduction
Observed in a local startup run under the job memory cap. It is not yet reproduced on a source-built input (see "Proposed check" below).
Process commit (
PagefileUsagein the DirectStorage heartbeat) went from 5.3 GiB to 12.2 GiB once loading started, at the 12 GiB cap.wrap()insrc/startup_stubs/d3d12_xs_device.cpp(line 463 at this commit):_aligned_malloccan returnnullptr. The result is used without a check.Expected behavior
When the wrapper allocation fails, the calling slot returns
E_OUTOFMEMORY(and leaves*outnull), so the title can handle the failure or report it through its own error path.Observed behavior
Debugger stop at 221.29 s: second-chance access violation, a write to
0x20, atd3d12_xs.dll+0x587d90(vmovdqa [rcx],ymm0in the CRTmemset).Stack inside
d3d12_xs.dll(release build, no PDB; identified from the disassembly and the format strings next to each call):+0x5621f7wrap():_aligned_malloc(0x530, 16)returnednullptr, thenmemset(nullptr, 0, 0x530)+0x528928Device::slot55(derived pipeline), the placeholder path:*out = wrap(nullptr, pipeline_kind)wrap()has 16 call sites ind3d12_xs_device.cpp(queues, root signatures, descriptor heaps, command lists, resources, pipelines, command signatures, the device). None of them can see a failure today, becausewrap()never returns one.Proposed check
A source-built fixture under a job commit limit (the view census test already uses one) could fill the commit until one more allocation fails, then call one wrapping slot (for example a derived pipeline or a root signature). Expected:
E_OUTOFMEMORYand a null output. A control without the check would end the process on an access violation.A fix needs one decision per call site: what each slot returns, and which side effects (registry insertion, desktop object references) must be undone when the wrapper cannot be created.
Environment
Related: #1199 (commit exhaustion during loading). This issue only covers the missing check; the memory growth itself belongs to #1199.
AI-assisted (Claude Code).