fix(linux): a restart no longer hands the game its own log as stderr, so the new run moves it and the crash window finds it #1059
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1059
Loading…
Reference in a new issue
No description provided.
Delete branch "zeldaootr/Longshot:restart-log"
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: Steam Deck OLED (SteamOS 3.9.5, RADV); Linux x86-64 (game-free checks) · Needs: none
Why
On Linux, after the game restarts itself (the Insert menu's Restart now, or a restart a changed setting asks for), its log is wrong: the new run's lines go on at the end of the old run's
longshot_log.txtinstead of a fresh log, the old run is not kept aslongshot_log.1.txt, and if the new run crashes, the crash window shows the crash without its log. That hits every player who starts the game from its icon, Steam or the launcher and restarts it, the Steam Deck included, and the log is what a bug report sends.The tracker was searched (
restart,relaunch,longshot_log,stderr): 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); in the game, any Linux PC or Steam Deck.
Settings and switches: defaults; the game started with no stderr of its own (from its icon, Steam or the launcher, or
2>/dev/nullfrom a shell).Steps: start the game, restart it (Insert menu, Restart now; or the control bridge's
relaunch), then readlogs/longshot_log.txtandlogs/longshot_log.1.txtin the game folder. Game-free:python -I -B tests/test_restart_log.pyon main with this PR's test commit.Expected:
longshot_log.1.txtholds the first run, and the newlongshot_log.txtstarts with the second run's version andrun_idlines.Actual: the second run's lines follow the first run's in
longshot_log.txt;longshot_log.1.txtis the run before the first (or missing).What changed
The Linux restart becomes the game again with
execve, which keeps the open stderr. A game given no stderr writes its log there, so the new run found its own log file as stderr, took it for a stderr it was given, and neither moved the log to.1nor named it for the crash window. Now the start remembers whether the game was given a stderr, as Windows already does, and a game given none is started again with none (/dev/null); it gets its log back if the restart fails, so the failure is still logged.hos_relaunch_keep_env(new on Linux) andrelaunchinhost/hos_relaunch.c: the first notes at the start whether stderr was given, by the same testhost/hos_main.cuses; the second puts/dev/nullon stderr for a game given none beforeexecve, and restores the log if bothexecveandexecvpfail.maininhost/hos_main.ccallshos_relaunch_keep_env()before the log is opened as stderr.tests/test_restart_log.py(new) cuts the Linux restart and runs it with stand-ins for the exec;tests/display_startup_failure_test.cppgets a stand-in for the new call.Measurements
Verdict: fixed. In the game-free test, on main a restarted game given no stderr gets its own log as stderr; with this PR it gets none, a game given a stderr keeps it, and a failed restart has its log back. On a Steam Deck started as from Steam, a restart over the bridge left run 1 in
longshot_log.1.txtand a freshlongshot_log.txtstarting with run 2'srun_id.Hardware: game-free on Ubuntu 24.04 x86-64, gcc 13.3.0 and clang 23.1.5; in the game a Steam Deck OLED (SteamOS 3.9.5, kernel 7.2.7-valve2, Mesa 26.2.0-devel RADV)
Scene: game-free; in the game, the title screen, a restart, the title again
Method:
tests/test_restart_log.pywith each compiler at the test commit and at the fix (deterministic, one run each); in the game one run, the two log files read after the quitHow to reproduce:
CXX=g++ python -I -B tests/run_all.py test_restart_log, thenCXX=clang++; in the game, start with2>/dev/nulland the control bridge on,longshot_ctl.py relaunch, quit, readlogs/bbe421f5+ the test (fd0ad1b7)e833a327longshot_log.txtFlags and settings
None.
Testing
Tested:
setsid ./longshot </dev/null >/dev/null 2>&1, so the game opens its own log as stderr), with the control bridge on: to the title, then the bridge'srelaunch, thenquit. The game came back in 1.3 s as the same process;logs/longshot_log.1.txtholds run 1 (itsrun_id), and the newlogs/longshot_log.txtstarts with the version line and run 2'srun_id, with no line of run 1; the quit exited 0. The build was a local test pack on an older development base (main9c9d69ed), carrying this change'shost/diff as it is here, plus the bridge'srelaunchfrom #97, which that base predates. Recorded indocs/tested/2026-11-16-restart-log-zeldaootr-deck-run01.md.bbe421f5.CXX=g++andCXX=clang++ python -I -B tests/run_all.py --changed forge/main: 42 passed, 0 failed, 0 skipped each. The whole run,CXX=g++ python -I -B tests/run_all.py: 568 passed, 14 failed, 82 skipped; main @bbe421f5the same way: 567 passed, 14 failed, 82 skipped, the same 14 checks failing: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_keyandtest_pipeline_cache_save(a timing check that also fails on main under load). The skips are checks whose tools (the Vulkan headers and the like) are not on this PC.host/hos_main.candhost/hos_relaunch.ccompiled whole with-fsyntax-only -Wall -Wextrafor Linux (gcc and clang, with the build's-D_GNU_SOURCE) and for Windows (llvm-mingw 20261104), against the lift's generated headers of an older local build: the same warnings as main, none new.Not tested: main in the game for comparison: the Deck's development base has no bridge
relaunch(the command is refused there), so the bug itself was shown game-free only. The Insert menu's Restart now in the game (it calls the samerelaunch). Windows (unchanged: its restart starts a new process and already keeps whether stderr was given).Must be tested: None.
Risks
What could break: the restart on Linux: a game given no stderr now starts again with
/dev/nullthere, then opens its own log as on a first start. A game given a stderr (a terminal, a pipe, a file) is restarted with it as before.Turning it off: revert the commit.
Compatibility: Nothing changes for a player but that a restart starts a fresh log and keeps the run before as
longshot_log.1.txt.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
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).mainand passing here.tests/that reads changed source updated in this PR, not weakened.Tested in game: Steam Deck OLED (SteamOS 3.9.5, Mesa 26.2.0-devel RADV), headless, started as from Steam with the control bridge on: to the title, then the bridge's relaunch, then quit. The game came back as the same process in 1.3 s; logs/longshot_log.1.txt holds run 1's run_id and the new logs/longshot_log.txt starts with run 2's version and run_id lines; quit exit 0. (A local test pack on an older development base with this change's host diff.)
Code-only review of
e3c2e5c1c4; informational findings, with final approval left to another reviewer.No introduced correctness defect found. The startup probe uses the same stderr classification as the log-opening path, before that path replaces stderr. The saved log descriptor is close-on-exec, and the failure path restores it after both executable attempts fail; externally supplied stderr stays untouched.
The new fixture exercises the production restart body with real descriptors, checks the externally supplied file's identity, and checks restoration after failed exec. It does not perform a successful exec or exercise terminal/pipe inputs and descriptor-operation failures. The reported Steam Deck restart supplies complementary successful-exec evidence, with the older combined development-pack baseline clearly disclosed; it is not a current-head full-build comparison. I have not independently reproduced those results.
Merge coordination: the restart-in-place PR also changes this function to pass its save note. Those changes are complementary; preserve both the note handling and this stderr handling when combining them.
Read the complete diff, surrounding startup/relaunch and POSIX handle code, tests, run record and PR discussion. No builds, tests, generators or game runs performed.
A Linux restart no longer keeps the game's own log as stderr. I read head
e3c2e5c1. Approved.execvekeeps fd 2. A game started from its icon, Steam or the launcher has no stderr, so the first run openslongshot_log.txtthere. The new run then saw a regular file, treated it as a stderr it had been given, and neither moved the log to.1nor named it for the crash window.hos_relaunch_keep_envruns before that open and uses the same test as the log open: a terminal, a pipe or a real file counts as given;/dev/nulland a socket count as none. A restart with none puts/dev/nullon stderr, and puts the log back if both execs fail, so the failure is still logged. The saved descriptor is close-on-exec, so a successful exec does not keep the old log open. Windows already recorded this and is unchanged.The check compiles that restart and runs it on real descriptors. A game given no stderr is not restarted with its log, a game given a file keeps that file, and a failed exec has the log back. It does not perform a successful exec. The Steam Deck run did: started as from Steam, one restart, run 1 in
longshot_log.1.txtand a freshlongshot_log.txtfor run 2. That pack was an older base plus thishost/change. #61 also edits this restart, to pass a save note. Keep both when that one is rebased.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.