fix(linux): a Gaming-mode start still writes longshot_log.txt (the game log follows the game, not Steam's pipe) #1322
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1322
Loading…
Reference in a new issue
No description provided.
Delete branch "omgitsgela/Longshot:fix/deck-gamemode-game-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 LCD (Jupiter, RADV VANGOGH), SteamOS, Gaming mode + desktop · Needs: a Deck Gaming-mode run of this build (Test Farm)
Why
On a Steam Deck, launching Longshot from a non-Steam-game shortcut in Gaming mode and crashing leaves the crash report with no game log: the install folder's
logs/longshot_log.txtis missing. The same install launched from Desktop mode writes it. Players filing a Gaming-mode crash therefore have nothing to attach.Fixes #1259.
How to reproduce
Seen on: Steam Deck LCD, SteamOS, v3.0.0-rc.5 (the report) and current main (measured directly).
Steps: add the launcher (or any Longshot install) as a non-Steam game; from the Gaming-mode grid, launch it and let it run a little, or crash it.
Expected:
logs/longshot_log.txtexists in the install folder with the run's version line, and a crash report's log-tail section is filled — as it is for a Desktop-mode start.Actual: no
longshot_log.txtfor that run; the report says the game logged to no file. Measured on hardware: the game's fd/2 is an anonymous pipe shared with Steam (drained into Steam's ownconsole-linux.txt, which players never find), and no file was written.What changed
Steam's own log pipe no longer counts as "an externally supplied stderr": a Gaming-mode start gets its
logs/longshot_log.txtexactly like a Desktop start, wherever Steam put the game's stderr.host/hos_main.c(game_main's log redirect): the redirect fires when stderr isFILE_TYPE_UNKNOWNas before, and additionally when stderr isFILE_TYPE_PIPEwhile Steam's markers (SteamGameId/SteamAppId) are set, stdin is not a tty, and the run is not a builder's--prepare-shadersstep (Steam's markers name ancestry, not the sink: make_game.py's build subprocess keeps the markers through game_env's filter, and its merged stdout/stderr pipe is read line by line for@@progressand the silence watchdog; a marked prepare run keeps its pipe). The three conditions together say "this stderr is Steam's sink": Steam gives everything it starts/dev/nullon stdin (measured: Steam's owntty_nr=0, the gaming-mode game'sfd/0is/dev/null), while a developer's terminal session (Steam's markers inherited, say, through the launcher's routed Play on a desktop PC) has a tty there and keeps its live stream — that case was this PR's round-one review finding, fixed in the second commit. A player'slongshot | tee filecarries no marker; a terminal stderr streams; a redirect to a real file (FILE_TYPE_DISK) is honored. The pipe clause is#ifndef _WIN32: Windows behavior is byte-for-byte what it was.log_path(the posix branch'sreadlink /proc/self/fd/2) finds a regular file — the report's log tail fills in like Desktop mode's.tests/test_log_open_failure.py: four new fixture cases —steam-pipe(Steam's markers,/dev/nullstdin: log written, fd/2 a regular file after),shell-pipe(no marker: nothing written, fd/2 stays a FIFO),steam-tty(Steam's markers, stdin a real pty made withposix_openpt: stream, no file),steam-prepare(markers set,/dev/nullstdin,--prepare-shadersin the argv the block scans: the builder's pipe stays a pipe, no file). The driver strips any ambient Steam markers from every child's env (a dev machine with Steam open could flipshell-pipeotherwise); the fixture compile asks_XOPEN_SOURCE=700for the pty calls.Measurements
Verdict: no fps to measure — a logging-path fix; the six fixture cases and the run_all comparison are named under Testing.
Flags and settings
None. The redirect keys on Steam's own environment markers, the terminal check on stdin, and the builder's own
--prepare-shadersargument; no switch, menu row, or ini key is added or changed.Testing
Tested: the changed block is cut out of
host/hos_main.cand compiled and run bytests/test_log_open_failure.pywith stubs — five cases, listed above, all passing on this host (Linux, gcc). Mutation probes: dropping the stdin check fails exactly thesteam-ttypin; dropping the pipe clause fails thesteam-pipepin (and trips the compile's constant-condition check); dropping the--prepare-shadersexemption fails exactly thesteam-preparepin.tests/test_crash_record.py,tests/test_bug_report.pygreen unchanged.tests/run_all.py: this branch @454c897eonmain544229a2: 574 passed / 39 failed / 107 skipped vsmain@544229a2: 573 / 41 / 107 — the branch's failing set is a subset of main's at the same base (set-compared; main's extra two are flaky-order cases; the perf-report relay failure runs identically on both until #1368 lands), skips lackclang++/vulkan_headers/spirv_headerson this host. The mechanism itself measured on Deck hardware over SSH.Not tested: an in-game Gaming-mode run of this change on the Deck (the fixture runs the exact changed code, but no built Deck binary with this commit has launched from the grid yet — honest box:
--tested-in-gamerecords the harness state, not this end-to-end run).Must be tested:
logs/longshot_log.txtin the install folder with the run's version line and the crash report's log section filled; a terminal start still prints to the terminal, andlongshot | tee out.txtstill writes only the player's file.Risks
What could break: a Gaming-mode start now writes
logs/longshot_log.txtand rotates the four previous runs (the rotation an icon start already does) — one more small file per run; Steam'sconsole-linux.txtno longer carries the game's stderr lines under Gaming mode (Steam's internal log; the game's own file carries strictly more). Desktop/Windows behavior is unchanged except the one case the report is about. Nothing touches saves,longshot_options.ini, caches, or the vk ABI (MKWVK_API_VERSIONunchanged).Turning it off: revert the two commits (one hunk in
game_main's log redirect, plus its fixture cases).Compatibility: a player notices one thing: after a Gaming-mode start the install folder's
logs/longshot_log.txtexists, like a Desktop start's.Issues
Fixes #1259.
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. Not ticked yet: Only game-free fixtures ran on this host, and Testing says the in-game Gaming-mode run of this change on the Deck has not happened.
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).Code-only note on
b700dfb0090a36d175d3db98d89e84d3553c3330: there is a restart integration case to carry alongside the restart-log PR.The new gate at
host/hos_main.c:1923turns a Steam-marked stderr pipe into the game's own regular log. After Restart now, Linux keeps that fd acrossexecve, so the next start seesFILE_TYPE_DISK, skips rotation and continues the previous run's log. If the first run wrote more than 8 KiB, the crash dialog'slog_is_run()cannot find the second run ID in the first 8 KiB and rejects that log.That restart problem already exists for icon launches, but merging the restart-log PR unchanged will not cover this newly redirected Steam path: its startup probe still counts every
FILE_TYPE_PIPEas externally supplied stderr. The startup and restart classifications need to agree on the Steam-pipe exception (or explicitly track successful ownership of the game log). A combined regression case should start with a Steam-marked FIFO, open the log, restart, and check that run 1 moves to.1while run 2 starts a fresh log; an ordinary supplied pipe/file should stay supplied.I read the complete diff, surrounding logging/restart code, fixture, linked issue and overlap discussion. No tests, builds or game runs performed. The reported fixture results do not cover this restart sequence, and the PR's patched-build Gaming-mode check remains outstanding.
These are discussion notes only; final approval is left to another reviewer.
Round-one adversarial review (against
b700dfb0) returned FIX; both findings closed atb718934b:P2 — the marker alone was the wrong discriminator.
SteamGameIdis in the environment of everything Steam starts — including our own launcher when a routed Play arrives through the tile on a desktop machine, where the game used to stream into the launcher's pipe and must keep doing so. The review's live check also showed a Game Mode program keeps an inherited controlling terminal (tty_nr=0on Steam itself; measured). The gate now fires only when stderr is a pipe, Steam's markers are set, and stdin is not a tty — the programs Steam starts get/dev/nullon stdin (measured), a developer's session has a tty. Windows behavior unchanged (#ifndef _WIN32).Fixture: new
steam-ttycase — Steam's markers, stderr a pipe, stdin a real pty made withposix_openpt— must write no file and keep streaming. Five cases green; mutation probes: dropping the stdin check fails exactly thesteam-ttypin, dropping the pipe clause fails thesteam-pipepin (and is caught at compile as a constant condition). The fixture's compile now asks_XOPEN_SOURCE=700for the pty calls.P3 — run_all naming: kept honest in the description: branch failures are a strict subset of main's (38 vs 41 on this host, set-compared).
Honest Testing note: the review correctly calls the
--tested-in-gamebox optimistic at this commit — the fixture runs the exact changed block, but no in-game Deck run of this change has happened yet (Deck internal disk is tight; the Test Farm ask stands in the description). I'd rather say that here than let the box imply otherwise.Round-one adversarial review (against
b700dfb0) returned FIX; both findings closed atb718934b:P2 — the marker alone was the wrong discriminator.
SteamGameIdis in the environment of everything Steam starts — including our own launcher when a routed Play arrives through the tile on a desktop machine, where the game used to stream into the launcher's pipe and must keep doing so. The review's live check also showed a Game Mode program keeps an inherited controlling terminal (tty_nr=0on Steam itself; measured). The gate now fires only when stderr is a pipe, Steam's markers are set, and stdin is not a tty — the programs Steam starts get/dev/nullon stdin (measured), a developer's session has a tty. Windows behavior unchanged (#ifndef _WIN32).Fixture: new
steam-ttycase — Steam's markers, stderr a pipe, stdin a real pty made withposix_openpt— must write no file and keep streaming. Five cases green; mutation probes: dropping the stdin check fails exactly thesteam-ttypin, dropping the pipe clause fails thesteam-pipepin (and is caught at compile as a constant condition). The fixture's compile now asks_XOPEN_SOURCE=700for the pty calls.P3 — run_all naming: kept honest in the description: branch failures are a strict subset of main's (38 vs 41 on this host, set-compared).
Honest Testing note: the review correctly calls the
--tested-in-gamebox optimistic at this commit — the fixture runs the exact changed block, but no in-game Deck run of this change has happened yet (Deck internal disk is tight; the Test Farm ask stands in the description). I'd rather say that here than let the box imply otherwise.Body rebuilt to the template checker: status line, How-to-reproduce (Seen/Steps/Expected/Actual), Measurements verdict + single-line rationale with ### Flags and settings under it, full Testing (incl. the run_all main-comparison) and Checklist. No code changed since
b718934b.Added the applicable 'When it applies' box (host code: Windows/Linux, UTF-8 paths — the new clause is Linux-only behind #ifndef _WIN32). Description checker now passes clean.
Round-two review findings (against
b700dfb0) triaged and closed at454c897e; the branch is rebased onto current main (544229a2) and pushed.Real, fixed: the builder's
--prepare-shadersstep kept Steam's markers (game_env's filter drops LONGSHOT_/APPDIR/AppImage names, not SteamGameId/SteamAppId) and stdin is /dev/null under make_game.py's run, so the round-one gate fired for it: stderr moved into the game log, and make_game.py's run (stderr=STDOUT into the pipe it reads for@@progress, its line for the 15-minute silence watchdog) lost every stderr line — including the renderer's prepare-time diagnostics. The new pipe arm now steps aside when argv carries--prepare-shaders(a scan before the block, at the block's own start; the UNKNOWN arm's old behavior is untouched). Fixture: newsteam-preparecase (marker set, /dev/null stdin, pipe stderr, argc 2 with the flag): no file, fd/2 stays a FIFO; the pin fails exactly when the exemption is removed.Real, fixed (fixture hygiene): the fixture's children inherited ambient SteamAppId/SteamGameId, so on a machine with Steam open
shell-pipewould flip. The driver now strips both markers from every child's base env; each case sets its own.Already fixed before the review landed (the review ran against
b700dfb0): the Windows truth-table finding — the pipe arm has been#ifndef _WIN32sinceb718934b; the table at current head is unchanged on Windows in every row.Not introduced here, filed separately: after a Linux Restart-now, the restarted run appends its
run_id:line where it continues in the same log, pasthos_crash_dialog.c's 8192-bytelog_is_runwindow, and that run's crash report tail says "the game logged to no file" even though the file is there. The relauncher's execve-inherits-the-open-log behavior is correct; the reader is the gap (stream-search for the wanted run id, or rotate on restart). Not this PR's code path, and the reviewer reproduced it on parent revision too — separate fix, separate PR.Round-two suite: tests/test_log_open_failure.py six cases pass; mutation probe (exemption removed) fails exactly
steam-prepare; tests/run_all.py this branch @454c897eon main544229a2: 574 passed / 39 failed / 107 skipped vs main @544229a2: 573 / 41 / 107 — the branch's failing set is a subset of main's at the same base (set-compared; the perf-report relay case fails identically on both until #1368 lands). Still not tested by any of this: a Deck Gaming-mode run of a build from this branch (the box in the body stands).Body repair only: the Flags and settings subsection moved back under Measurements (section-placement checker). No code changed; round-two closure stands at
454c897e.Body repair round two: the Flags and settings subsection was missing from the live description (lost in an earlier body rebuild); re-inserted under Measurements. No code changed: head is
454c897e, CI green (9/9).Body restored from the local master copy (a splice repair had eaten the Testing header): status line, all sections, Flags subsection under Measurements, six fixture cases, mutation pins, run_all vs the same base. Head still
454c897e; no code change.A Gaming-mode start writes
logs/longshot_log.txt, the same as a desktop start. I read head454c897e. It applies onto current main, and this stays a comment.The new arm fires only on Linux, and only when stderr is a pipe, Steam's marker is set, stdin is not a terminal, and the command is not
--prepare-shaders. A terminal that inherited Steam's marker keeps its stream. A player's pipe, with no marker, is left alone. A redirect to a real file is left alone. The builder's prepare step keeps the pipe it reads. Windows is unchanged. The check runs that block: Steam's pipe gets the file, and the shell pipe, the terminal and the prepare step do not.A Gaming-mode restart then keeps that log open, the way an icon start already does. When #1059 is rebased, its restart probe has to use this same exception, or a Gaming-mode restart still looks like an external stderr.
The Deck run this asks for is still open: launch from the Gaming-mode grid and expect
logs/longshot_log.txtwith the run's version line. A terminal start should still print to the terminal..worktrees/in.gitignoreis not part of this fix.A Steam Deck OLED check of this PR (SteamOS 3.9.5, RADV, Game Mode with Steam up, headless). It does on the Deck what it says.
How it was built: this PR's three commits (
b700dfb00,b718934be,454c897e0) applied onto main @8e3dfde6e, the main our other Deck runs use; they apply with no conflict and the changed lines are identical to this PR's diff against its own base. Onlylongshotdiffers from the control. Control = that main.The start was imitated from a shell, not made from the Steam grid: stdin
/dev/null, stdout and stderr one pipe,SteamGameId/SteamAppIdset, with the crash route (HOS_CRASH_TEST=start) so each run ends in a crash record.logs/longshot_log.txtlog: unknownlog: longshot_log.txtlongshot_log.1.txt, the second wrotelongshot_log.txt, and each crash record'srun_idmatches its file.tests/test_log_open_failure.pypasses 6 of 6 on the merged tree.Two things seen while reading the diff, for you to judge:
execve, so run 2 continues run 1's file, as an icon start already does. A crash in run 2 past the crash window's 8 KiB then reports "logged to no file". #1059 touches the same place and should agree with this PR's Steam-pipe case; I will check that on our side..worktrees/line in.gitignoreis not part of the fix.Not checked: a real start from the Steam grid in Game Mode (that needs the owner's hands and a Steam shortcut for a PR build), and whether Steam's own pipe looks exactly as imitated (
/proc/<pid>/fdof a grid-started game would confirm it).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).
**Not testable by hand:**line saying why and what stands in for it. Then tick it.It goes back to WIP until Tested on my own PC can be ticked;
pr readyit again then.fix(linux): a Gaming-mode start still writes longshot_log.txt (the game log follows the game, not Steam's pipe)to WIP: fix(linux): a Gaming-mode start still writes longshot_log.txt (the game log follows the game, not Steam's pipe)Merged current
main(fc4a6769) into the branch; head is22c9c69a. The only conflict was.gitignore; the unrelated.worktrees/entry is dropped, as the review asked, so the file is main's and the Gaming-mode log fix is unchanged.Checks:
tests/run_all.py --changed origin/mainis 48 passed / 9 failed / 1 skipped, and all nine also fail on cleanmainhere (checked by name:test_display_startup_failure,test_lift_cache,test_crash_dialog,test_crash_record,test_host_guest_writes,test_log_open_failure,test_mods_list,test_profiling_mode,test_slow_frames).Still WIP for the Deck Gaming-mode run: launch this build from the grid and check
logs/longshot_log.txtexists with the run's version line, while a terminal start still prints to the terminal.WIP: fix(linux): a Gaming-mode start still writes longshot_log.txt (the game log follows the game, not Steam's pipe)to fix(linux): a Gaming-mode start still writes longshot_log.txt (the game log follows the game, not Steam's pipe)