fix(host): the saved logs leave out the player's user name #1459

Merged
HumanBean merged 2 commits from dyst/Longshot:fix/log-redact into main 2026-11-17 20:29:44 +00:00
Member

Type: fix · Risk: medium · Tested on: Windows 11 (game-free checks only) · Needs: Windows and Linux, any GPU, an in-game run

Why

Players send longshot_log.txt around all the time: in issues, on Discord, in chats. Until now only the copies the Bug report
and the crash window make left the home folder and the user's name out. The log itself kept C:\Users\<name>\... and
/home/<name>/... wherever a line had a path, and so did the builder's --log file. Now every log the game and the
builder save leaves the user name out as it is saved. The rest of each path stays, so a helper still sees where
things are.

For #1093 (Windows user names in generated files; this covers the logs). See #1264 (the crash report's own redaction).

What changed

The saved logs use the rule the Bug report already used, with one implementation instead of two: the home folder, as a
whole, becomes ~ (%USERPROFILE% on Windows), and the user's name becomes <user> wherever it is a folder in a path.
The game's own lines are redacted as they are written. Lines other code prints straight to stderr are redacted in the
file once the run has ended. The builder's --log file gets the same rule in Python.

  • One rule: gpu/vk/compat/longshot_redact.h longshot_redact_line, a C header the C++ renderer also includes.
    hos_crash_redact_line (host/hos_crash_dialog.h) and the Bug report's redact() (gpu/vk/vk_bug_report.cpp) now call
    it. Their output is unchanged: the new test checks it against main's redact() on every case.
  • The game's lines: hos_vlog and hos_fatal (host/hos_thread.c) redact each line before the control bridge, the
    log queue or stderr get it, through hos_log_redact (host/log_redact.c). It takes out this PC's home folder and user
    name, read once from the environment. On Windows it also takes out:
    • the home folder's short 8.3 name (C:\Users\JOHNSM~1, which TEMP paths often use);
    • the home folder's own name when it differs from USERNAME (john.PC).
      It allocates nothing and takes no lock after the first call. The renderer's logf goes through the same path.
  • Lines written straight to stderr (the Vulkan loader, SDL, the host's own early fprintfs): hos_log_redact_file
    rewrites the log in place once its run has ended. It locks the file (LockFileEx / flock) so two rewrites never
    overlap, and leaves the file alone when it's already clean. It runs in two places:
    • the crash watch (host/hos_crash_dialog.c helper): right after the game is gone, before it reads the log. It only
      touches its own run's log, checked by the run_id: line, which may have been rotated to .1 by then;
    • the next start (host/hos_main.c): on the log it has just rotated to longshot_log.1.txt. This covers runs that had
      no crash watch (--prepare-shaders, HOS_HEADLESS, HOS_CRASH_WATCH=0).
  • The builder: make_game.py --log FILE writes through nx2/log_redact.py RedactedLines, the same rule in Python. It
    writes whole lines only, so a path split across two writes is still caught. The console, which a launcher reads, stays
    as it was.
  • Docs: the README's If something goes wrong and docs/crash-report-window.md.

What the game and the builder save, and what this PR does with each

File Can it hold a path or user name? Now
logs/longshot_log.txt and .1–.4.txt Yes: the game folder, saves, caches, __GL_SHADER_DISK_CACHE_PATH, the Vulkan loader's layer manifests The game's lines are redacted as written. Third-party stderr lines are redacted at the end of the run, or at the next start
make_game.py --log file Yes: the dump, work and game folders, compiler output Redacted as written
logs/longshot_frames.csv, the frame log (RX_VK_FRAME_LOG) No: numbers only Unchanged
logs/profile-*/ (HOS_PROFILE=1) process.json could; the rest is numbers, thread names and module+offset Unchanged: process.json already writes <game folder>/ or <a path>
Crash and unclean-end records (bug-reports/pending/) Could Unchanged: already redacted (hos_report_privacy)
The crash window's report, and the Bug report's bug-reports/<date>/ Could Unchanged: already redacted (their copies of the logs are now no-ops)
cache/longshot_driver_faults.txt No: vendor, driver and key in hex Unchanged
logs/longshot_startup.log — Nothing writes it any more; it's only moved from older folders
The game started from a terminal Yes Unchanged: it prints to the terminal, not a file, and the game's own lines are redacted there too

Measurements

No measurement yet, because the game hasn't been built or run on this PC. The cost per line is a scan of a line of at most
2,200 bytes for up to four short strings, done on the thread that logs, against 30–90 lines a second in play. Frame time
must still be compared in game (Must be tested).

Flags and settings

None.

Testing

Tested: game-free, on Windows 11 with GCC 16.1 (WinLibs).

  • tests/test_log_redact.py (new) passes. It covers:
    • the rule in C and in Python, against the same 15 cases: names with spaces, an apostrophe and non-ASCII letters;
      another drive's \Users\<name>; OneDrive under the home folder; /home, /media, /run/media and /var/home; a
      name that is also a word of the line (kept); relative paths (kept);
    • redacting again changes nothing;
    • the Bug report's C++ redact() gives the same output. main's redact() gives the same output for every case too;
    • hos_log_redact from the environment: a profile folder named apart from USERNAME, and a real 8.3 short name on
      this drive;
    • hos_log_redact_file: another run's log is left alone; this run's is rewritten, both shorter and longer; an
      already-clean file isn't written; a missing file;
    • RedactedLines with a line split across writes, and the source checks on every caller.
  • tests/test_build_log.py passes: it now compares the log with the console's text as the file holds it, and checks
    the console keeps the path while the file doesn't.
  • Updated checks pass: test_log_levels.py (a line through hos_vlog comes out redacted), test_crash_record.py (the
    order in hos_vlog and hos_fatal), test_bug_report.py, test_log_batch.py and test_report_privacy.py.
    test_crash_dialog.py's behaviour build links host/log_redact.c.
  • python -I -B tests/run_all.py --changed origin/main: 105 passed, 16 failed, 14 skipped. The 16 also fail on main
    @ 4dc2a6a5 on this PC, run the same way: test_bug_report_defaults, test_crash_dialog (Windows code-page cases, see
    #1012), test_display_startup_failure, test_failed_compile_keeps_objects, test_hud_layout_row, test_invalidate_vcore,
    test_job_queue, test_missing_nup, test_oot_state_tap, test_perf_report, test_prepare_stall, test_profiling_mode,
    test_slow_frames, test_tested_configurations, test_vcore_escape and test_walk_key. test_build_log failed
    until its update.
  • After rebasing onto main @ c14641a6, the checks named above ran again with the same results.

Not tested:

  • The game. It hasn't been built (this PC has no llvm-mingw, and host/hos_thread.c and hos_main.c need the lift's
    generated a64_suyu.h) and hasn't been run.
  • The Linux paths of host/log_redact.c (flock, pread/pwrite). They haven't been compiled: there's no Linux here.
  • host/hos_crash_dialog.c compiles on Windows (-fsyntax-only -Wall -Wextra, clean). Its Linux behaviour test
    wasn't run.

Must be tested:

  • Windows, any GPU, by hand: play to the title screen, then quit. logs/longshot_log.txt must show %USERPROFILE%
    where the game folder or saves are under your profile, and no C:\Users\<you>. Search the file for your user name.
  • Linux, any GPU (Test Farm: @Beanstalk linux, start to the title and quit, then check logs/longshot_log.txt for the user name): the same check, expecting ~ and <user> and no /home/<you>.
  • Steam Deck (Test Farm: @Beanstalk steamdeck): a game folder on the SD card (/run/media/<user>/...) shows
    /run/media/<user>/ in the log.
  • Windows and Linux, by hand, a crash (HOS_TEST_CRASH, or kill the game from Task Manager or with kill -SEGV):
    • the crash window still shows the log's last lines and its stage;
    • longshot_log.txt afterwards has no user name, third-party lines included;
    • starting again leaves longshot_log.1.txt the same.
  • Windows, Insert menu → Restart now: the new run's longshot_log.txt starts fresh, and .1 is the previous run's
    log, clean.
  • Any PC, by hand, frame time: compare this PR with main in one scene (the FPS counter's Dev level, or
    RX_VK_FRAME_TRACE=1), 2 runs each. Expect no difference.
  • Building: make_game.py --nup ... --out ... --log build.log gives a build.log with ~ or %USERPROFILE% for the
    work and game folders, while the console shows the real paths.

Risks

What could break:

  • If the end-of-run rewrite were interrupted (the PC loses power during the few milliseconds it writes), that log could be
    left cut short.
  • A crash watch that reads the rotated log while the next start is rewriting it could show a partly redacted line in its
    window. The rewrite is locked against the other rewrite, not against readers.
  • A user name of one or two letters is taken out wherever it is a whole folder name (D:\x\al\y becomes D:\x\<user>\y),
    as the Bug report already did.

Turning it off: revert the commits.

Compatibility:

  • Logs say ~ / %USERPROFILE% and <user> instead of the real paths.
  • Scripts that read paths back from a log need to expand them. nx2/pipeline_share.py reads the log for the GPU and the
    version, not paths, so it's unaffected.
  • Nothing else changes: saves, options, caches and the vk ABI are untouched.

Issues

See #1093
See #1264

Checklist

Everyone

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Not yet: not built here (see Not tested).
  • Docs updated.
**Type:** fix · **Risk:** medium · **Tested on:** Windows 11 (game-free checks only) · **Needs:** Windows and Linux, any GPU, an in-game run ## Why Players send `longshot_log.txt` around all the time: in issues, on Discord, in chats. Until now only the copies the Bug report and the crash window make left the home folder and the user's name out. The log itself kept `C:\Users\<name>\...` and `/home/<name>/...` wherever a line had a path, and so did the builder's `--log` file. Now every log the game and the builder save leaves the user name out as it is saved. The rest of each path stays, so a helper still sees where things are. For #1093 (Windows user names in generated files; this covers the logs). See #1264 (the crash report's own redaction). ## What changed The saved logs use the rule the Bug report already used, with one implementation instead of two: the home folder, as a whole, becomes `~` (`%USERPROFILE%` on Windows), and the user's name becomes `<user>` wherever it is a folder in a path. The game's own lines are redacted as they are written. Lines other code prints straight to stderr are redacted in the file once the run has ended. The builder's `--log` file gets the same rule in Python. - **One rule:** `gpu/vk/compat/longshot_redact.h` `longshot_redact_line`, a C header the C++ renderer also includes. `hos_crash_redact_line` (`host/hos_crash_dialog.h`) and the Bug report's `redact()` (`gpu/vk/vk_bug_report.cpp`) now call it. Their output is unchanged: the new test checks it against `main`'s `redact()` on every case. - **The game's lines:** `hos_vlog` and `hos_fatal` (`host/hos_thread.c`) redact each line before the control bridge, the log queue or stderr get it, through `hos_log_redact` (`host/log_redact.c`). It takes out this PC's home folder and user name, read once from the environment. On Windows it also takes out: - the home folder's short 8.3 name (`C:\Users\JOHNSM~1`, which TEMP paths often use); - the home folder's own name when it differs from `USERNAME` (`john.PC`). It allocates nothing and takes no lock after the first call. The renderer's `logf` goes through the same path. - **Lines written straight to stderr** (the Vulkan loader, SDL, the host's own early `fprintf`s): `hos_log_redact_file` rewrites the log in place once its run has ended. It locks the file (`LockFileEx` / `flock`) so two rewrites never overlap, and leaves the file alone when it's already clean. It runs in two places: - the crash watch (`host/hos_crash_dialog.c` `helper`): right after the game is gone, before it reads the log. It only touches its own run's log, checked by the `run_id:` line, which may have been rotated to `.1` by then; - the next start (`host/hos_main.c`): on the log it has just rotated to `longshot_log.1.txt`. This covers runs that had no crash watch (`--prepare-shaders`, `HOS_HEADLESS`, `HOS_CRASH_WATCH=0`). - **The builder:** `make_game.py --log FILE` writes through `nx2/log_redact.py` `RedactedLines`, the same rule in Python. It writes whole lines only, so a path split across two writes is still caught. The console, which a launcher reads, stays as it was. - **Docs:** the README's *If something goes wrong* and `docs/crash-report-window.md`. ### What the game and the builder save, and what this PR does with each | File | Can it hold a path or user name? | Now | |---|---|---| | `logs/longshot_log.txt` and `.1`–`.4.txt` | Yes: the game folder, saves, caches, `__GL_SHADER_DISK_CACHE_PATH`, the Vulkan loader's layer manifests | The game's lines are redacted as written. Third-party stderr lines are redacted at the end of the run, or at the next start | | `make_game.py --log` file | Yes: the dump, work and game folders, compiler output | Redacted as written | | `logs/longshot_frames.csv`, the frame log (`RX_VK_FRAME_LOG`) | No: numbers only | Unchanged | | `logs/profile-*/` (`HOS_PROFILE=1`) | `process.json` could; the rest is numbers, thread names and module+offset | Unchanged: `process.json` already writes `<game folder>/` or `<a path>` | | Crash and unclean-end records (`bug-reports/pending/`) | Could | Unchanged: already redacted (`hos_report_privacy`) | | The crash window's report, and the Bug report's `bug-reports/<date>/` | Could | Unchanged: already redacted (their copies of the logs are now no-ops) | | `cache/longshot_driver_faults.txt` | No: vendor, driver and key in hex | Unchanged | | `logs/longshot_startup.log` | — | Nothing writes it any more; it's only moved from older folders | | The game started from a terminal | Yes | Unchanged: it prints to the terminal, not a file, and the game's own lines are redacted there too | ## Measurements No measurement yet, because the game hasn't been built or run on this PC. The cost per line is a scan of a line of at most 2,200 bytes for up to four short strings, done on the thread that logs, against 30–90 lines a second in play. Frame time must still be compared in game (Must be tested). ### Flags and settings None. ## Testing **Tested:** game-free, on Windows 11 with GCC 16.1 (WinLibs). - `tests/test_log_redact.py` (new) passes. It covers: - the rule in C and in Python, against the same 15 cases: names with spaces, an apostrophe and non-ASCII letters; another drive's `\Users\<name>`; OneDrive under the home folder; `/home`, `/media`, `/run/media` and `/var/home`; a name that is also a word of the line (kept); relative paths (kept); - redacting again changes nothing; - the Bug report's C++ `redact()` gives the same output. `main`'s `redact()` gives the same output for every case too; - `hos_log_redact` from the environment: a profile folder named apart from `USERNAME`, and a real 8.3 short name on this drive; - `hos_log_redact_file`: another run's log is left alone; this run's is rewritten, both shorter and longer; an already-clean file isn't written; a missing file; - `RedactedLines` with a line split across writes, and the source checks on every caller. - `tests/test_build_log.py` passes: it now compares the log with the console's text as the file holds it, and checks the console keeps the path while the file doesn't. - Updated checks pass: `test_log_levels.py` (a line through `hos_vlog` comes out redacted), `test_crash_record.py` (the order in `hos_vlog` and `hos_fatal`), `test_bug_report.py`, `test_log_batch.py` and `test_report_privacy.py`. `test_crash_dialog.py`'s behaviour build links `host/log_redact.c`. - `python -I -B tests/run_all.py --changed origin/main`: 105 passed, 16 failed, 14 skipped. The 16 also fail on `main` @ 4dc2a6a5 on this PC, run the same way: `test_bug_report_defaults`, `test_crash_dialog` (Windows code-page cases, see #1012), `test_display_startup_failure`, `test_failed_compile_keeps_objects`, `test_hud_layout_row`, `test_invalidate_vcore`, `test_job_queue`, `test_missing_nup`, `test_oot_state_tap`, `test_perf_report`, `test_prepare_stall`, `test_profiling_mode`, `test_slow_frames`, `test_tested_configurations`, `test_vcore_escape` and `test_walk_key`. `test_build_log` failed until its update. - After rebasing onto `main` @ c14641a6, the checks named above ran again with the same results. **Not tested:** - The game. It hasn't been built (this PC has no llvm-mingw, and `host/hos_thread.c` and `hos_main.c` need the lift's generated `a64_suyu.h`) and hasn't been run. - The Linux paths of `host/log_redact.c` (`flock`, `pread`/`pwrite`). They haven't been compiled: there's no Linux here. - `host/hos_crash_dialog.c` compiles on Windows (`-fsyntax-only -Wall -Wextra`, clean). Its Linux behaviour test wasn't run. **Must be tested:** - **Windows, any GPU, by hand:** play to the title screen, then quit. `logs/longshot_log.txt` must show `%USERPROFILE%` where the game folder or saves are under your profile, and no `C:\Users\<you>`. Search the file for your user name. - **Linux, any GPU** (Test Farm: `@Beanstalk linux, start to the title and quit, then check logs/longshot_log.txt for the user name`): the same check, expecting `~` and `<user>` and no `/home/<you>`. - **Steam Deck** (Test Farm: `@Beanstalk steamdeck`): a game folder on the SD card (`/run/media/<user>/...`) shows `/run/media/<user>/` in the log. - **Windows and Linux, by hand, a crash** (`HOS_TEST_CRASH`, or kill the game from Task Manager or with `kill -SEGV`): - the crash window still shows the log's last lines and its stage; - `longshot_log.txt` afterwards has no user name, third-party lines included; - starting again leaves `longshot_log.1.txt` the same. - **Windows, Insert menu → Restart now:** the new run's `longshot_log.txt` starts fresh, and `.1` is the previous run's log, clean. - **Any PC, by hand, frame time:** compare this PR with `main` in one scene (the FPS counter's Dev level, or `RX_VK_FRAME_TRACE=1`), 2 runs each. Expect no difference. - **Building:** `make_game.py --nup ... --out ... --log build.log` gives a `build.log` with `~` or `%USERPROFILE%` for the work and game folders, while the console shows the real paths. ## Risks **What could break:** - If the end-of-run rewrite were interrupted (the PC loses power during the few milliseconds it writes), that log could be left cut short. - A crash watch that reads the rotated log while the next start is rewriting it could show a partly redacted line in its window. The rewrite is locked against the other rewrite, not against readers. - A user name of one or two letters is taken out wherever it is a whole folder name (`D:\x\al\y` becomes `D:\x\<user>\y`), as the Bug report already did. **Turning it off:** revert the commits. **Compatibility:** - Logs say `~` / `%USERPROFILE%` and `<user>` instead of the real paths. - Scripts that read paths back from a log need to expand them. `nx2/pipeline_share.py` reads the log for the GPU and the version, not paths, so it's unaffected. - Nothing else changes: saves, options, caches and the vk ABI are untouched. ## Issues See #1093 See #1264 ## Checklist ### Everyone - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Not yet: not built here (see Not tested). - [x] Docs updated.
Players attach longshot_log.txt to issues and pass it around in chats, and
until now only the Bug report's and the crash window's copies left the home
folder and the user's name out: the log itself kept C:\Users\<name>\... and
/home/<name>/... wherever a line had a path.

- One rule for the log, the crash window and the Insert menu's Bug report,
  gpu/vk/compat/longshot_redact.h (the host's hos_crash_redact_line and the
  renderer's redact() now call it; the output is the same as before).
- Each line the game and the renderer log is redacted before it is written
  (hos_vlog, hos_fatal), from this PC's home folder and name, also the home
  folder's short 8.3 name and its own name when USERNAME differs
  (host/log_redact.c).
- What other code wrote to stderr itself (the Vulkan loader, SDL) is
  redacted in the file once the run has ended: by the crash watch, for its
  own run only and locked, and at the next start on the rotated
  longshot_log.1.txt for a run that had none.

For #1093.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(build): the builder's --log file leaves out the player's user name
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 8s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 18s
Third-party parts / As their notes say (pull_request) Successful in 23s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Failing after 9s
6e795db40b
make_game.py --log saved the build's output as it was, with the home folder
in every path of the work folder, the dump and the game folder. The file is
now written through nx2/log_redact.py, the game's rule in Python (the same
output for the same line), whole lines at a time; the console, which a
launcher reads, stays as it is.

tests/test_log_redact.py checks the rule in C and in Python against the same
cases, the Bug report's output, the game's line, the file sweep and the
callers; tests/test_build_log.py compares the log with the console's text
as the file holds it.

For #1093.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean changed title from WIP: fix(host): the saved logs leave out the player's user name to fix(host): the saved logs leave out the player's user name 2026-11-17 20:29:07 +00:00
HumanBean deleted branch fix/log-redact 2026-11-17 20:29:46 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1459
No description provided.