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
3 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.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.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.