Skip to content

host/fs: refuse save commits after failed path mutations - #2690

Closed
thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/save-mutation-failures
Closed

thehobbit85 wants to merge 1 commit into
seedds:mainfrom
thehobbit85:codex/save-mutation-failures

Conversation

@thehobbit85

@thehobbit85 thehobbit85 commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Unexpected save-path errors invalidate the affected working transaction, preserve the last committed save and notify the front end. The connection to issue #1692's game crash and black screen remains unconfirmed; existing damaged saves are not repaired, and the issue stays open.

Conflict refresh — November 14, 2026

Rebased 6f6097230e6e96efb1aabf203853ac8988170f39 onto main 678481d280ee09cbc436bb51416a878ec6183ec3, producing b998ca1baace97a973b6a692b140d256a6495799 on the same branch. The sole conflict was additive documentation: Ocarina's “Found on this game” list retains main's Metal archive-cleanup and graceful-prewarm findings plus the save-failure finding. All seven feature paths retain the same added/removed lines; the filesystem implementation and regression/stub sources are byte-identical to the author's published head. Main's newer lifecycle, pool and dirty-retirement fixes remain intact. Generated symptoms, range-diff, remaining diff and ancestry were checked.

The following checks passed on e886e92a323718a3bb4df5f059405fdd0cb7367a against 1df3182f88c0b067f365c665ab8c1f05408a24d5, Apple M2 Max, Xcode 27.2, native Python 3.14.6 and LLVM 23.1.4:

  • Actual APFS t_fs_mutation: 432 checks passed, and 432 passed under AddressSanitizer/UndefinedBehaviorSanitizer with leak detection disabled. Built through make -C dm/host/tests GAME=0400486024DEC000 using separate native/sanitizer build directories. No real saves were used.
  • make -C dm/host GAME=0400486024DEC000 -j3: passed with the current main integration.
  • Documentation, Metal-cache cleanup, usage and environment catalogue: 19 Python tests passed.
  • Compilation database regenerated; lint_c.py tidy --against 1df3182f88c0b067f365c665ab8c1f05408a24d5 dm/host/hle_fs.c dm/host/tests/t_fs_mutation.c passed: five existing findings, zero new/stale baseline pairs. Whitespace checks passed.

After main advanced to 678481d280ee09cbc436bb51416a878ec6183ec3, the candidate was rebased again. Complete host, graphics and Ocarina profile Git trees and build inputs are byte-identical to the tested integration above, retaining its native, sanitizer, host and C-lint evidence. The only incoming changes concern provisional Unreal memory defaults and their documentation/profile tests. Fresh final-head documentation, profile-guesser, cache, usage and environment tests passed: 50 tests, zero skips; no unchanged native campaign was repeated.

The author's broader host/tools/graphics and failing-before evidence is preserved below with its original revisions. It was not rerun or relabeled as fresh. In particular, the historical graphics run's initial MetalFX HDR assertion remains a limitation. No current full graphics, five-game comparison, gameplay, damaged-save recovery or iOS runtime result is claimed. The original five impacted-game choices and unavailable game-build explanation below remain applicable. Remote CI on this replacement head requires separate verification.

Original proposal, attribution and validation (historical)

An unexpected host error during a save path operation could leave earlier changes in the working directory eligible for Commit. Refuse that incomplete transaction, retain the last committed version, notify the front end through the existing save-failure path, and allow the next complete save to succeed.

Related to #1692 (partial correction; do not close the issue). Credit to AmateurWizrd's filesystem lead and offered commit 566afc34. This adapts the failure handling to current main and adds an independent synthetic regression. The reported game's area-transition crash and subsequent black screen have not been reproduced or connected to this bug. Existing damaged saves are not repaired.

Path lookup, writable opens, create/delete operations and renames now attribute unexpected errors to the exact guest mount's backing transaction, even when lookup fails before a physical path exists. Aliases share that transaction; an independent save can still commit. Ordinary missing/existing/type/invalid-name results, read operations, read-only mounts and nontransactional mounts do not invalidate a save. Recursive deletion stops at the first error instead of losing it on a subsequent directory read. Rename destination probes and guest-name metadata failures also retain the original error.

Validation

Apple M2 Max, macOS 26.6, native arm64, Python 3.14.6, LLVM 23.1.4. No game files were used. Tested head 6f6097230e6e96efb1aabf203853ac8988170f39, based on main de2018e0100e75e782464a830250800bdfebb219.

  • New t_fs_mutation: 432 checks pass, also under AddressSanitizer + UndefinedBehaviorSanitizer. It uses the actual filesystem HLE and real APFS clone/commit/recovery, injecting only the failing POSIX operation. Checks cover failure before path resolution and afterward, shared aliases, independent saves, committed data preservation, one front-end notification with the original errno, ordinary probe results and a successful subsequent save.
  • Failing-before/passing-after evidence: the initial 396-check fixture failed 92 assertions on unchanged main; the added rename destination probe failed 5 assertions before its correction; the two rename metadata cases failed 8 assertions before theirs. All cases now pass.
  • arch -arm64 make -j4 -C dm/host/tests GAME=0400486024DEC000 run fs-directory: pass.
  • python3 -m unittest discover -s dm/tools/tests: 1,586 tests, 32 skipped, pass (includes documentation checks).
  • arch -arm64 make -j4 -C dm/host GAME=0400486024DEC000: pass, including after rebase.
  • lint_c.py tidy dm/host/hle_fs.c dm/host/tests/t_fs_mutation.c with LLVM 23.1.4: zero file/check pairs above baseline. Five existing findings remain in the host file; the new test has none.
  • Graphics: arch -arm64 make -j4 -C dm/gfx/tests GAME=0400486024DEC000 run initially stopped at one t_upscaler_mfx HDR assertion (0.59375 instead of 0.5). The unchanged focused check_t_upscaler_mfx target then passed all its configurations, and the remaining graphics targets passed. This transient initial failure is retained as a validation limitation, not hidden as an uninterrupted clean run.
  • Full host/tools/graphics checks above were on main 9e0ddeebd plus this patch. The only intervening main change was PR Initialize dirty tracking before concurrent pool registration #2225's dirty-page initialization. After rebasing, reran the save regression (432/432), Mac host build and the incoming check_t_dirty_init (8 pools, 0 failed). The filesystem patch and test contents did not change during rebase.
  • git diff --check: pass. No shader-chain tool changed.

