Repository navigation
D3D12-LOADER-CRASH-MEMORY-AT-ISOLATION: remove post-MEM_RELEASE VA-reuse race in memory_at test - #2939
D3D12-LOADER-CRASH-MEMORY-AT-ISOLATION: remove post-MEM_RELEASE VA-reuse race in memory_at test#2939bobcatchris wants to merge 1 commit into
Conversation
|
Controlled address-reuse check under Wine on With the original Cargo binary basename the stock crash tests passed 19/19 on this PR. The combined crash/profile/stack groups passed 23/23, including #2946’s closed-stderr test. This covers the test behavior under controlled reuse on Wine 11.22. MEASURED with synthetic inputs, OpenAI Codex and a separate read-only review. |
KelboLive
left a comment
There was a problem hiding this comment.
The fix is right, and deletion is the only sound option: after MEM_RELEASE the test has handed the range back to the process, so any post-free VirtualQuery on base is unsound — narrowing the window would not have helped. The low-64 KiB anchor is valid (Windows keeps 0..0x10000 permanently MEM_FREE; I verified memory_at(0) and memory_at(0x1008) both return "nothing mapped there" on Win11 26200), and the PR no longer touches base after the free, so re-reservation cannot bite. crash::tests is 19/19 over 40 runs, and the old assertion is provably wrong: when I reverted it and added a throwaway free-then-VirtualAlloc-same-base probe, memory_at(base + 8) reported "read-write".
Two nits, neither blocking:
memory_at(0x1008)is the sameMEM_FREEregion as the pre-existingmemory_at(0), so it adds no coverage — harmless, just not a second case.- The test now asserts nothing about
MEM_RELEASEactually freeing the range. That is inherently untestable in-process, but worth stating explicitly rather than losing it silently.
Merge is clean against current main, and the textual overlap with #2946 is file-only (hunks are disjoint); #2947 does not touch crash.rs.
Claimed in the coordination issue as: D3D12-LOADER-CRASH-MEMORY-AT-ISOLATION (#2570 (comment); ref finding #2570 (comment))
What and why
crash::tests::memory_at_names_what_an_access_hit(d3d12/crates/leonida-loader/src/crash.rs:915) calledVirtualFree(base, 0, MEM_RELEASE)and then immediately assertedassert_eq!(memory_at(base + 8), "nothing mapped there").Under parallel
leonida-loadertest runs (including Windows CI), another test thread can reclaim the just-released VA range viaVirtualAlloc(..., PAGE_READWRITE)or the heap allocator beforeVirtualQueryruns, causing intermittent failures (left: "read-write", right: "nothing mapped there").Fix: remove the racy post-
MEM_RELEASEquery onbaseand exerciseMEM_FREEagainst both0and0x1008in Windows' permanently unmapped low-64 KiB guard region (0..0x10000).Tested
cargo test --locked -p leonida-loader --lib crash::tests: 19 passed, 0 failed.python -I scripts/check_no_game_data.py d3d12/crates/leonida-loader/src/crash.rs: clean.GPUs tested: n/a (CPU/OS virtual-memory query test; Windows 11).
AI-assisted: yes — Gemini 4 Neon (implementation and an independent read-only reviewer pass).
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).