WIP: fix(linux): crash and unclean-end records are published on exFAT and FAT drives #1060
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1060
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:crash-record-no-link"
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?
Type: fix · Risk: low · Tested on: Linux x86-64 (game-free checks); Steam Deck OLED (a normal start, ext4) · Needs: steamdeck or Linux with the game on an exFAT or FAT card
Why
With the game on an exFAT or FAT drive on Linux (a Steam Deck's SD card formatted on a PC, a USB stick), no crash record and no unclean-end record is ever kept, so the crash window and a bug report have nothing to show. The records are published with a hard link, which never replaces another record, and those drives have no hard links. Each crash or unclean end then leaves its files behind in
bug-reports/running/, and a later run that the system gives the same process id keeps no record of its own at all.The tracker was searched (
exFAT,hard link,crash record,renameat2,unclean): no issue or pull request is about this.How to reproduce
Seen on: game-free, Linux (Ubuntu 24.04, x86-64, gcc 13.3 and clang 23), with
link()failing as exFAT's and vfat's do (EPERM); in the game, any Linux PC or Steam Deck with the game folder on an exFAT or FAT drive.Settings and switches: defaults.
Steps: run
python -I -B tests/test_crash_record_no_link.pyon main with this PR's test commit; in the game, with the game folder on an exFAT card, start it andkill -SEGVit, then look inbug-reports/.Expected: one
bug-reports/pending/crash-<time>.txt, and nothing left inbug-reports/running/.Actual: nothing in
pending/;running/<pid>.recordandrunning/<pid>.runningstay there, at the next start too.What changed
Where
link()is refused for want of hard links (EPERM,EOPNOTSUPP), the record is moved intopending/without replacing anything there: by the kernel's no-replace rename (renameat2withRENAME_NOREPLACE, which exFAT and vfat support), else onto a name first taken withO_CREAT|O_EXCL. Both are plain system calls, as the crash path needs (it runs in the signal handler), and a name another record has moves on to the next name as before.publishinhost/hos_crash_record.ctriesmove_noreplace(new) after alink()refused withEPERM,EOPNOTSUPPorENOTSUP.move_noreplacecallsrenameat2throughsyscall()(no dependency on a glibc that wraps it), and falls back to theO_EXCLreservation when the kernel or the drive refuses the flag (EINVAL,ENOSYS,EOPNOTSUPP). A failed move removes its reservation. The crash path (hos_crash_record_write, in the handler) and the start's recovery (recover_one, an unclean end or a crash staged but not published) both go throughpublish. Windows is unchanged (MoveFileExW, which never replaces a file).docs/development.mdsays the never-overwrite rule holds on drives without hard links too.tests/test_crash_record_no_link.py(new).Measurements
Verdict: fixed in the game-free test: on main no record is published when
link()is refused as on exFAT; with this PR a crash, an unclean end and a taken name each publish exactly once, never over another record, andrunning/is left empty, with and withoutrenameat2. In the game only a normal start on a Steam Deck's internal ext4 drive, which takes the oldlink()path: clean. The no-hard-link path has not run in the game (Must be tested).Hardware: Ubuntu 24.04 x86-64, gcc 13.3.0 and clang 23.1.5 (no GPU involved)
Scene: none (game-free)
Method:
tests/test_crash_record_no_link.pywith each compiler, at the test commit and at the fix, plus three mutations of the fix; one run each (the test is deterministic)How to reproduce:
CXX=g++ python -I -B tests/run_all.py test_crash_record_no_link, thenCXX=clang++bbe421f5+ the test (30323df4)dbfa1d10link()refused (EPERM)running/keeps itrunning/emptyrunning/emptyrenameat2(ENOSYS, EINVAL)Flags and settings
None.
Testing
Tested:
bug-reports/pending/andbug-reports/running/empty after the quit; no device-loss,VK_ERROR,FATALorCRASH:line; the log the same as the development base's start but for timing-dependent lines. The game folder was on the Deck's internal ext4 drive, wherelink()works, so this shows the change leaves the usual path alone and nothing more: the Deck has no exFAT or FAT drive mounted, so the new path could not be shown in the game. The build was a local test pack on an older development base (main9c9d69ed) carrying this change'shost/diff as it is here. Recorded indocs/tested/2026-11-16-crash-record-no-link-zeldaootr-deck-run01.md.host/hos_crash_record.cwithlink()failing as on exFAT and runs it in separate processes, as the game would; it fails at the test commit and passes at the fix with g++ 13.3 and clang++ 23.1, on mainbbe421f5, and each of the three mutations above makes it fail.tests/test_crash_record.py(#75's checks,link()working) passes unchanged.CXX=g++andCXX=clang++ python -I -B tests/run_all.py --changed forge/main: 17 passed, 2 failed, 0 skipped each; the 2 that fail (test_walk_key,test_vk_occlusion_queries) fail the same way on main. The whole run,CXX=g++ python -I -B tests/run_all.py: 569 passed, 13 failed, 82 skipped; main @bbe421f5the same way: 567 passed, 14 failed, 82 skipped. Every check that fails here fails on main too:test_bug_report_defaults,test_crt_options,test_guest_imported,test_link_skip,test_linux_preflight,test_linux_update,test_make_game_cache,test_missing_nup,test_mods_size_table,test_pending_guest_import,test_run_all_changed,test_vk_occlusion_queries,test_walk_key(main also failedtest_pipeline_cache_save, a timing check). The skips are checks whose tools (the Vulkan headers and the like) are not on this PC.host/hos_crash_record.ccompiled whole with-fsyntax-only -Wall -Wextrafor Linux (gcc and clang, with the build's-D_GNU_SOURCE) and for Windows (llvm-mingw 20261104): no warning, as on main.Not tested: in the game on an exFAT or FAT drive; a real exFAT or vfat mount (the test stands in for
link()'s refusal and uses the test folder's ownrenameat2); a kernel older than 3.15 (norenameat2: theO_EXCLway, which the test runs too).Must be tested:
kill -SEGV <its pid>. Expect, within a few seconds, onebug-reports/pending/crash-*.txtand nothing inbug-reports/running/. The process itself may take a while longer to end: the system writes its core dump after the record (minutes on a Steam Deck); that is not this change.kill -9it at the title, then start it once more and quit. Expect onebug-reports/pending/unclean-*.txtandrunning/empty.pending/empty and<pid>.record/<pid>.runninginrunning/.Risks
What could break: only the publication of a record when
link()is refused; a drive with hard links takes the samelink()path as before. On a drive without them, between theO_EXCLreservation and the rename (only withoutrenameat2), the record's name holds an empty file for a moment.Turning it off: revert the commit.
Compatibility: Nothing changes for a player but that records are kept on exFAT and FAT drives. Files a run left in
bug-reports/running/before this change are published by the next start (an unclean end, or the crash's own record).Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.Tested in game: Steam Deck OLED (SteamOS 3.9.5, Mesa 26.2.0-devel RADV), headless, started as from Steam: a normal start to the title, 6 minutes there, quit exit 0, bug-reports/pending and running empty, no FATAL/CRASH/device-lost line. The game folder was on the internal ext4 drive (hard links work), so the new exFAT/FAT path itself has not run in the game: the Deck has no such drive mounted. (A local test pack on an older development base with this change's host diff.)
Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.