loader: retry in-flight faults at already-patched instruction sites #184
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Androtim--MiniVI!184
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/184/head"
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?
@Androtim on GitHub · 2026-11-30 02:14 UTC · original
Androtim:feat/iter181-loader-retry-inflight-patch-fault→main· +52 −7 · 1 files · 1 commits · merged 2026-11-30 03:06 UTCSummary
console_insn::emulatewithPATCHING, which now records each committed replacement keyed by instruction address (BTreeMap<usize, Vec<u8>>).patchorclwbNOP fill),emulateobserves our recorded bytes atRIPand returnsCONTINUE_EXECUTIONwithout advancingRIPso the thread retries execution cleanly on the patched instruction instead of failing to decode it and crashing.console_insn::tests::fault_already_in_flight_retries_only_our_unchanged_patchcovering retry of our unchanged patch, unpatched non-console bytes, and overwritten code at the previously patched address.Verification
cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy(311 files ok)cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-loader --lib(59 passed; 0 failed)cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warningscargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings@Androtim on GitHub · 2026-11-30 03:04 UTC · original
Automated triage for the maintainers (not an approval).
Verdict:
merge-candidate· CI (check):passingReview Summary
Clean, well-scoped fix for a real multithreaded
#UDexception race incrates/victory-loader/src/console_insn.rs.Verified Details
PATCHING,patch,emulate): ChangingPATCHINGfromMutex<()>toMutex<BTreeMap<usize, Vec<u8>>>and snapshottingripunderPATCHINGinemulateensures a thread with an in-flight fault cannot observe half-written patch bytes or miss the recorded replacement. Whenpatches.get(&rip)matchesbytes[..n], returningCONTINUE_EXECUTIONwithout advancingctx.Ripcleanly re-executes the patched instruction.emulatedrops thePATCHINGguard before decoding and before anyConsoleOnly::Clwb,Monitorx/Mwaitx, orClzeroLoopbranch re-acquiresPATCHING(directly or viapatch()/patch_clzero()).bytes[..n].starts_with(patch)prevents infinite retry loops if code at a previously patched address is later overwritten.tests::fault_already_in_flight_retries_only_our_unchanged_patchcovers all three cases (retry on unchanged patch, return0on unpatched non-console bytes, return0on overwritten bytes at a patched site). TheVirtualAlloc/PAGE_EXECUTE_READWRITEstatic-flag hits are confined to this unit test, mirroring the existingclzero_loops_far_apart_are_each_replacedtest.CI is passing and this change is purely CPU instruction emulation in
victory-loader(no GPU/shader/host/launcher impact), so it is ready as a merge candidate.Generated with Antigravity CLI (
agy).