Skip to content

tests: slot 133 teardown leaves nothing at vkDestroyDevice (RT-SLOT133-STANDIN-LEAK) - #1716

Open
Tyrannys wants to merge 3 commits into
ProjectLeonida:mainfrom
Tyrannys:claude/slot133-standin-leak-adc6b3
Open

Tyrannys wants to merge 3 commits into
ProjectLeonida:mainfrom
Tyrannys:claude/slot133-standin-leak-adc6b3

Conversation

@Tyrannys

@Tyrannys Tyrannys commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-SLOT133-STANDIN-LEAK (#1608)

Depends on: #1758

What and why

The finding in #1608 (and adrianmjim's run on #1558): after a slot 133 placement, vkDestroyDevice reports 57-63 objects that were never destroyed (VUID-vkDestroyDevice-device-05137) under LEONIDA_VK_VALIDATION=1. The leak comes from the test helper, not the runtime.

d3d12test::Ref had no assignment operator of its own, so placed = {}; copied a null pointer over the reference and never called Release. The placed texture kept its reference to the device proxy, and the whole D3D12 device was still alive at vkDestroyDevice. I took the runtime's slot 133 paths one at a time (provider refusal → host-address texture → committed stand-in) and none holds a reference after release.

adrianmjim's #1758 (TEST-REF-MOVE-ONLY) makes the same Ref change: move-only, and ref = {} releases. It is equivalent to the change this pull request first carried, so that part has been reverted here (in a new commit; the history is unchanged), and the Ref fix is left to #1758. This pull request now only adds a regression test for slot 133 teardown.

The new xbox_slot133_teardown test needs no game files. Through slot 133 on the Vulkan device behind the proxy, it places:

  • a 1280×720 format-118 depth target without UAV
  • a 256×256 RGBA8 texture
  • an RGBA8 render target
  • a buffer

It drops each one with = {} and checks that the proxy's reference count is back where it was. Then it releases the device and reads the validation error count only after vkDestroyDevice.

Tested

NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11, MSVC, Ninja RelWithDebInfo. Branch with current main (a73a57e) merged in.

GPUs tested: NVIDIA GeForce RTX 4070 SUPER, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🤖 Generated with Claude Code

…SLOT133-STANDIN-LEAK)

The 57-63 Vulkan objects reported at vkDestroyDevice (VUID-vkDestroyDevice-device-05137) after a slot 133
placement were the test's, not the runtime's. d3d12test::Ref had no assignment operator of its own, so
`placed = {};` (PR ProjectLeonida#1558's check_d16s8_refused_uav) copied a null pointer over the reference without
Release: the placed texture, and through its device reference the whole D3D12 device, outlived the test.

Ref now has a move assignment that releases what it held, a move constructor, and deleted copies (two Refs
on one reference release it twice). Nothing on main copies a Ref or assigns `{}` to one.

xbox_slot133_teardown places, through slot 133 on the Vulkan device behind the proxy, a 1280x720
format-118 depth target without UAV, a 256x256 RGBA8 texture, an RGBA8 render target and a buffer; drops
each with `= {}`, checks the proxy's reference count is back where it was, releases the device and reads
the validation error count only after vkDestroyDevice. With the old Ref it fails ("keeps 3 after
release"); with this one it passes, plain and with LEONIDA_VK_VALIDATION=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PierreEbele

Copy link
Copy Markdown
Contributor

Reviewed 573c918: the slot-133 teardown test and the D3D12 COM targets are MSVC/Windows-only, so they were not built or run here; its referenced symbols all check out against main's headers and the CMake registration matches the neighbouring xbox_gpu_label_test block. The header logic this PR changes is verified: a standalone arm64-Linux probe compiling Ref's special members verbatim (plus a sweep of all 46 files that include d3d12_test_shaders.h) shows placed = {} issuing 0 Release calls with main's Ref and exactly 1 with the PR's, moves and by-value returns working, and copies refused at compile time; nothing in-tree copies a Ref, aggregate-initializes one or copies a fixture holding one, so the deleted copies break no existing test. One wording nit: "Nothing on main copies a Ref or assigns {} to one" is not accurate - xbox_depth_storage_test.cpp:95 assigns {} (the leak site this PR fixes). No code findings.
AI-assisted review.

Recommendation: Merge

@ammonium231

Copy link
Copy Markdown

RTX 3090 / 621.40, validation on: clears the device-teardown leak in xbox_d16s8_refused_uav (main leaks 74 objects, with this PR 0). xbox_slot133_teardown is also clean.

ProjectLeonida#1758 makes the same d3d12test::Ref change (move-only, `ref = {}`
releases). Keep this pull request to the slot 133 teardown test, which
depends on that change.

AI-assisted (Claude Code).
@Tyrannys Tyrannys changed the title tests: d3d12test::Ref releases on = {}; slot 133 teardown test (RT-SLOT133-STANDIN-LEAK) tests: slot 133 teardown leaves nothing at vkDestroyDevice (RT-SLOT133-STANDIN-LEAK) Nov 26, 2026
@Tyrannys

Copy link
Copy Markdown
Contributor Author

Housekeeping: adrianmjim's #1758 makes the same d3d12test::Ref change (move-only, ref = {} releases), so I reverted that part here in a new commit. This PR now only adds the xbox_slot133_teardown test and depends on #1758. With #1758's header the test passes plain and under LEONIDA_VK_VALIDATION=1 (no VUIDs); without it, it fails with VUID-05137. That fits the verification of #1758 I posted there earlier. Thanks @adrianmjim! AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants