loader: stop clzero loop emulation before address wraparound #3256
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
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
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
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/Marvisak--VIctory!3256
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3256"
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?
@cloph-dsp on GitHub · 2026-11-26 14:46 UTC · original
cloph-dsp:fix/clzero-wraparound→main· +22 −3 · 1 files · 1 commits · openDepends on: #1633 (claim
CLZERO-WRAPAROUND; earlier PR #2555 closed unmerged).The emulated
clzeroloops advanced their line pointer withwrapping_add(0x40). If a loop's limit was nearu64::MAX, the pointer wrapped to a small address and the emulator kept zeroing lines instead of ending the pass. A smalladvance_linehelper now useschecked_addand both loops stop when the next line would wrap.Test:
crash::tests::clzero_loop_advance_stops_before_u64_wraparoundchecks the valid boundary (u64::MAX - 0x40→u64::MAX) and thatu64::MAX - 0x3fandu64::MAXare rejected, without touching invalid memory.Validation (Windows, Rust 1.100.0/MSVC, worktree-local
CARGO_TARGET_DIR):cargo test --locked -p victory-loader --lib -- clzero— 8 passed, 0 failed (existing loop tests unchanged).git diff --check— clean.origin/main.AI-assisted (Hy4 flash). Synthetic inputs only; no game assets, extracted shaders, logs or DRM material were used or uploaded.
@AurumCarlos on GitHub · 2026-11-26 15:05 UTC · original · reviewed
Two things:
u64::MAX(reeledMarek closed it on that basis). Unless something has changed since, this guards an unreachable case; worth answering that triage note in the description.advance_lineis inserted betweenclzero's doc comment (/// # Safety …) andunsafe fn clzero, so the Safety section now documentsadvance_lineandclzerohas none. Moving the helper above that comment block fixes it.@Dukestar69 on GitHub · 2026-11-26 15:31 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64:
advance_line(checked_add(0x40)) in bothclzeroloop emulation paths cleanly stops beforeu64address wraparound instead of wrapping to low memory.cargo test -p victory-loader --lib crash:: -- --test-threads=1: 25 passed, 0 failed (includingclzero_loop_advance_stops_before_u64_wraparound).cargo clippy -p victory-loader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.