startup: keep the object receiver for 8-byte struct returns when rdx holds a wrapper #2766
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2774"
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 MasterDomino on 2026-11-26T07:41:23Z.
Refs #2379. Fixes the Release-only crash in
startup_resource_retire_titlereported on #2768.Problem
Since #2719, all six
startup_resource_retire_titlevariants segfault in Release (--preset release) onmain; Debug passes. A bisect puts it at #2719: its parent41cd090bpasses 6/6 in Release, and33004fa1fails 6/6. The test change only exposed it. The defect is older, in the shim.Descriptor heap slot 9 (
GetCPUDescriptorHandleForHeapStart) returns an 8-byte structure. A title-ABI call passes onlythisin rcx and reads rax, so the second register holds whatever the caller left there.small_resulttook the (return buffer, object) form whenever that second argument was a live wrapper. It then wrote the handle over the first argument, the heap object's vtable, and returned the heap's address as the "handle".Case 9 nests the slot 9 call inside a slot 20 call:
invoke<void>(guest, 20, resource, &rtv, invoke<UINT64>(heap, 9)). At/O2, rdx still holds the resource wrapper at the inner call. The RTV is therefore written to an untracked slot, which fails the case-9 check, and the heap's nextReleasejumps to the handle value. A crash filter showed exception0xc0000005with access kind 8 (execute) at a data address, reached fromcase9_view_slot_fallback.Change
small_resultnow takes its object fromreceiver(), the rule the larger struct-returning slots already use:It writes through the first argument only in the (return buffer, object) form.
New case 10 in
startup_resource_retire_title. It calls slot 9 three ways:It runs first, in all six variants. On failure it detaches the heap, so the negative control fails cleanly instead of crashing.
Verification
Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818.
85087eab, oncd5fb38b):ctest --preset release --no-tests=error -j1 -R '^startup_resource_retire_title'gives 6/6 passed (was 6/6 SEGFAULT onmainf1a8db63).f1a8db63plus this change:ctest --preset dev --no-tests=error -j6 -R '^startup_' -E 'gfx2hlsl|image_sample|vertex_fetch'gives 763/763 passed. Eight tests were not run, all capability skips, as onmain:startup_view_heap_*andstartup_logical_view_*("adapter accepts 1245184 descriptors directly"),startup_sharedexp_target_*,startup_small_texture_4k_addrlibandstartup_run_sh.FAIL: heap start with a live object in the second argument: got 0x2659c32e970, expected 0x2659de204a0 (heap 000002659C32E970). The returned "handle" is the heap object's own address.Not covered
The CI
/O2job is skipped on PRs, which is why this Release regression wasn't caught there. Case 10 passes the stray wrapper explicitly instead of relying on register allocation, so it should fail without the fix under any optimization level. I ran the negative control in Release only.AI-assisted; commands listed were executed locally.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:48:12Z.
Review: COMMENTED
Review + Win2025 WARP receipt for head
85087eab(comment review, no approval).Reviewed:
small_resultnow takes its object fromreceiver(), the same rule the larger struct-returning slots use. It writes through the first argument only in the (return buffer, object) form. The new case 10 covers a live second wrapper (rax form), the hidden-pointer form, and a heap-intact check. On failure it detaches the heap, so the negative control fails cleanly. It runs first in all six variants. No siblingsmall_resultcallsite is left on the old rule. The PR fixes a test crash; it does not claim game-startup progress, and I made no executable claims.Commands run:
git diff --check origin/main...HEAD(clean), 0 commits behind main.Win2025 result: dev and release each show
100% tests passed out of 6forctest -R '^startup_resource_retire_title': 4 passed, 2 skipped (startup_resource_retire_title_warp_debug1,startup_resource_retire_title_hardware_debug1, debug-layer capability, not counted as passes). Release no longer crashes (this crash is the one on main since #2719).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
85087eab072bd1a578a4ce92254c844ed1762cc1:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_resource_retire_title -- -j 2):41.76s(configure2.54s)ctest --preset dev -R '^startup_resource_retire_title' --parallel 6 --no-tests=error --output-on-failure): 4/6 passed (0.23s:startup_resource_retire_title_warp_debug10.03s,startup_resource_retire_title_hardware_debug10.03s,startup_resource_retire_title_off_hardware0.07s,startup_resource_retire_title_off_warp0.08s,startup_resource_retire_title_hardware_debug00.09s,startup_resource_retire_title_warp_debug00.10s); skipped (capability, not a pass):startup_resource_retire_title_warp_debug1,startup_resource_retire_title_hardware_debug1/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_resource_retire_title -- -j 2):50.61s(configure2.42s)ctest --preset release -R '^startup_resource_retire_title' --parallel 6 --no-tests=error --output-on-failure): 4/6 passed (0.34s:startup_resource_retire_title_hardware_debug10.06s,startup_resource_retire_title_warp_debug10.06s,startup_resource_retire_title_off_warp0.10s,startup_resource_retire_title_off_hardware0.10s,startup_resource_retire_title_hardware_debug00.11s,startup_resource_retire_title_warp_debug00.16s); skipped (capability, not a pass):startup_resource_retire_title_hardware_debug1,startup_resource_retire_title_warp_debug1sccache: 0/14 hits; wall108.9sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:48:11Z.
Review + Win2025 WARP receipt for head
85087eab(comment review, no approval).Reviewed:
small_resultnow takes its object fromreceiver(), the same rule the larger struct-returning slots use. It writes through the first argument only in the (return buffer, object) form. The new case 10 covers a live second wrapper (rax form), the hidden-pointer form, and a heap-intact check. On failure it detaches the heap, so the negative control fails cleanly. It runs first in all six variants. No siblingsmall_resultcallsite is left on the old rule. The PR fixes a test crash; it does not claim game-startup progress, and I made no executable claims.Commands run:
git diff --check origin/main...HEAD(clean), 0 commits behind main.Win2025 result: dev and release each show
100% tests passed out of 6forctest -R '^startup_resource_retire_title': 4 passed, 2 skipped (startup_resource_retire_title_warp_debug1,startup_resource_retire_title_hardware_debug1, debug-layer capability, not counted as passes). Release no longer crashes (this crash is the one on main since #2719).Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
85087eab072bd1a578a4ce92254c844ed1762cc1:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_resource_retire_title -- -j 2):41.76s(configure2.54s)ctest --preset dev -R '^startup_resource_retire_title' --parallel 6 --no-tests=error --output-on-failure): 4/6 passed (0.23s:startup_resource_retire_title_warp_debug10.03s,startup_resource_retire_title_hardware_debug10.03s,startup_resource_retire_title_off_hardware0.07s,startup_resource_retire_title_off_warp0.08s,startup_resource_retire_title_hardware_debug00.09s,startup_resource_retire_title_warp_debug00.10s); skipped (capability, not a pass):startup_resource_retire_title_warp_debug1,startup_resource_retire_title_hardware_debug1/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_resource_retire_title -- -j 2):50.61s(configure2.42s)ctest --preset release -R '^startup_resource_retire_title' --parallel 6 --no-tests=error --output-on-failure): 4/6 passed (0.34s:startup_resource_retire_title_hardware_debug10.06s,startup_resource_retire_title_warp_debug10.06s,startup_resource_retire_title_off_warp0.10s,startup_resource_retire_title_off_hardware0.10s,startup_resource_retire_title_hardware_debug00.11s,startup_resource_retire_title_warp_debug00.16s); skipped (capability, not a pass):startup_resource_retire_title_hardware_debug1,startup_resource_retire_title_warp_debug1sccache: 0/14 hits; wall108.9sAI-assisted; commands listed were executed locally.