Loader: accept identical destination when concurrent publish rename fails #2795
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2797"
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?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:47:52Z.
What
publish::write_if_changednow treats a failedstd::fs::rename(&staging, path)as success ifpathalready holds the exactbytesbeing published (after removing the staging file), and also removes the staging file on a failedstd::fs::write.Why
victory_loader::loadcallspublish::write_if_changed(&path, &prepared.bytes)and immediately mapspathwithLoadLibraryExW, which opens the file withoutFILE_SHARE_DELETEon Windows. When two runners prepare the same image into a shared cache directory concurrently, both can miss the initialstd::fs::read(path)fast path, write distinct staging files, and race onstd::fs::rename. Once the winner renames and mapspath, the loser'srenamefails withPermissionDenied/ sharing violation even thoughpathalready contains the identical prepared image.If
pathholds different bytes (or cannot be read), the original rename error is still returned after removing the staging file.Verification
cargo test --locked -p victory-loader: 36 passed, 0 failed (including two deterministic WindowsFILE_SHARE_READ-locked tests covering both identical and differing destination contents).cargo clippy --locked -p victory-loader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 184 files ok.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:14:32Z.
Review: COMMENTED
Correct fix for the Windows rename semantics:
fs::renameover a destination opened withoutFILE_SHARE_DELETEfails, and when several runners publish the same title image the loser's rename can fail after the winner already wrote identical bytes. Comparing the destination to the staged bytes on failure turns exactly the 'someone else published the same bytes' case into a no-op success, and returns the original error otherwise. Tests lock the destination with read-share only, which reproduces the rename failure deterministically. LGTM.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:23:07Z.
Automated triage for the maintainers.
In
publish::write_if_changed(crates/victory-loader/src/publish.rs), this PR treats a failed rename as success when the destination already holds the same bytes (newpublish_staged). It also removes the staging file when the write itself fails. The race is real:windows.rsmaps the published image withLoadLibraryExWstraight after publishing, and Windows will not rename over a mapped image. A different or unreadable destination still returns the original error. The two new Windows tests lock the destination without delete sharing. CI passes.Minor: the PR also reflows an unrelated
assert!in the existing test, and the module doc no longer mentions renaming over another writer's file.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T01:12:48Z.
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
ea27d8e(on its base13f91ca).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 775 passed, 0 failed, 9 ignored.concurrent_rename_accepts_identical_locked_destination,failed_rename_with_different_locked_destination_still_errors.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T03:12:59Z.
Review: APPROVED
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-loader --lib publish::tests: 4 passed, 0 failed (including newconcurrent_rename_accepts_identical_locked_destinationandfailed_rename_with_different_locked_destination_still_errors).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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.