fix(crash): the crash report finds the run's log wherever its run_id line sits #1375
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!1375
Loading…
Reference in a new issue
No description provided.
Delete branch "omgitsgela/Longshot:fix/crash-dialog-log-run-search"
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, no GPU needed) · Needs: Windows, Steam Deck
Why
On Linux and Steam Deck, "Restart now" from the Insert menu starts the new run in the same process (
host/hos_relaunch.c), and the new run keeps writing to the log the run before left open. That is deliberate. What was not deliberate: when that restarted run crashes, its own report could not find its own log. The report's log section said "Not found: the game logged to no file" whilelogs/longshot_log.txtsat right there, full of the run's lines — because the search for the run'srun_id:line only read the first 8192 bytes, and the restarted run's line lands wherever the first run stopped (a real play session is far past 8 KB). The player pastes a report with no log tail. Deck players restart to apply settings often, so this is the common Deck path.Fixes #1374. See #1259 (the #1259 review round found this pre-existing gap; that PR does not touch it).
How to reproduce
Seen on: Linux (reproduced by test; the same code path runs on Steam Deck)
Settings and switches: defaults
Steps: start the game from a terminal, play until the log passes ~8 KB (any session does), Insert → "Restart now", play until it crashes on its own
Expected: the crash report's "The end of longshot_log.txt" section carries the restarted run's last lines
Actual: the section says "Not found: the game logged to no file"
What changed
The log-ownership probe now streams the file looking for the wanted
run_id:line instead of reading a fixed 8 KB head, under the same 256 MB ceiling the log reader below already uses. Behavior at the head is unchanged; the search just keeps going.host/hos_crash_dialog.c:log_is_run()streams line by line (fgets, 4 KB lines) until it seesrun_id: <wanted>or the ceiling, and reports where that line sits;find_run_log()passes the byte intoRunLog.from, andread_log()feeds the fact parser (map, stage, start-failure) only from that line on — a log inherited across a posix restart holds the run before too, and its map is not this run's. The ring of tail lines stays whole-file: the lines just before a restart are context.tests/test_crash_dialog.py: the fixture'srelaunchmode grows (RESTARTEDenv makes the exec'd run append instead of truncate,CRASH_TEST_RELAUNCH_TOchooses what the restarted run does — default staysclean, the existing pin), and a new case runsrelaunch → crashbehind a first run whose log is 24 KB deep, clicks Report manually, and requires the clipboard copy to carry the restarted run's own line (CRASH_TEST_RESTARTED_LOG: only the restarted run writes it) and not say the game logged to no file. A second case restarts behind a deep run that played in Kokiri Forest and crashes at the start: the box must say during-the-start and the report must not name the old run's map (review round two).source_checks()pins the probe's streaming form (fgets, noread_texthead window, the located byte reported) and theread_loggate.Measurements
Verdict: no fps to measure — a crash-report path fix; the new case fails on main with the exact #1374 text and passes on this branch (mutation-probed).
Flags and settings
None.
Testing
Tested: Linux host:
tests/test_crash_dialog.pyfull suite green (both restart cases, the source pins, plus every existing crash-dialog case, including the originalrelaunchclean-restart pin);tests/test_crash_record.py,tests/test_bug_report.pygreen.tests/run_all.py: this branch @c31c54f6onmain544229a2: 575 / 39 / 107 vs main 573 / 41 / 107 — the only branch-side entry main doesn't share istests/test_perf_report.py's known flaky relay case (green standalone at this head and at the base; #1368's author is fixing its race in parallel). Mutation probes: restoring the 8 KB head-window probe fails exactly the deep-log pin; neutralizing theread_logfact gate fails the box-stage pin (proved with the source-pin string kept in dead code, so only behavior caught it).Not tested: Windows — the code is platform-neutral C in the shared crash dialog; Windows has no same-process Restart now (its restart re-launches and the log block runs normally), so this only affects a rotated-name search there.
Must be tested:
Risks
What could break: a pathological log (256 MB of one line with no newline where the run_id should be): the probe stops at the same ceiling
read_logalready uses. No other caller oflog_is_runbesidesfind_run_log.Turning it off: revert the commit.
Compatibility: Nothing changes for saves, ini, caches, or the vk ABI; players only notice their post-restart crash report finally has the log tail.
Issues
Fixes #1374. See #1259.
Checklist
Everyone
type(scope): description) of the status line's type.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
fgets/strstr) compiled through the same path on both; the fixture runs on this host.mainand passing here.tests/that reads changed source updated in this PR, not weakened.source_checks()gains the streaming-probe pin; nothing removed.Checker fixes only: literal 'Actual:' label in the reproduce block; the Windows/Linux build box added to When it applies (plain C under both toolchains). No code change: head still
bf57a624.bf57a62447fef49480e1Round two (checker guidance): source_checks() now pins the probe's streaming form (tests read host/hos_crash_dialog.c; the check is added, not weakened); AI-assistance trailers added per CONTRIBUTING. Amended head
fef49480(same content + trailer). run_all compared at the same base544229a2: branch 576/38/107 vs main 573/41/107, branch failing set a strict subset (set-compared).Checklist: added the two applicable When-it-applies boxes (game-free test failing on main; source-reading check updated, not weakened). No code change: head
fef49480.The finding is real and verified by the reviewer's probe: a log the run inherits across a posix Restart now holds two runs, and read_log parsed facts from byte zero — so the restarted run's crash report wore the run before's map and stage ("while you were playing", Kokiri Forest) for a run that never left the start. log_is_run now also says WHERE the wanted run_id line sits, and read_log feeds the fact parser only from that line on. The report's tail stays whole-file: the lines just before a restart are context a player and a maintainer both want. Test: the restarted run writes its own line (CRASH_TEST_RESTARTED_LOG: only it can, the way the real game keeps logging; the round-one tail marker now proves the restarted run's own output, reviewer note), and a new case restarts behind a deep run that played in Kokiri Forest and crashes at the start: the box must say during-the-start, and the report must not name the old run's map. Mutation probes: neutralizing the gate fails the box-stage pin; the source pins cover the new signature and the read_log gate.Round two (adversarial review, verdict request-changes — both notes taken):
Head
c31c54f6. tests/test_crash_dialog.py green (both restart cases); run_all 575/39/107 vs same-base main 573/41/107, the extra branch-side entry the known flaky perf relay case, green standalone and named under Testing.The crash report looks through the whole log for this run's
run_idline, and the map and the stage come only from the lines after it. I read headc31c54f6. It applies onto current main, and it merges with #1379. This is not a merge yet.log_is_runused to read 8 KB. A Linux Restart now keeps the same log open, so the new run's line sits wherever the first run stopped, and the report said the game logged to no file. The search now reads line by line up to the same 256 MB ceiling as the log reader, and remembers that line's byte. The tail of the report is still the whole file. The log is cleared before the search, and the byte is set only when the line is found. The check crashes a restarted run whose line is 24 KB in, and a start-crash behind a run that had already named a map.Must be tested is still a Steam Deck: Restart now, crash, Report manually, and the clipboard copy has the log's end rather than "Not found". Only a BigBean can start that.
Round three (the P1 as stated does not reproduce on the shipped head
c31c54f6— evidence, not argument):The finding's mechanism names
hos_crash_record_commit. There is no such function in the tree:grep -rn "record_commit" host/ tests/returns nothing. What exists ishos_crash_record_write(the crash handler's path) andhos_crash_clean_end(the clean-exit path). The probe that produced the result is a re-implementation of the recorder rather than the shipped one, and it skips exactly the steps that matter here.Linux "Restart now" is not a second run inside the same image.
host/hos_relaunch.c:158:execve("/proc/self/exe", r.argv, r.envp). The whole process image is replaced, so every recorder global (ready,claimed,session) starts zero in the new run, and the marker's fd is openedO_RDWR | O_CLOEXEC | O_NOFOLLOW | O_CREAT | O_EXCL(hos_crash_record.c:188), so exec closes it and its flock goes with it.The marker is gone before the restart.
hos_crash_record_writeremoves it right after publishing (:922 remove_file(marker_path)) andhos_crash_clean_endremoves it too (:767). So when the restarted run reacheshos_crash_record_start, there is no<pid>.runningleft to collide with — and exec preserves the pid, which is the one case where a same-name collision was plausible.hos_crash_record_startalso runsrecover()before creating its marker, which claims and clears a stale marker whose flock is free, so even a marker left by a mid-write failure cannot suppress a later run in that folder.The shipped recorder is already under test on that exact path, and it produces the second report.
tests/test_crash_dialog.py:900compileshost/hos_crash_record.c(the real file) with the driver, and the driver'srelaunchmode goeshos_crash_quit_asked(); hos_crash_clean_end(); execv("/proc/self/exe", again)— the shipped sequence. The two cases added in round two assert, for the restarted run, one crash box and a clipboard report carrying that run's own line; both pass atc31c54f6(21 PASS lines, and the mutation probes in the PR body show they fail when the gate is removed). If the P1 were true, those assertions could not pass: the box and the report are exactly what the finding says would never appear.So no change is being made for it. What the finding did get right, and what is worth a separate look: the crash dialog's own process is what execs into the restarted game, so a dialog that hands back a record whose publisher already ran is the only window where recorder state crosses a restart — I checked it and it is closed by the publish-time marker removal above. If a Deck tester sees a missing report after a Restart now in a real build, the log and
crash_reports/folder from that game folder would settle it, and I will pick that up immediately.Rounds one and two stand as described: the deep
run_id:search and the fact gate. Suite atc31c54f6: tests/test_crash_dialog.py green; run_all 575/39/107 vs same-base main 573/41/107, branch-only failures [].Round three accepted, with the two findings fixed on
c6e59fae(your P2 and P3 were both right, and P3 was my own error of ordering):P3, the version line: fixed by moving the gate. The run logs its
longshot <version>banner one line BEFORE therun_id:line; the gate started atrun_id, so every report lost its own log's version and fell back to the crash record's.log_is_runnow records the offset of this run's own] longshotbanner — the nearest one before itsrun_id— andread_loggates from there. An earlier run's facts sit before that banner and stay out.Pinned behaviorally, not by source: the fixture now runs a relaunch where the log says
vlog-9but the crash record saysvrec-7. Only a gate that reads the banner can produceVersion: vlog-9, and the case assertsvrec-7never appears andMap: Kokiri(the run before's) stays out.P2, the Windows write order: fixed by putting the boundary on disk first.
game_mainnow callshos_log_flush()right after the banner andrun_idlines. The direct-stderr startup failures (no image / can't reserve / can't open) then physically follow the boundary, so the batched Windows logger can no longer land them before the run's own start. Pinned on source (no Windows build here):hos_log_flush();must sit within the 900 bytes after therun_idlog call.Probed and found clean on my side, matching your report: the chunk-boundary searches (markers at 4094/4095/4096/8190/20000-byte lines), three-runs-in-one-log isolation, rotated-log lookup, the ceiling at 268435455/268435456, and the full
tests/test_crash_dialog.pysuite green here atc6e59fae.Honest limitation, same as your report: the Windows arm is source-pinned only — no native Windows run exists here. The Test Farm ask covers it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.