startup: check the placement publish lock and width #1496
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1503"
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 Asimmimx on 2026-11-24T13:13:41Z.
Change
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).