mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:55:52 +01:00
[PR #2343] d3d12_device_calls: forget a slot a store or a call may have replaced (D3D12-DEVICE-CALLS-STALE-SLOT) #2350
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2350
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?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2343
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:fix/d3d12-device-calls-stale-slot📝 Commits (1)
cc841a8d3d12_device_calls: forget a slot a store or a call may have replaced (D3D12-DEVICE-CALLS-STALE-SLOT)📊 Changes
2 files changed (+60 additions, -3 deletions)
View changed files
📝
tests/test_d3d12_device_calls.py(+40 -0)📝
tools/d3d12_device_calls.py(+20 -3)📄 Description
Claimed in the coordination issue as: D3D12-DEVICE-CALLS-STALE-SLOT (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7194420859)
What and why
tools/d3d12_device_calls.pypromises statically resolved device sites and to report the rest as not resolved, "never guessing a slot"; under-counting is the accepted direction ("a slot can be called more often than the report says"). Its walk keeps a[reg+disp]slot that held the device (stack slots survive calls) and dropped it only on a plain store to the slot's exact address. Two ways a slot gets another object were missed, and the next call through the slot was then reported as a device slot:A call given the slot's address. MSVC reuses frame slots, so the device spilled to
[rsp+40h]can share the slot with an out variable:The slots whose addresses are passed in rcx/rdx/r8/r9 are now forgotten at the call. A creator's out slot is still added back after it, so the existing out-pointer tracking is unchanged.
An SSE/AVX store over the slot (
movups [rsp+40h],xmm0, how struct copies and zeroing are compiled), or any store that covers only part of it (mov dword [rsp+44h],0). Every store now ends the slots whose bytes it touches. The vector stores (0F 11/29/2B/7F/E7/13/17/D6, movnti, and their VEX/EVEX forms) take their widest size, 16 bytes and 32 under VEX, because the decoder keeps neither the prefix nor VEX.L. Forgetting a slot only loses a site, while keeping one wrongly invents a site.A store or out-pointer next to the slot leaves it alone (tested both ways). The docstring's walk description says so.
Different topic from #2262 (
--outvalidation and atomic reports, same file); the two merge cleanly.Tested
Windows 11, Python 3.14.7, the test file's synthetic PE fixture only:
python -I tests/test_d3d12_device_calls.py: 17 tests OK. Two new tests run a function that spills the device to[rsp+40h], does one thing, reloads the slot and calls its slot 6:movupsat the slot,movupsatrsp+38h,vmovdqu ymmatrsp+30hand a 4-byte store into the upper half all end the slot;movupsatrsp+48hand a store atrsp+38hkeep it;rsp+48hkeeps it (slot 8 is counted in both).On
mainthe five overwriting cases fail and the keeping ones pass.tests/test_gdk_runtime_calls.pyOK;python -m compileall;scripts/check_no_game_data.pyon both files.Not measured: how many sites this removes from a real executable (no game files here).
GPUs tested: n/a (CPU-only tool)
AI-assisted: yes (Claude Code, Claude Opus 5.5)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.