Console instructions: a fault raced by its own patch runs the new bytes #2614
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2614
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2614"
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?
@gabrielecabrini on GitHub · 2026-11-29 14:58 UTC · original
gabrielecabrini:fix/console-insn-patch-race→main· +30 −1 · 1 files · 1 commits · closed without mergingWhat
A console-only instruction (
insertq,extrq,monitorx,mwaitx, aclzeroloop,clwb) is replaced in the title's code the first time it faults. When two threads hit the same site, one can fault on the old bytes while the other replaces them. The late thread's handler then reads the new bytes at itsrip(ourjmpto the stub, or the no-ops), which do not decode as console-only, soemulatereturned 0 and the title died with an unhandled0xc000001d.Evidence
4.5 minutes into play on an Intel i5-14600KF (no SSE4a), Proton Experimental, RTX 4070 SUPER (2026-11-29):
e9 …. 90at the faulting address is our own jump over a 6-byteinsertq: an illegal-instruction fault on a validjmp, which only a fault taken on the old bytes explains.Fix
crates/victory-loader/src/console_insn.rs:patch()(waits,clzeroloops, SSE4a) and theclwbpath note the address they replaced in aPATCHEDlist.emulate, when the bytes atripdo not decode andripis a noted place, it returnsCONTINUE_EXECUTIONwithout movingrip: the thread runs the new code.VICTORY_PATCH_SSE4A=0 VICTORY_PATCH_WAITS=0 VICTORY_PATCH_CLZERO=0was the only way around it, at the cost of one exception per execution (oneinsertqalone faulted ~3,700 times a second).Tests
an_sse4a_instruction_becomes_sse2now also faults a second time at the patched place, as the late thread would, and expectsCONTINUE_EXECUTIONwithripunchanged.console_insntests pass (cross-built withcargo xwin, run under Proton).cargo clippy -p victory-loader --all-targets -- -D warningsstops at an unusedcrash::unwind_copywithoutdiagnostics; that error was already onmainbefore this change.@dyshay on GitHub · 2026-11-29 15:40 UTC · original
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch
janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with--profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.github-bot referenced this pull request2026-11-29 19:19:29 +00:00
@AimLogin on GitHub · 2026-11-29 19:27 UTC · original
Review note on the race fix (read from the diff, not run):
One window is still open.
note_patchedis called only after thecmpxchg16bstore,VirtualProtectandFlushInstructionCache, andwas_patchedtakes onlyPATCHED, notPATCHING. A thread that faulted on the old bytes can therefore read the new bytes atripwhile the patching thread is between the store andnote_patched. It finds no entry,emulatereturns 0, and the title still dies with0xc000001d. The two system calls make that gap wider than it looks. Theclwbpath has the same order (note_patched(rip)after the secondVirtualProtect).Either change closes it:
PATCHINGbefore the lookup inwas_patched, so a late thread waits for a patch in flight, which has recorded its site before it releases the lock;#2585 fixes the same #2393 by reading the fault bytes under the patch lock and matching them exactly against the recorded replacement, so the two PRs overlap and probably only one should land.
Review was AI-assisted.
@gabrielecabrini on GitHub · 2026-11-29 22:08 UTC · original
Closing in favour of #2585, which fixes the same #2393 and closes the window AimLogin pointed out here (the replacement is recorded under
PATCHINGand the late fault is matched under the same lock). One fix for this is enough.Pull request closed