Crash reports: keep them when stderr is closed #1964

Open
imjustprism wants to merge 1 commit from upstream-pr/1966 into main
imjustprism commented 2026-11-25 01:53:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by imjustprism on 2026-11-25T01:53:21Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5483598174 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1966). Originally posted by [imjustprism](https://github.com/imjustprism) on 2026-11-25T01:53:21Z. --- 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.
DesertGamer commented 2026-11-25 03:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-25T02:15:41Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150504848 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7150504848). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-25T02:15:41Z. --- ### 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.*
AgneyaK commented 2026-11-25 03:03:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T02:41:26Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151049854 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7151049854). Originally posted by [AgneyaK](https://github.com/AgneyaK) on 2026-11-25T02:41:26Z. --- 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.
Marvisak commented 2026-11-25 09:06:17 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:24:16Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7156983077 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7156983077). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T08:24:16Z. --- <!-- 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)_
upstream-sync changed title from [PR #1966] keep crash reports when stderr is closed to [PR #1966] Crash reports: keep them when stderr is closed 2026-11-26 09:05:11 +00:00
cloph-dsp commented 2026-11-27 02:40:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T02:40:40Z.


Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2, no game data).

  • PR head 3eab67c, merge base 940d32f.
  • cargo test --locked -p victory-loader --test crash_log -- reports_reach_the_log_when_stderr_is_closed --exact --test-threads=1 --quiet -> test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out (exit 0).
  • git diff --check 940d32f HEAD -> exit 0.
  • Negative control: the new test name is absent from the merge base (git grep -c ... crates/victory-loader/tests/crash_log.rs -> no hits).

Note: only the named synthetic integration test was replayed; the full crate suite was not run. GPU/driver: N/A (CPU-only crash-log test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7208336295 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1966#issuecomment-7208336295). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T02:40:40Z. --- Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local `CARGO_TARGET_DIR`, `CARGO_BUILD_JOBS=2`, no game data). - PR head `3eab67c`, merge base `940d32f`. - `cargo test --locked -p victory-loader --test crash_log -- reports_reach_the_log_when_stderr_is_closed --exact --test-threads=1 --quiet` -> `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out` (exit 0). - `git diff --check 940d32f HEAD` -> exit 0. - Negative control: the new test name is absent from the merge base (`git grep -c ... crates/victory-loader/tests/crash_log.rs` -> no hits). Note: only the named synthetic integration test was replayed; the full crate suite was not run. GPU/driver: N/A (CPU-only crash-log test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1966:upstream-pr/1966'
git switch 'upstream-pr/1966'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1966'
git switch 'upstream-pr/1966'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1966'
git switch 'upstream-pr/1966'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1966'
git switch 'main'
git merge --squash 'upstream-pr/1966'
git switch 'main'
git merge --ff-only 'upstream-pr/1966'
git switch 'main'
git merge 'upstream-pr/1966'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1964
No description provided.