Repository navigation
startup: keep the object receiver for 8-byte struct returns when rdx holds a wrapper - #2774
Conversation
…holds a wrapper small_result chose the (return buffer, object) form whenever its second argument was a live wrapper. A title-ABI call to descriptor heap slot 9 (GetCPUDescriptorHandleForHeapStart) passes only `this`, so the second register holds whatever the caller left there. When that was another live wrapper, the shim wrote the handle over the heap object's vtable and returned the heap's address as the handle. Case 9 of startup_resource_retire_title (R0Y00#2719) nests the slot 9 call in a slot 20 call; at /O2 rdx still held the resource wrapper, so the RTV went to an untracked slot and the heap's next Release jumped into data. All six variants segfaulted in Release since R0Y00#2719. small_result now takes its object from receiver(), the rule the larger struct-returning slots already use: a wrapper first is the object, and only when both look like wrappers does the one on this thread's stack become the result buffer. Case 10 calls slot 9 with a live wrapper in the second argument and through a return buffer; it fails in Debug and Release without the shim change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review + Win2025 WARP receipt for head Reviewed: Commands run: Win2025 result: dev and release each show Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
tedin7
left a comment
There was a problem hiding this comment.
Review + Win2025 WARP receipt for head 85087eab (comment review, no approval).
Reviewed: small_result now takes its object from receiver(), 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 sibling small_result callsite 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 6 for ctest -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:
- Debug (
--preset dev):- Build (
cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_resource_retire_title -- -j 2):41.76s(configure2.54s) - Test (
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
- Build (
- Release
/O2(--preset release):- Build (
cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_resource_retire_title -- -j 2):50.61s(configure2.42s) - Test (
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_debug1
- Build (
sccache: 0/14 hits; wall108.9s
AI-assisted; commands listed were executed locally.
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