[pr-fix] Replay: the frame recorder no longer crashes on Windows 10 when a command list closes #281
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!281
Loading…
Reference in a new issue
No description provided.
Delete branch "cafe/recorder-close"
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?
What it changes
DARNER_RECORD), the game closed at start with an access violation (0xc0000005): a write intoD3D12Core.dllfrom the recorder'slist_close.D3D12Core.dll1.620) sets a command list's table pointer again onClose, not only onReset. The recorder then took the runtime's own table for its shim and wrote into it.list_resetalready puts the shim back afterReset; this does the same afterClose(5 lines inreplay/record.rs).How it was tested
f3840d73d+ this commit:darner-gpulib tests: 1188 pass, 5 fail, all in code this commit doesn't touch. Tests that need Shader Model 6.6 can't run on Windows 10's own D3D12, so they were skipped.Checked for overlap
No open PR changes
replay/record.rs. gtahub PR 45 and PR 46 (Intel replay work) touch other replay files.Independent Windows build, gate, and code-read review of
2ea0fd2e4(based onmainf3840d73d). Not run in-game or on Windows 10.Environment
x86_64-pc-windows-msvc), MSVC 19.44.35230.Measured results
cargo clippy --workspace --all-targets --locked -- -D warnings): PASScargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASScargo xtask policy: PASS (asset policy: 555 files ok)cargo test --locked -p darner-gpu --features diagnostics --test replay: PASS (1 passed; 0 failedin 1.04 s)cargo test --locked -p darner-gpu --features diagnostics --lib replay: PASS (32 passed; 0 failed; 1 ignoredin 0.63 s)Finding (blocking)
Shimleak and globalMADE/VirtualQuerystorm on everyCloseandResetwhen Windows 10 swaps open/closed vtables (crates/darner-gpu/src/replay/hook.rs:19-29, 99-132, 159-179):hook::Shimstores only oneorigvtable pointer, andMADE: Mutex<BTreeSet<usize>>tracks only created shim addresses without caching(orig_vtbl, state) -> shim.hook::again(hook.rs:169-177), if(*shim).orig as usize != now, it falls through toinstall(this, (*shim).state, patch), which locks globalMADE, runsreadable()(VirtualQuery) twice (hook.rs:116, 120), andBox::leaks a new 4,144-byteShim(state+orig+pre[4]+table[512]).D3D12Core.dllsetsthis->vtblto a closed-state vtable (VT_CLOSED) onCloseand back to an open-state vtable (VT_OPEN) onReset:list_close:now = VT_CLOSED != Shim_1.orig (VT_OPEN)→install()leaksShim_2(orig = VT_CLOSED).list_reset:now = VT_OPEN != Shim_2.orig (VT_CLOSED)→install()leaksShim_3(orig = VT_OPEN).CloseandResetof every hooked host command list ping-pongs forever (even whileDARNER_RECORDis armed/idle), leaking ~8 KiB per list cycle, growingMADEwithout bound, and taking globalMADE+ 2×VirtualQueryon every close/reset.(orig_vtbl, state)insidehook.rs(or keep a small per-shim alternate pointer) so alternatingVT_OPEN <-> VT_CLOSEDallocates at most two shims per list and reuses them thereafter, and add a unit test inreplay/hook.rsexercising alternatingvtbl_a -> vtbl_b -> vtbl_a -> vtbl_b.thisis guaranteed hooked on entry tolist_close, runninghook::againeven whenhr.is_err()keepsof(this)safe, and the other hooked interfaces (device_table,queue_table,library_table) do not swap open/closed vtables.Verdict: Changes requested (add
(orig_vtbl, state)shim reuse inreplay/hook.rsso Windows 10Close/Resetdoes not leak shims on every list cycle).AI-assisted: yes (Gemini 4 Neon).
Thanks, good catch: fixed in
91b554973.Each shim now keeps a link to the shim made for the same object's other table. A list that switches between the open and closed tables (Windows 10's
Close/Reset) reuses the same two shims: after the firstClose, no new shim, noMADElock and noVirtualQuery.switching_between_two_tables_reuses_two_shims(open → closed → open, three rounds: the same two shims each time, and the calls still reach the right table).cargo test --locked -p darner-gpu --features diagnostics --lib replay::hook(2 passed),cargo clippy --locked --release -p darner-gpu --all-targets --features diagnostics -- -D warnings.