d3d12: report textures that ended while descriptors still name them #567

Open
NickStallman wants to merge 1 commit from upstream-pr/567 into main
NickStallman commented 2026-11-30 03:57:48 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T03:57:48Z.


Log-only, for anyone chasing a lost GPU (#232). Refs #533 (claimed there). Run in the game four times, see below.

Why. On an RTX 5090 (10de:2b85, 620.70.10, GE-Proton11-14) ProjectScarlett loses the GPU some minutes into the story (Xid 13, an MMU fault in a shader). One run had a fault address: a read of 0xdcf6068000, which vkd3d's binding log says was inside an image's range that was unbound 846 seconds before the fault ("very likely use-after-free"). The log can't say whose image it was or which descriptor still named it. From the code, the likely kind is a reserved placed texture (no dimensions in vkd3d's record), which is a guess.

What it does. With TUXBOX_CHECK_STALE_IMAGES=1 (and TUXBOX_LOG), a shadow of the host descriptors follows creations and copies, separately from the tracking that keeps images alive. At a device loss it logs the ended images that descriptors still name, with up to 4 descriptors each (slot, kind, evicted or not, source), then every ended image kept, with its life in performance-counter seconds to match against vkd3d-proton's BIND and UNBIND times. Every 30 s it counts index-map entries without a slot and says what visible slot 0 names. Off by default; nothing is nulled or kept alive.

Limits: D3D12 gives no image address, so images are matched by time and size. It takes one lock per descriptor write, so it costs CPU (not measured). At most 1,024 named images and 32,768 ended ones.

Results on an RTX 5090. Nothing to say in the first (84a: no loss, 8 minutes in the world). In the second (84b) the GPU was lost 11 minutes into the world with it on: no followed descriptor named an ended image (28,244 images live, 32,768 ended kept, 160,785 descriptors naming an image), and vkd3d called that fault address (0x1030b5000) never-used memory or out of bounds. So a stale descriptor isn't supported as the cause of that loss. It can't see copy paths it doesn't follow, has no positive control in the game, and ran with neither of the earlier losses, so it says nothing about 83a. Index map: about 1.04 million unmapped indices held records, 46,000 empty, and visible slot 0 named no image.

