fix(builder): profile.json is edited under the edit lock, read again after the picker #3021
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3021
Loading…
Reference in a new issue
No description provided.
Delete branch "PedroRossi/Longshot:fix/profile-for-edit-lock"
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?
Summary
profile_for(longshot-builder/src/play.rs) reads the profile, may open the game-file picker (which can stay openfor minutes), then writes the whole profile back, without the edit lock that launcher-profile's
edit.rssays everyeditor takes (the launcher's
channel.rsdoes). A licence the launcher records while the picker is open is writtenover, and DLSS is left out of the build; a mod added meanwhile likewise.
After the picker,
profile_fornow takeslauncher_profile::edit_lock(dir), reads the profile again under it, makesits change and writes.
How to see it on main: start a play that opens the picker, accept the DLSS licence in the launcher meanwhile, then pick
the game: the licence is gone from
profile.json.Read first:
profile_for.Testing
Tested: game-free: the new test (its picker changes the profile while open) fails on main and passes here;
longshot-builder's tests (LONGSHOT_NO_CLANG=1: the site-hooks test wants clang), clippy -D warnings, rustfmt. As
pr createasks for a builder change: Debian 13, GeForce GTX 1660 SUPER, NVIDIA 550.163.01: the game built by a builder from main @1938a302with #3018, #3020 and #3021 merged, through the PC's job queue, played from the Market entrance repository save, then the control bridge's quit; exit 0. The profile code this changes runs in the launcher's play and build, not in the game.mise run test(--strict) on main @1938a302, and on main with this change merged (together with #3017, #3018, #3019, #3020, #3022, from the same audit): 775 passed, 145 failed, 10 skipped both ways, so none fails only with it. The 145 are named at the end.Still to test:
Measurements
Nothing to measure: one lock and one read of a small file, after the picker.
Risks
profile_fornow waits for the edit lock when another editor holds it, up to the lock's wait, and fails with thelock's error past it. A revert undoes it.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.The 145 checks of
mise run testthat fail on main @1938a302on this PC too, with or without this change97 need a tool this PC doesn't have on PATH (
--strictfails them):48 fail on main itself: test_blocks_at_start.py, test_bug_report.py, test_cloth_kernels.py, test_cloth_loops.py, test_cloth_sphere.py, test_cloth_step12.py, test_cloth_step8.py, test_cloth_step9.py, test_control_picture.py, test_crash_record.py, test_crt_options.py, test_dev_update.py, test_dlssg_pace.py, test_draw_stream_visibility.py, test_framegen_resources.py, test_fsr_uniform_ownership.py, test_game_boundary.py, test_guest_holes.py, test_image_reaper_threads.py, test_image_view_retry.py, test_input_background.py, test_keyboard_option.py, test_linux_pressure.py, test_loaded_modules_drop.py, test_log_levels.py, test_menu_keys.py, test_menu_save_atomic.py, test_mesh_first_types.py, test_oot_occ_raster.py, test_option_ids.py, test_perf_send.py, test_pipeline_tour.py, test_present_acquire_ahead.py, test_present_image_free.py, test_present_source_crop.py, test_program_cache_cleanup.py, test_program_cache_one_variant.py, test_readback_timeout_reuse.py, test_recording_admission.py, test_screensaver.py, test_switch_table.py, test_target_retention.py, test_tex_desc_memo.py, test_thinlto_tls.py, test_upscaler_round_trip.py, test_vram_compact.py, test_windows_display_startup.py, test_windows_on_linux.py
Found in an AI-assisted audit of the repository. The test, the fix, the runs and this description were made with Claude Code; I reviewed them.
Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
Tested in game: Debian 13, GeForce GTX 1660 SUPER, NVIDIA 550.163.01: the game built by a builder from main @
1938a302with this change merged (and my two other builder pull requests from the same audit), through the PC's job queue, played from the Market entrance repository save, then the control bridge's quit; exit 0. The profile code this changes runs in the launcher's play and build, not in the game.PedroRossi referenced this pull request2026-12-02 17:54:18 +00:00
WIP: fix(builder): profile.json is edited under the edit lock, read again after the pickerto fix(builder): profile.json is edited under the edit lock, read again after the picker@review
Recommendation: Request changes. The reread preserves edits completed while the picker is open, but the lock it relies on can admit two editors at once and still lose a profile update.
The builder rereads the profile after the picker and applies its settings under the shared edit lock, preserving intervening changes in the tested sequence. The added lock and reread are small, but the lock's acquisition race leaves the underlying lost-update bug possible.
Blocking (1): must change before merging.
builder/crates/longshot-builder/src/play.rs:304: The edit lock used here does not reliably exclude a concurrent editor: its new lock file is visible before its holder text is written, and another taker treats that empty file as stale. (more on the line) Do: Make lock publication and stale recovery mutually safe for concurrent takers, and add a deterministic test covering acquisition while the first lock is being published.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for an edit completed while the picker is open: the new game-free test exercises that sequence and the author reports it fails on the base and passes here. Simultaneous lock acquisition remains unsafe.
Other systems: The same profile path is used by play and build on Windows and Linux, and by launcher and mod editors using launcher-profile's edit lock. The game's rendering and runtime are unchanged. The reported game run does not exercise the launcher licence-acceptance scenario.
Switches: None.
Reviewed:
e508b3aaefagainst1938a302fe: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, both commits, the complete diff, Cargo.toml, play.rs and the edit-lock implementation; traced profile reads and writes and the build and play callers. Skimmed Cargo.lock and the reported runs. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no commands from the project, builds or tests were run. CI was still running in the supplied status.
Overlaps and merge order: Unknown; network access is closed and no overlapping pull request was supplied.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -301,1 +301,4 @@};// (the edit lock for the change, taken after the picker, which can stay open for minutes: the profile is read again// under it, so what the launcher or a mod tool wrote meanwhile is kept; launcher-profile's edit.rs)let _lock = launcher_profile::edit_lock(dir).map_err(|e| (FAILED, e.to_string()))?;L1 (blocking): The edit lock used here does not reliably exclude a concurrent editor: its new lock file is visible before its holder text is written, and another taker treats that empty file as stale.
When: If the builder creates the lock file and is paused before writing its PID, a launcher or mod editor can read the empty file, rename it as stale, and acquire a replacement. Both then read and write the profile under guards they believe are exclusive, so the later write can discard the other's licence or mod change.
Do: Make lock publication and stale recovery mutually safe for concurrent takers, and add a deterministic test covering acquisition while the first lock is being published.
e508b3aaefa295342302Rebased onto current main (which rewrote play.rs, though profile_for still read-before-picker and wrote without the lock). The fix is the same — take launcher_profile::edit_lock after the picker and re-read the profile under it — and it now rests on #3020, where that lock became a real OS advisory lock (one holder at a time), so the concurrency concern in the review is handled there. The test (a_change_made_while_the_picker_is_open_is_kept) is verified to fail on main and pass here.
@review
Recommendation: Request changes. The profile is re-read after the picker, but the edit lock still allows two concurrent editors to enter. A licence or mod change can therefore still be overwritten.
The change re-reads the profile under the edit lock after the picker and includes a test for a licence accepted while it is open. Its protection against simultaneous writes depends on a lock that still has a race.
Blocking (1): must change before merging.
builder/crates/longshot-builder/src/play.rs:304: The edit lock used here does not reliably exclude a concurrent editor: its new lock file is visible before its holder text is written, and another taker treats that empty file as stale. When: If the builder creates the lock file and is paused before writing its PID, a launcher or mod editor can read the empty file, rename it as stale, and acquire a replacement. Both then read and write the profile under guards they believe are exclusive, so the later write can discard the other's licence or mod change. Do: Make lock publication and stale recovery mutually safe for concurrent takers, and add a deterministic test covering acquisition while the first lock is being published.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Since the last review (on
e508b3aaef)Still open: L1 (The edit lock used here does not reliably exclude a concurrent editor: its new lock file i…); L2 (The launcher workflow described in the pull request is still awaiting a manual run.)
Checks: Still running: 10 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven: the author reports that the game-free picker test fails on main and passes with this change, but the lock race remains and the manual launcher workflow has not been run.
Other systems: The same edit lock coordinates launcher and mod-tool profile edits on Linux and Windows; its empty-file race applies on both. The game itself does not run the changed profile code.
Switches: None.
Reviewed:
a295342302againstb77c2f4b3e: Read AGENTS.md, CONTRIBUTING.md, docs/dev/standards.md, the pull request template, the diff, play.rs and launcher-profile/src/edit.rs. Reviewed the supplied comments, CI status and test claims; the adjacent Tooling rules and docs/review-checklist.md were unavailable.; nothing run (a code review).Checked and fine:
Testing: The author reports a game-free test failing on main and passing here, builder tests, clippy and rustfmt. The manual launcher interaction remains outstanding; CI is still running. No commands that execute project code were run during review.
Overlaps and merge order: The author identifies #3020 as the intended lock fix, but that implementation is absent at this head; it must be incorporated before this change can rely on it.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@fix
a2953423027f78fd41a5Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The profile update now re-reads under the edit lock, and the reported game-free test covers the lost-licence case. The end-to-end launcher interaction is still awaiting a manual run. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
7f78fd41a5. I rebased it ontomain(14f452f810). I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The builder preserves profile changes made while the game-file picker is open. It adds a short lock wait and a second profile read; the follow-up adds lock tests without changing the fix.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
Checks: they run again on this head; a failure shows on the pull request.
More: does it help, other systems, switches, what was read
Does it help: Unproven end to end: the author reports that the game-free test fails on main and passes with the fix, but the launcher workflow has not yet been run by hand.
Other systems: The profile path is used by launcher play and build on Windows and Linux. The lock uses the operating system's advisory lock; the reported in-game run does not exercise the launcher interaction.
Switches: None.
Reviewed:
7f78fd41a5against14f452f810: Read AGENTS.md, CONTRIBUTING.md, the pull request template, launcher-profile/src/edit.rs, the profile_for implementation, the changed test contexts, and the fix diff. The stated base-to-head diff spans 896 files; it was only skimmed and was not read in full. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: The author reports the targeted game-free test, builder tests, clippy and rustfmt passed. CI has not run on this head; no commands that execute project code were run for this review.
Overlaps and merge order: The change rests on the advisory-lock change #3020, which is present in the head.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.