Skip to content

Fix save_to_file() crash from concurrent writes - #773

Merged
asimon-1 merged 1 commit into
jugeeya:mainfrom
danbugs:fix/save-to-file-crash
Sep 4, 2026
Merged

Fix save_to_file() crash from concurrent writes#773
asimon-1 merged 1 commit into
jugeeya:mainfrom
danbugs:fix/save-to-file-crash

Conversation

@danbugs

@danbugs danbugs commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

save_to_file() is spawned on a background thread, and a previous write's file handle can still be held open when the next save-state triggers another spawn--the second std::fs::write fails with Horizon FS error 0x0E02 (TargetLocked) and hits the .expect(), panicking the plugin. Added an AtomicBool guard so overlapping calls are skipped, and swapped the .expect() for error! logging so a failed write is non-fatal.

save_to_file() runs in a background thread, and the file handle from a
previous write can still be held open when the next save-state triggers
another spawn. The second write fails with OS error 0x0E02 and hits the
.expect(), panicking the plugin.

- Add an AtomicBool guard so a second call while one is in flight is
  skipped
- Replace the .expect() on std::fs::write with error! logging
- Log info! on success for visibility in skyline logs

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@danbugs
danbugs requested a review from jugeeya as a code owner September 4, 2026 20:19
@asimon-1

asimon-1 commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

LGTM, thanks for the pull request!

@asimon-1
asimon-1 merged commit 446eb54 into jugeeya:main Sep 4, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants