Watch: range_lock's first read does not undo a set_range_lock that came in meanwhile #2650
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!2650
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2650"
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?
@boraswim on GitHub · 2026-11-29 15:33 UTC · original
boraswim:fix/range-lock-first-use→main· +6 −2 · 1 files · 1 commits · merged 2026-11-30 14:12 UTCPart of #2420 (the switch race noted there from the review of #2439).
What it changes
victory_gpu::watch::range_lock()cachesVICTORY_RANGE_LOCKinRANGE_LOCK(0 not asked yet, 1 off, 2 on). On its first call it didload→ read the env var →store. Aset_range_lock(true)from another thread that lands between thatloadandstorewas overwritten with the env var's answer, which is off by default.In a run this is harmless, because the variable decides the switch once. But
set_range_lockexists for tests of other crates (#[doc(hidden)], used byvictory-hle's xmem tests), and there any thread's firstrange_lock()could switch it back off mid-test.The first read now installs its answer with
compare_exchange(0, ..). If something was set in the meantime, it returns that value instead. There is no change when nothing races: the same single env read, the same cached value.How it was tested
cargo test -p victory-gpu --lib -- watch::62 passed, 0 failed.cargo clippy -p victory-gpu --lib -- -D warningsreports nothing inwatch.rs(main's other clippy errors are #2048's). There is no deterministic test for the interleaving without a hook inside the first read, so none was added.cargo testpassed for the crates it touches: yes (victory-gpuwatch tests)Checked for overlap
range_lockorRANGE_LOCK.