Crash reports: keep them when stderr is closed #1966

Open
github-bot wants to merge 1 commit from github-bot/gh-1966 into main AGit
Owner

@⁠imjustprism on GitHub · 2026-11-25 01:53 UTC · original
imjustprism:fix/crash-report-broken-stderr → main · +79 −24 · 2 files · 1 commits · open

crash reports were printed with eprint!, which panics when stderr is a pipe whose reader has left (a pager, or a | select -first that stopped reading). in the exception handler that panic cannot unwind, so the process died with 0xc0000409 and the report never reached crashes.log. log_crash lost the host gpu failure text the same way. the reports are now written to stderr with the write error ignored, so the log still gets them.

the new test runs a child whose stderr is closed, raises a breakpoint and logs a gpu failure. without the change the child aborts and the log holds only the panic.

**@⁠imjustprism** on GitHub · 2026-11-25 01:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/1966) `imjustprism:fix/crash-report-broken-stderr` → `main` · +79 −24 · 2 files · 1 commits · open crash reports were printed with `eprint!`, which panics when stderr is a pipe whose reader has left (a pager, or a `| select -first` that stopped reading). in the exception handler that panic cannot unwind, so the process died with 0xc0000409 and the report never reached crashes.log. `log_crash` lost the host gpu failure text the same way. the reports are now written to stderr with the write error ignored, so the log still gets them. the new test runs a child whose stderr is closed, raises a breakpoint and logs a gpu failure. without the change the child aborts and the log holds only the panic.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:50:20 +00:00
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-25 02:15 UTC · original

VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7150504848) ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠AgneyaK on GitHub · 2026-11-25 02:41 UTC · original

Verified locally: merged 3eab67c onto main 940d32f (clean), Windows 11 26300, Rust 1.98.1 MSVC.

  • The test reproduces the bug on main. With main's crash.rs and this PR's test, reports_reach_the_log_when_stderr_is_closed fails exactly as described:
    exit code: 0xc0000409
    ... panicked at library\std\src\io\stdio.rs:1166:9: failed printing to stderr: The pipe is being closed. (os error 232)
    ... panicked at library\core\src\panicking.rs:225:5: panic in a function that cannot unwind
    
    With the PR it passes.
  • Stable: cargo test -p victory-loader --locked 5 runs, all green (34 unit + the crash_log tests). cargo clippy -p victory-loader --all-targets --locked -- -D warnings: clean.
  • Checked the other stderr writers on the crash path:
    • host::fail logs through tracing before calling the report. tracing-subscriber 0.3.23's fmt layer has log_internal_errors: false by default, so a broken stderr is ignored there, not printed with eprintln!. That path is fine with this PR.
    • Not in scope, but the same pattern: victory-loader/src/stacks.rs (VICTORY_STACKS) prints with eprintln! (lines 99, 113, 119), so a stack dump with a closed stderr would panic that thread too. It's a diagnostics switch, so it's lower stakes.

Not tested: the title with a closed stderr.

AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; the results are from the runs described.

**@⁠AgneyaK** on GitHub · 2026-11-25 02:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7151049854) Verified locally: merged `3eab67c` onto `main` `940d32f` (clean), Windows 11 26300, Rust 1.98.1 MSVC. - **The test reproduces the bug on `main`.** With `main`'s `crash.rs` and this PR's test, `reports_reach_the_log_when_stderr_is_closed` fails exactly as described: ``` exit code: 0xc0000409 ... panicked at library\std\src\io\stdio.rs:1166:9: failed printing to stderr: The pipe is being closed. (os error 232) ... panicked at library\core\src\panicking.rs:225:5: panic in a function that cannot unwind ``` With the PR it passes. - **Stable:** `cargo test -p victory-loader --locked` 5 runs, all green (34 unit + the `crash_log` tests). `cargo clippy -p victory-loader --all-targets --locked -- -D warnings`: clean. - **Checked the other stderr writers on the crash path:** - `host::fail` logs through `tracing` before calling the report. `tracing-subscriber` 0.3.23's fmt layer has `log_internal_errors: false` by default, so a broken stderr is ignored there, not printed with `eprintln!`. That path is fine with this PR. - Not in scope, but the same pattern: `victory-loader/src/stacks.rs` (`VICTORY_STACKS`) prints with `eprintln!` (lines 99, 113, 119), so a stack dump with a closed stderr would panic that thread too. It's a diagnostics switch, so it's lower stakes. Not tested: the title with a closed stderr. AI use: Claude Code (Claude Opus 5.5) ran these checks and wrote this; the results are from the runs described.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 08:24 UTC · original · edited 2026-11-25 08:27 UTC

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. The fix reads as correct. It is marked this way only because the new test starts a child process (see below), and changes that spawn processes are left to the maintainer.

crates/victory-loader/src/crash.rs now writes crash reports with print_to_stderr, which ignores the write error, instead of eprint!/eprintln!. This covers log_crash and the lines in report (including the save_on_crash note). A closed stderr no longer panics inside the exception handler, which used to abort with 0xc0000409 before the report was appended to crashes.log. After the change there are no other eprint! calls in the crash path, and the text written to the log is unchanged.

The new test reports_reach_the_log_when_stderr_is_closed re-runs its own test binary as a child process, the same way first_chance_breakpoint_logging on main already does; nothing external is started. A contributor's comment confirms that the test fails on main with the abort and passes with the change.

CI (check): passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 08:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7156983077) · edited 2026-11-25 08:27 UTC <!-- victory-triage v1 head=3eab67c54b0a44ff86c16b4a0c6ec7e5361e417b verdict=needs-work at=2026-11-25T08:27:00Z --> Automated triage for the maintainers. **Needs work: needs the maintainer's decision.** The fix reads as correct. It is marked this way only because the new test starts a child process (see below), and changes that spawn processes are left to the maintainer. `crates/victory-loader/src/crash.rs` now writes crash reports with `print_to_stderr`, which ignores the write error, instead of `eprint!`/`eprintln!`. This covers `log_crash` and the lines in `report` (including the `save_on_crash` note). A closed stderr no longer panics inside the exception handler, which used to abort with 0xc0000409 before the report was appended to `crashes.log`. After the change there are no other `eprint!` calls in the crash path, and the text written to the log is unchanged. The new test `reports_reach_the_log_when_stderr_is_closed` re-runs its own test binary as a child process, the same way `first_chance_breakpoint_logging` on `main` already does; nothing external is started. A contributor's comment confirms that the test fails on `main` with the abort and passes with the change. CI (`check`): passing. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot changed title from keep crash reports when stderr is closed to Crash reports: keep them when stderr is closed 2026-11-26 09:03:13 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1966/head:github-bot/gh-1966'
git switch 'github-bot/gh-1966'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1966'
git switch 'github-bot/gh-1966'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1966'
git switch 'github-bot/gh-1966'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1966'
git switch 'main'
git merge --squash 'github-bot/gh-1966'
git switch 'main'
git merge --ff-only 'github-bot/gh-1966'
git switch 'main'
git merge 'github-bot/gh-1966'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
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
github/Marvisak--VIctory!1966
No description provided.