D3D12.X: unregister resource from title_textures before final COM Release (#1359) #1404
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1404
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1404"
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?
@slopgobblercobbler on GitHub · 2026-11-24 15:39 UTC · original
slopgobblercobbler:fix/res-release-uaf→main· +15 −2 · 1 files · 1 commits · openSummary
Fixes #1359:
title_textures::TEXTURESstores raw, un-AddRef'dID3D12Resource*pointers and revives them into owned handles viaID3D12Resource::from_raw_borrowed(&p).map(|r| r.clone())(IUnknown::AddRef) inrefresh_onceandclone_resources.In
real::res_release:super::title_textures::forget(this as usize)previously ran only after the finalf(this)dropped the COM refcount to 0, destroying/freeing the resource, and aftersparseandvramteardown. Any concurrent upload thread could callr.clone()(AddRef) on a freed object or resurrect an object whose backing memory was being torn down.res_release, we now synchronizetitle_texturesunregistration with the final release:late_releaseis enabled andadd(this) == 2(refcount was 1, title's final release), callsuper::title_textures::forget(this as usize)beforef(this)or holding inlate_release.add(this) != 2, checkrem = f(this). Ifrem == 1, callsuper::title_textures::forget(this as usize)before the secondf(this)drops refcount to 0.late_releaseis disabled, probe refcount viaadd(this)and calltitle_textures::forget(this as usize)before the finalRelease().title_textures::forgetfirst in then == 0teardown block beforevram::forgetandUMA_BUFFERSteardown.Changes
crates/xcl/src/hle/d3d12x/real.rs:res_release: unregister fromtitle_texturesbefore finalReleasedrops COM refcount to 0.Tested
cargo test -p xcl -- real: 23 passed, 0 failed (100% pass rate).Not Tested
AI Use
Co-Authored-By: Claude Code (Claude Opus 5.5) / Gemini Antigravity
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@Diskuss on GitHub · 2026-11-24 15:51 UTC · original
Tested on AMD Radeon RX 9070 XT (RDNA4) at
4a966038075702a657d3fdc472e987a735c3641aRyzen 7 5700X3D, 32 GB RAM, Windows 11 Pro 26300.9974, driver 32.0.32015.7029, Rust 1.100.0, DXC 1.9.2602.17, debug build.
Tested:
4a96603as-is (0 commits behind main930e8b4, no merge needed).cargo build --workspace: OK.cargo test --workspace --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored.cargo test -p xcl --lib title_textures -- --test-threads=15 times: 13 passed, 0 failed each run (5/5).930e8b4alone gave 751 passed, 0 failed, 41 ignored, same as the PR.Not tested: retail title /
scripts/smoke.ps1(no game files), release build.Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.
@Anon64 on GitHub · 2026-11-24 15:54 UTC · original
Regression run for this PR: head
4a96603, based onmain930e8b4. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release,XCL_NETWORK=0, A pressed every 4 s from 20 s,scripts/smoke.ps1on a retail title for 60 s.main
930e8b4:this PR:
No device removals or crashes; 98 % of main's frames, 98 % of its peak commit.
Both runs' peak commit is high because of this machine's pipeline preload list at the time (the same on
main), not this PR.Not tested: the whole suite; whether the title reaches the changed code in these 60 s.
Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@DavidM1911 on GitHub · 2026-11-24 17:08 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
@KainanP on GitHub · 2026-11-24 19:35 UTC · original
Thanks for working on #1359. I read the diff at
4a96603(not run).The refcount probes still miss the issue's first path. With the count at 2 (title +
upload_allclone) and two concurrentres_releasecalls: A add→3, B add→4, A Release→3, B Release→2, A Release→1, B Release→0. Neither thread seesadd == 2/c == 2orrem == 1, sotitle_textures::forgetfirst runs in then == 0block, after the object is freed, whilerefresh_once/clone_resourcescan still AddRef the stale pointer fromTEXTURES.A suggestion: make the decision under the lock that the revivers use. For example, do the real Release while holding the
TEXTURESlock and remove the entry in the same critical section when it returns 0, so no AddRef can land in between. Watch for re-entrancy: a clone dropped while that lock is held would deadlock.AI use: Claude Code (Claude Opus 5.5) read the diff; not run. Checked by the user before posting.
@throny on GitHub · 2026-11-24 19:38 UTC · original
Two contributors checked independently and found that #1527 solves the same problem (for #1359) in a different way: #1607, group D4. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@throny on GitHub · 2026-11-24 20:29 UTC · original
Two contributors checked independently and found that #801 #1527 solves the same problem (for #1359) in a different way: #1607, group D38. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.