scripts/regress.py impact HEAD identifies four affected profiles from usage manifests (Hades, Breath of the Wild, Pokémon Scarlet, Tears of the Kingdom), with 166 profiles lacking manifests. This is static reach analysis, not gameplay validation.

The required scripts/regress.py check --games 0400486024DEC000,0100152000022000,01006F8002326000,010099C022B96000,01007EF00011E000 was attempted and exits 2 because REGRESS_ROOT / REGRESS_GAMES are not configured and there are no local game files. Selected routes and rationale:

Game Reason
Ocarina of Time Report that supplied the save-failure lead
Mario Kart 8 Deluxe Independent account/device save transactions
Animal Crossing: New Horizons Save mount aliases and commit paths
Super Mario Galaxy Older SDK filesystem calls
Breath of the Wild Broad filesystem/save usage confirmed by impact analysis

No gameplay, damaged-save recovery or iOS runtime validation is claimed.

Documentation and scope

Durable mechanism in docs/reference/services.md, linked from Ocarina's “Found on this game” list; symptom index and docs/development.md updated. No game assets, keys, agent planning files or execution journals are included. Fresh main, all-state PR inventory (including drafts), issue timeline, relevant save changes and the offered commit's PR associations were rechecked before publication; no existing PR implements this correction.

@github-actions github-actions Bot added host The Horizon host: SVCs, services, threads, memory (dm/host) docs Documentation game: 0400486024DEC000 A game labels Nov 14, 2026
@thehobbit85
thehobbit85 force-pushed the codex/save-mutation-failures branch from 6f60972 to b998ca1 Compare November 14, 2026 17:11
seedds added a commit that referenced this pull request Nov 15, 2026
…ommit (PR #2690)

Failed writes and resizes already refused the save transaction's next
Commit; path lookup, opening for writing, create, delete, mkdir, rmdir,
clean and rename did not. A game that ignores such a failure (Horizon's
save storage never fails, so games do not check) could then commit an
incomplete save, e.g. an old file deleted and its replacement not
created on a full disk.

A failure in those operations now marks the transaction of the guest
mount it names (aliases share it), even before a physical path exists,
unless the error is one Horizon answers too (missing, existing, wrong
type, not empty, bad name or argument; fs_guest_error). Read-only and
non-transactional mounts are untouched. A rename whose name metadata and
rollback both fail marks it whatever the first error. Recursive deletes
stop at the first failure and keep its errno.

New t_fs_mutation (464 checks on real APFS clones; failed 105 of the
PR's 432 on the previous main). Synthetic only: no lost save was
reported, and the link to #1692's crash and black screen is unconfirmed.

Related to #1692.

Co-authored-by: Eliran Zach <4012041+thehobbit85@users.noreply.github.com>
Co-authored-by: AmateurWizrd <196495025+AmateurWizrd@users.noreply.github.com>
@seedds

seedds commented Nov 15, 2026

Copy link
Copy Markdown
Owner

Landed on main as 73f6cbb, with you and AmateurWizrd credited as co-authors. Thanks.

Changes on top of this PR:

  • The rename rollback case now marks the save whatever the first error was. With ENAMETOOLONG from the name write and a failed rollback, the entry stays at the new path, but save_path_error would have ignored that error. One helper, save_poison_path, finds the save from the guest mount name for both cases, so save_txn_from_path is gone.
  • The list of errors that don't mark the save is now fs_guest_error, with EILSEQ added: APFS returns it for a name that isn't valid UTF-8, which is the guest's error like ENAMETOOLONG.
  • t_fs_mutation has three more cases: an invalid UTF-8 name, a rename name failure that rolls back, and one whose rollback fails. 464/464 pass, also under ASan/UBSan, and t_fs, t_fs_commit_list, t_fs_case and t_fs_directory pass too.
  • I dropped the paragraph in docs/development.md, since it repeated the reference entry, and reworded Ocarina's note so the link to Game crashes when entering a new area, such as the Deku Tree, or Hyrule Field. And when you load the save after the crash it a black screen. (Ocarina of Time) #1692 reads as unconfirmed.

#1692 stays open: this hasn't been shown to cause its crash and black screen. Real save and recovery on a device with a full disk is still untested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 0400486024DEC000 A game host The Horizon host: SVCs, services, threads, memory (dm/host)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants