[PR #1758] test: d3d12test::Ref owns its pointer alone: move only, and ref = {} releases (TEST-REF-MOVE-ONLY) #1771

Open
opened 2026-11-26 21:18:54 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1758
Author: @adrianmjim
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: test/ref-move-only


📝 Commits (1)

  • a8a56cb test: d3d12test::Ref owns its pointer alone: move only, and ref = {} releases (TEST-REF-MOVE-ONLY)

📊 Changes

1 file changed (+13 additions, -0 deletions)

View changed files

📝 runtime/test/d3d12_test_shaders.h (+13 -0)

📄 Description

Claimed in the coordination issue as: TEST-REF-MOVE-ONLY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161001857)

What and why

d3d12test::Ref (runtime/test/d3d12_test_shaders.h, included directly by 40 test sources and 3 shared test headers) had a destructor but no copy or move members of its own. Two consequences:

  • ref = {} silently leaked. It builds an empty temporary and copies its null pointer over the held one, so Release() is never called. That is what happened in #1558's new test: its slot 133 resource stayed alive and kept the device proxy and the whole D3D12 device. Under LEONIDA_VK_VALIDATION=1 the result was a 63-object vkDestroyDevice report, which I first misread as a runtime leak.
  • A copy would release twice. With a user-declared destructor there is no implicit move. So a std::vector<Ref<...>> that grows copies every element and then destroys the originals. d3d12_bundle_test keeps Refs in vectors (Rig::bundle_allocators, Rig::bundles). Each Rig calls bundle() once, so neither grows past its first element, and the bug is latent.

The change: copying is deleted, moving transfers the pointer, and move assignment releases the old pointer. So ref = {} now does what it reads as, and a growing vector moves (noexcept). The struct keeps its p member, reset() and operator->, and no test copies a Ref or initialises one from a pointer, so every test builds unchanged.

Tested

On main 2b567edca with this change, Windows 11 build 26300, VS 2022 (MSVC 19.44) RelWithDebInfo, AMD Radeon RX 7900 XT, driver 32.0.32029.2010 (26.11.2):

  • Build: the whole runtime and every test build with no errors, and no warning points at the changed header.
  • ctest -j 6: 400 of 403 without failures (387 passed, 13 skipped). The three failures are the same as on main 42537e7b6 without it: d3d12_texture_tiles (#964), d3d12_clear, and d3d12_geometry_views (#1678, no Resizable BAR).
  • #1558's leak: in a local probe through #1558's slot 133 path, placed.reset() (what placed = {} does after this change) left no leaked objects under validation.

GPUs tested: AMD Radeon RX 7900 XT (RDNA3), AMD 32.0.32029.2010, Windows 11 26300

AI-assisted: yes

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. (No translator change.)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1758 **Author:** [@adrianmjim](https://github.com/adrianmjim) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `test/ref-move-only` --- ### 📝 Commits (1) - [`a8a56cb`](https://github.com/ubiquitarianism/leonida/commit/a8a56cb47ede0039988abab4a2e17e5be2a48c5c) test: d3d12test::Ref owns its pointer alone: move only, and `ref = {}` releases (TEST-REF-MOVE-ONLY) ### 📊 Changes **1 file changed** (+13 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/test/d3d12_test_shaders.h` (+13 -0) </details> ### 📄 Description Claimed in the coordination issue as: TEST-REF-MOVE-ONLY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161001857) ### What and why `d3d12test::Ref` (`runtime/test/d3d12_test_shaders.h`, included directly by 40 test sources and 3 shared test headers) had a destructor but no copy or move members of its own. Two consequences: - **`ref = {}` silently leaked.** It builds an empty temporary and copies its null pointer over the held one, so `Release()` is never called. That is what happened in #1558's new test: its slot 133 resource stayed alive and kept the device proxy and the whole D3D12 device. Under `LEONIDA_VK_VALIDATION=1` the result was a 63-object `vkDestroyDevice` report, which I first misread as a runtime leak. - **A copy would release twice.** With a user-declared destructor there is no implicit move. So a `std::vector<Ref<...>>` that grows copies every element and then destroys the originals. `d3d12_bundle_test` keeps `Ref`s in vectors (`Rig::bundle_allocators`, `Rig::bundles`). Each `Rig` calls `bundle()` once, so neither grows past its first element, and the bug is latent. The change: copying is deleted, moving transfers the pointer, and move assignment releases the old pointer. So `ref = {}` now does what it reads as, and a growing vector moves (`noexcept`). The struct keeps its `p` member, `reset()` and `operator->`, and no test copies a `Ref` or initialises one from a pointer, so every test builds unchanged. ### Tested On `main` `2b567edca` with this change, Windows 11 build 26300, VS 2022 (MSVC 19.44) RelWithDebInfo, AMD Radeon RX 7900 XT, driver 32.0.32029.2010 (26.11.2): - **Build:** the whole runtime and every test build with no errors, and no warning points at the changed header. - **`ctest -j 6`:** 400 of 403 without failures (387 passed, 13 skipped). The three failures are the same as on `main` `42537e7b6` without it: `d3d12_texture_tiles` (#964), `d3d12_clear`, and `d3d12_geometry_views` (#1678, no Resizable BAR). - **#1558's leak:** in a local probe through #1558's slot 133 path, `placed.reset()` (what `placed = {}` does after this change) left no leaked objects under validation. GPUs tested: AMD Radeon RX 7900 XT (RDNA3), AMD 32.0.32029.2010, Windows 11 26300 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change.) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#1771
No description provided.