startup: check the placement publish lock and width #1503
No reviewers
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!1503
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1503/head"
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?
@Asimmimx on GitHub · 2026-11-24 13:13 UTC · original
Asimmimx:startup/placement-publish-check→main· +98 −1 · 3 files · 1 commits · merged 2026-11-24 13:30 UTCChange
Refs #1149. This adds a device-free check for
src/startup_stubs/placement_publish.h. Device slot 133 (d3d12_xs_device.cpp) uses it to register a placed buffer.The binding lookup
placed_buffer_rangeind3d12_capture.inltakesnote_lockshared and starts its search ataddress - max_width + 1. It therefore relies on two things:publish_placementinserts the record and its index entry under the exclusive lock;max_widthnever shrinks below the widest record published so far.The tests that reach the header are
startup_placement_alloc(CPU),startup_placed_vertex_warpandxmem_page_runs_device_warp. They check the inserted records, theALREADY_EXISTSand out-of-memory paths and the rollback, but neither of those two properties. Three single-point mutants left all three passing:max_width = record.bytes, which lets a later, narrower record shrink the search window. Lookups inside a wider, earlier buffer would then start too late and miss it.startup_placement_publishincludes only the header:TryAcquireSRWLockSharedfails. SRW locks are not reentrant, so this means the lock is held exclusively. It also checks that the lock is free again after the call.max_widthafter each record against hand-worked values: 0x100000, 0x100000, 0x400000, 0x400000.startup_placement_publish_shrink_controlruns--mutate shrink, which expects 0x20000 after the second record, and must fail (WILL_FAIL).The change is test, CMake and
docs/experiments.mdonly. The paragraph sits next to the existingstartup_placement_alloctext, and the CMake block follows thestartup_placement_allocregistration.Verification
Commit
3c6273ac(main) plus this change,devpreset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.xmem_page_runs_device_warpalso passed on the unmodified header.tests/docs_links_check.py,tests/bidi_controls_check.pyandgit diff --checkpassed.Mutation probe
I applied each mutation to the header alone, rebuilt the affected targets, ran the tests, then reverted. None of this is committed.
startup_placement_publishif (!added)→if (added)max_width = record.bytesinsert_or_assign(duplicate replaces the record)records.erasedroppedthrow;→return S_OK;record.bytes - 1start + 1length_errorcatch →domain_errorTwo survivors are deliberately not pinned:
insert_or_assign. A duplicate owner cannot come from the real caller: each owner is a freshly allocated wrapper that lives for the whole process. TheALREADY_EXISTSreturn is already checked.domain_errorcatch. Astd::unordered_mapthrowslength_erroronly abovemax_size, which is not practically reachable.Checklist
AI-assisted (Claude Code).