Tested

  • Four new unit tests; python tuxbox.py check --no-gpu passed (10 of 10). It merges cleanly with our integration branch, where its unit tests and cargo check pass.
  • What a clean result doesn't show: the shadow follows the descriptors TuxBox writes. It can't see a shader that uses an index outside the heap or the index map (#472, 30 Nov), so "no descriptor names an ended image" doesn't rule that out.
  • Not run: an AMD run in the game; @ReverendOzmund ran it on an RTX 3080 Ti (#232): 34,529 images live, 9,665 ended kept, none named by any descriptor at that loss.

A matching descriptor shows it existed, not that a shader read it. Please use it with TUXBOX_HOLD_LOST-style delays if you have them, so the dump completes.

  • Full python tuxbox.py check of 1006ca18 (rebased onto e5d2e913; no change in behaviour): RTX 5090 (10de:2b85, 620.70.10) 200 pass, 0 fail; AMD iGPU (1002:13c0, RADV) 199 pass, 0 fail. GE-Proton11-14.

Evidence: TuxBox check of 1006ca185a, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run
Evidence: TuxBox check of 1006ca185a, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5558706591 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/567). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T03:57:48Z. --- Log-only, for anyone chasing a lost GPU (#232). Refs #533 (claimed there). Run in the game four times, see below. **Why.** On an RTX 5090 (`10de:2b85`, 620.70.10, GE-Proton11-14) ProjectScarlett loses the GPU some minutes into the story (Xid 13, an MMU fault in a shader). One run had a fault address: a read of `0xdcf6068000`, which vkd3d's binding log says was inside an image's range that was unbound **846 seconds before** the fault ("very likely use-after-free"). The log can't say whose image it was or which descriptor still named it. From the code, the likely kind is a reserved placed texture (no dimensions in vkd3d's record), which is a guess. **What it does.** With `TUXBOX_CHECK_STALE_IMAGES=1` (and `TUXBOX_LOG`), a shadow of the host descriptors follows creations and copies, separately from the tracking that keeps images alive. At a device loss it logs the ended images that descriptors still name, with up to 4 descriptors each (slot, kind, evicted or not, source), then every ended image kept, with its life in performance-counter seconds to match against vkd3d-proton's BIND and UNBIND times. Every 30 s it counts index-map entries without a slot and says what visible slot 0 names. Off by default; nothing is nulled or kept alive. **Limits:** D3D12 gives no image address, so images are matched by time and size. It takes one lock per descriptor write, so it costs CPU (not measured). At most 1,024 named images and 32,768 ended ones. **Results on an RTX 5090.** Nothing to say in the first (84a: no loss, 8 minutes in the world). In the second (84b) the GPU was lost 11 minutes into the world with it on: **no followed descriptor named an ended image** (28,244 images live, 32,768 ended kept, 160,785 descriptors naming an image), and vkd3d called that fault address (`0x1030b5000`) never-used memory or out of bounds. So a stale descriptor isn't supported as the cause of that loss. It can't see copy paths it doesn't follow, has no positive control in the game, and ran with neither of the earlier losses, so it says nothing about 83a. Index map: about 1.04 million unmapped indices held records, 46,000 empty, and visible slot 0 named no image. ## Tested - Four new unit tests; `python tuxbox.py check --no-gpu` passed (10 of 10). It merges cleanly with our integration branch, where its unit tests and `cargo check` pass. - **What a clean result doesn't show:** the shadow follows the descriptors TuxBox writes. It can't see a shader that uses an index outside the heap or the index map (#472, 30 Nov), so "no descriptor names an ended image" doesn't rule that out. - **Not run:** an AMD run in the game; @ReverendOzmund ran it on an RTX 3080 Ti (#232): 34,529 images live, 9,665 ended kept, none named by any descriptor at that loss. A matching descriptor shows it existed, not that a shader read it. Please use it with `TUXBOX_HOLD_LOST`-style delays if you have them, so the dump completes. - Full `python tuxbox.py check` of 1006ca18 (rebased onto e5d2e913; no change in behaviour): RTX 5090 (`10de:2b85`, 620.70.10) 200 pass, 0 fail; AMD iGPU (`1002:13c0`, RADV) 199 pass, 0 fail. GE-Proton11-14. Evidence: TuxBox check of 1006ca185aa4, no uncommitted changes, GPU 10de:2b85: 16 passed, 0 failed, 0 not run Evidence: TuxBox check of 1006ca185aa4, no uncommitted changes, GPU 1002:13c0: 16 passed, 0 failed, 0 not run 🤖 Generated with [Claude Code](https://claude.com/claude-code)
brcly commented 2026-11-30 04:12:04 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:04Z.


Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase.

  • Formatting: the whole workspace is now formatted with rustfmt (see the new rustfmt.toml).
  • Lints: every crate denies unwrap(), lossy as casts and undocumented unsafe outside tests.
  • CI: it now also runs cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.

The least painful way is to format your branch first, so the rebase only shows real changes:

git fetch origin
git checkout origin/main -- rustfmt.toml
cargo fmt --all && git commit -am "rustfmt"
git rebase origin/main

Then run python tuxbox.py check --no-gpu, which now includes the format step.

If clippy flags something new:

  • A cast: use From for widening, TryFrom for narrowing, and a mask for bit fields.
  • An unwrap(): use ?, or expect with the reason it can't fail.
  • An unsafe block: it needs a // SAFETY: comment.

CONTRIBUTING's "Code checks" section lists the commands. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7268558264 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/567#issuecomment-7268558264). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:12:04Z. --- Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase. - **Formatting:** the whole workspace is now formatted with rustfmt (see the new `rustfmt.toml`). - **Lints:** every crate denies `unwrap()`, lossy `as` casts and undocumented `unsafe` outside tests. - **CI:** it now also runs `cargo fmt --check`, rustdoc with warnings denied, and Miri on the providers' unit tests. The least painful way is to format your branch first, so the rebase only shows real changes: ```sh git fetch origin git checkout origin/main -- rustfmt.toml cargo fmt --all && git commit -am "rustfmt" git rebase origin/main ``` Then run `python tuxbox.py check --no-gpu`, which now includes the format step. If clippy flags something new: - **A cast:** use `From` for widening, `TryFrom` for narrowing, and a mask for bit fields. - **An `unwrap()`:** use `?`, or `expect` with the reason it can't fail. - **An `unsafe` block:** it needs a `// SAFETY:` comment. CONTRIBUTING's "Code checks" section lists the commands. Thanks!
brcly commented 2026-11-30 09:33:35 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T09:33:35Z.


Thanks, this was useful work: it answered its question. In your runs (and @ReverendOzmund's) the result was negative, which rules this theory out for #232.

That's also why I'm holding it rather than merging. On main it would be about 500 lines plus hooks in a hot path (every descriptor write and copy goes through the shadow's check), for a diagnostic that has already said what it can and that nobody needs right now. The branch keeps it available: anyone chasing #232 can merge it locally, and if a new loss points back at this, we'll merge it then.

Feel free to turn it into a draft so it stays findable. I'll leave it open.

<!-- greyfinch-sync:brcly/TuxBox:comment:7274373423 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/567#issuecomment-7274373423). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T09:33:35Z. --- Thanks, this was useful work: it answered its question. In your runs (and @ReverendOzmund's) the result was negative, which rules this theory out for #232. That's also why I'm holding it rather than merging. On main it would be about 500 lines plus hooks in a hot path (every descriptor write and copy goes through the shadow's check), for a diagnostic that has already said what it can and that nobody needs right now. The branch keeps it available: anyone chasing #232 can merge it locally, and if a new loss points back at this, we'll merge it then. Feel free to turn it into a draft so it stays findable. I'll leave it open.
NickStallman commented 2026-11-30 09:39:19 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T09:39:19Z.


Agreed on holding #567 and #568; both were meant for finding the cause, and the branches stay as they are. One limit on the conclusion, so nobody closes the question from it: #567 follows the descriptors TuxBox writes, so a clean result only rules out a followed descriptor naming a destroyed texture. It can't see a shader that uses an index outside the heap or the map, which is what @Jerkin42 has since found on #472. I've added that to the description.

<!-- greyfinch-sync:brcly/TuxBox:comment:7274504424 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/567#issuecomment-7274504424). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T09:39:19Z. --- Agreed on holding #567 and #568; both were meant for finding the cause, and the branches stay as they are. One limit on the conclusion, so nobody closes the question from it: #567 follows the descriptors TuxBox writes, so a clean result only rules out a *followed* descriptor naming a destroyed texture. It can't see a shader that uses an index outside the heap or the map, which is what @Jerkin42 has since found on #472. I've added that to the description.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/567:upstream-pr/567'
git switch 'upstream-pr/567'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/567'
git switch 'upstream-pr/567'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/567'
git switch 'upstream-pr/567'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/567'
git switch 'main'
git merge --squash 'upstream-pr/567'
git switch 'main'
git merge --ff-only 'upstream-pr/567'
git switch 'main'
git merge 'upstream-pr/567'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
brcly/TuxBox!567
No description provided.