fix(gpu): let the device-loss report see long live allocations #435
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/lobomfz--VIctory-xmem!435
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-435"
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?
@Luxuride on GitHub · 2026-12-04 02:46 UTC · original
Luxuride:fix/gpu-book-holders→main· +36 −4 · 1 files · 1 commits · merged 2026-12-05 17:27 UTCWhat is wrong
Bookkeeps two maps for one question:by_startfor entries that fit in a window, andlongfor the entries longer thanLONG(64 MiB) that cannot be found by scanning a window at all (crates/victory-gpu/src/book.rs:32-37).aliveconsults both (book.rs:136-148), ending in|| self.long.iter().any(holds).holders, its sibling with the same documented meaning — "the live entries that holdat" — scans only the 2 GiB window belowat(book.rs:151-161):A live allocation longer than 64 MiB whose start is more than 2 GiB below the fault address is therefore invisible to it, while
alivestill says it is there. The two constants contradict each other: ifLONGESTreally were "longer than anything of ours",alive'slongfallback would be dead code.Concrete failure
holdershas one caller, the device-loss report (book.rs:715-718), which prints every holder under; BOOK: alive there:and every released entry under; gone there. When the DRED fault address (fault.PageFaultVA,crates/victory-gpu/src/host.rs:4857) falls inside a large live allocation more than 2 GiB from its start, the report lists it under neither heading — it says the book never had that address, which is the one conclusion that is certainly false, in the one report someone reads after a device loss.This is the shape the bug hides in: an allocation has to be >64 MiB and the fault >2 GiB past its start. Just under 2 GiB works today, which is why no capture shows it.
The change
One predicate, both sources, same order (last start first), same 8-entry cap:
The identity check keeps an entry that is both in the window and in
longfrom being printed twice. Nothing changes while every live entry is ≤ 64 MiB:longis empty then.Plus a regression test that books a 3 GiB entry at
0x7f00_0000_0000, asserts the fault at+2 GiB + 4 KiBhas exactly one holder thataliveagrees is alive, and that the address one byte past the end has none (theat - start < sizeboundary is what the oldfiltergot right).Validation
cargo check -p victory-gpu --tests --target x86_64-pc-windows-msvc—Finished.windowscrate, DRED), so the test cannot execute on this Linux host; the behaviour was proved with a standalone harness that copiesEntry/add/remove/alive/holders/gone_atverbatim from this file and books the same 3 GiB entry: oldholders= 0, patched = 1,fate = Alive, and the just-under-2-GiB and past-the-end cases stay correct.Overlap
crates/victory-gpu/src/book.rsappears in none of the 100 open PRs (checked bygh pr list --json filesplus a per-PR diff grep forbook.rs,holders,LONGEST), and no issue mentionsLONGESTor the device-loss report.bookis behind thediagnosticsfeature:cargo test -p victory-gpu --libdoes not compile it, so the tests here run withcargo test -p victory-gpu --tests --features diagnostics.@Kal0s-design on GitHub · 2026-12-04 03:14 UTC · original
Tested this natively on Windows 11 (MSVC) with one NVIDIA desktop card.
The bug is real on main. I dropped your 3 GiB case into the base tree as a throwaway test and
holdersreturns nothing for the fault 2 GiB + 4 KiB in, whilealivesays true. With the PR the new test and the existing book tests pass.Heads up that
bookis behind thediagnosticsfeature, socargo check -p victory-gpu --testswithout it does not compile book.rs at all, and a plaincargo test -p victory-gpu --libskips these tests. I ran them with--features diagnostics. The full gpu lib suite fails the same tests on this branch as on main here, and clippy has no new warnings.Small nit on the dedup. It matches on start and size, so two live long entries with the same start and size (say a heap and a resource placed over all of it) collapse into one when the fault is more than 2 GiB past their start. I checked it with two 3 GiB entries at the same address and got 1 holder far out, 2 near the start. Comparing with
std::ptr::eq, or skipping long entries whose start is already inside the window (e.start >= from), keeps both.Also
holdershas a second caller in the slot reach loop of the same report (it sizes a texture from its holders), so that one gets the fix too.AI-assisted: yes
a2a8a867c7to401e2d5821401e2d5821to23b39b827b@Luxuride on GitHub · 2026-12-04 11:12 UTC · original
Fixed: the dedup is by identity now (
std::ptr::eq(*o, e)), not by start and size, so two live entries over the same range stay two holders. The dedup itself is needed because a long entry of at mostLONGESTis inby_startas well as inlong; only the ones past it are reachable solely throughlong, which is the whole reasonalivelooks at both.Thanks as well for the
--features diagnosticsnote —book.rsis behind that feature, socargo test -p victory-gpu --libsilently skips these tests, and I have made the PR description say which invocation actually runs them.23b39b827bto0c0aea1e1d