Loader: a clzero on a guarded line goes through the guard, not out of the run (Intel 0xc000001d; port of fxceless#1380) #698
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!698
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-698"
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?
@kibagami-nc on GitHub · 2026-11-28 03:39 UTC · original
kibagami-nc:fix/clzero-on-guarded-line→main· +131 −6 · 1 files · 1 commits · merged 2026-11-29 08:16 UTCThe problem
On a CPU without
clzero(Intel), the emulation incrates/victory-loader/src/console_insn.rsdeclines a line thatwritablerefuses. The code readsreturn 0; // the real instruction faults there too.On the console that fault is an access violation. The write watch's vectored handler resolves it for a guarded block, like any store of the title. Here the exception is an illegal instruction, which the guard never sees, so a
clzeroon a write-protected line of title memory was left unhandled and the run ended.This was seen as
0xc000001don the 12-byte loopclzero; add rax, 40h; cmp rax, r10; jb, 22 minutes into the opening, on an Intel i9-9900K. The report is in fxceless/victory-fork#1380, on a tree with the same early return.The change
zero_through_fault(line)handles a line that is committed or reserved but not writable. It zeroes the line with ordinary stores from the handler: they fault, the guard opens the block, and they complete.writable_to's remembered regions already rely on that ("the write then faults inside the handler, which the guard on view memory opens").This is a port of the fix in fxceless/victory-fork#1380 (arbelonson-source). It is cut to what this tree's emulation needs. That fork's
console_insn.rshas more that this one does not, such as per-kind counts and the 15-byte loop taken whole.Tests
New
console_insn::tests::clzero_on_a_guarded_line_goes_through_the_guard. It uses a read-only page and a vectored handler that opens the page on a write, as the guard does. It covers:clzeroon that page: the line is zeroed and nothing else is touched;raxmoves on to the next;With the two early returns put back, it fails at the first case.
cargo test -p victory-loader --locked --lib: 46 passed, three runs.cargo clippy -p victory-loader --all-targets -- -D warnings, with and without--all-features: no warnings.It merges cleanly with #572, which changes the same file elsewhere (the stubs' regions).
Checked by others
nick0451 (i9-14900K, RTX 3090, Windows 11) merged this onto
mainat63b902f:cargo test -p victory-loader --lib --lockedpassed 46 tests in 5 of 5 runs, and clippy was clean. With the early returns put back, the new test fails at its first case.VICTORY_PATCH_CLZERO=0) and for a loneclzero. That fits the crash 22 minutes in, rather than one in every run.No game files, dumps or extracted data are included.
The clzero emulation declined a line that writable() refuses ("the real instruction faults there too"). On the console that fault is an access violation, which the write watch's vectored handler resolves for a guarded block like any store of the title. Here the exception is an illegal instruction, which the guard never sees, so a clzero on a write-protected line of title memory was left unhandled and the run ended: 0xc000001d on the 12-byte loop, 22 minutes into the opening on an Intel i9-9900K (no CLZERO). A line that is committed or reserved but not writable is now zeroed with ordinary stores from the handler (zero_through_fault): they fault, the guard opens the block, they complete, as writable_to's remembered regions already rely on. The lone instruction does it for its line; the 12-byte loop does it for its first line and goes on at the next. Free memory is still the title's exception. Port of the fix in fxceless/victory-fork#1380 (arbelonson-source), cut to what this tree's emulation needs: that fork's console_insn.rs has more (per-kind counts, the 15-byte loop taken whole) that this one does not. Test clzero_on_a_guarded_line_goes_through_the_guard: a read-only page and a vectored handler that opens it on a write, as the guard does; a lone clzero on it, then the loop with its first line there, then free memory. Before the change the emulation refused the guarded line.@Dukestar69 on GitHub · 2026-11-28 04:26 UTC · original · approved these changes
LGTM — verified on Windows:
cargo test -p victory-loaderpassed (46/46 unit tests includingclzero_on_a_guarded_line_goes_through_the_guard+ 3/3 integration tests)cargo clippy -p victory-loader --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (294 files ok)Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot referenced this pull request2026-11-28 05:03:10 +00:00
github-bot referenced this pull request2026-11-28 14:29:07 +00:00
github-bot referenced this pull request2026-11-28 14:31:20 +00:00
github-bot referenced this pull request2026-11-28 14:32:24 +00:00
@nick0451 on GitHub · 2026-11-28 07:19 UTC · original
Tested on Intel: i9-14900K, RTX 3090, Windows 11. This PR merged onto main at
63b902f.cargo test -p victory-loader --lib --locked: 46 passed in 5 of 5 runs (default parallel threads).cargo clippy -p victory-loader --all-targets --locked -- -D warnings: clean.clzero_on_a_guarded_line_goes_through_the_guardfails at its first case (a clzero on a guarded line), as the description says. So the test covers the change.zero_through_fault(not part of this PR) to see whether the path is taken in play. It was taken 0 times in those 5 minutes. On this tree the 12-byte loop is replaced by the stub at its first fault (ClzeroLoop { end_reg: 10 }was emulated once, then patched), and the stub's plain stores fault into the guard like any other store. So the new path should only matter where the patch is not made (stubs out of reach,VICTORY_PATCH_CLZERO=0) or for a loneclzero. That fits a crash 22 minutes in rather than one in every run.The code reads right to me: the loop advances
raxby one line and runs the same instruction again, by which time the guard has opened the block, and free memory still returns 0 as before. Looks good to merge.Tested with an AI assistant (Claude Code); results are from this PC.
github-bot referenced this pull request2026-11-28 22:35:36 +00:00
github-bot referenced this pull request2026-11-29 03:55:10 +00:00
victory-image-*.dll+0x1330a44#706github-bot referenced this pull request2026-11-29 04:32:09 +00:00
github-bot referenced this pull request2026-11-29 09:12:25 +00:00
github-bot referenced this pull request2026-11-29 09:17:53 +00:00
victory-image-*.dll+0x1330a44#706github-bot referenced this pull request2026-11-29 09:45:03 +00:00
github-bot referenced this pull request2026-11-29 09:55:55 +00:00
github-bot referenced this pull request2026-11-29 11:00:49 +00:00
github-bot referenced this pull request2026-11-29 12:27:35 +00:00
github-bot referenced this pull request2026-11-29 12:27:36 +00:00
github-bot referenced this pull request2026-11-29 13:00:38 +00:00
github-bot referenced this pull request2026-11-29 17:55:55 +00:00
github-bot referenced this pull request2026-11-29 18:06:54 +00:00
github-bot referenced this pull request2026-11-29 19:35:56 +00:00