Crash log: a panic carries our Rust stack #390

Open
Kaairim wants to merge 1 commit from upstream-pr/390 into main
Kaairim commented 2026-11-24 02:52:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Kaairim on 2026-11-24T02:52:15Z.


What

The panic hook in crash.rs now appends our Rust stack to crashes.log, captured with Backtrace::force_capture() whatever RUST_BACKTRACE says.

Why

A panic in an extern "system" function aborts the process (0xc0000409, as in #167), so the crash log is all that is left of it. It had the message and the location of the panic, but not the path that led there. Release builds already have debug = "line-tables-only", so the stack names functions, files and lines.

Tested

Windows 11 (build 26300), Rust 1.98.1 (pinned toolchain), x86_64-pc-windows-msvc:

  • New test crash::tests::a_panic_logs_our_stack: runs the test binary again as a child (panic_child, the pattern of threads::tests::exit_child) with RUST_BACKTRACE removed; the child logs crashes to a temporary file and panics in an #[inline(never)] function. The log must hold the message, our stack: and that function's name. Without the fix it fails on our stack:.
  • cargo test --workspace --no-fail-fast: 266 passed, 0 failed, 4 ignored (main: 264 / 0 / 4; panic_child counts as a pass when run directly).
  • cargo clippy --workspace --all-targets: the same two warnings as main.
  • rustfmt --check on crash.rs shows the same six hunks as on main, none in the lines changed here.

Not covered: the std unwinder stops at a frame without unwind data, so a panic on a title thread shows our frames down to the thunk, not the title's callers. Adding the file's own walker (unwind + locate, as report_unhandled does) would show those; I left it out to keep this small and can follow up if wanted. Not run: the title.

Improvements by William "kaairim" Deivid (wdcore). AI-assisted: Claude Code with Claude Opus 5.5 wrote the change, the test and this description; a second Claude Opus 5.5 agent reviewed the diff.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6573527714 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/390). Originally posted by [Kaairim](https://github.com/Kaairim) on 2026-11-24T02:52:15Z. --- ## What The panic hook in `crash.rs` now appends our Rust stack to `crashes.log`, captured with `Backtrace::force_capture()` whatever `RUST_BACKTRACE` says. ## Why A panic in an `extern "system"` function aborts the process (`0xc0000409`, as in #167), so the crash log is all that is left of it. It had the message and the location of the panic, but not the path that led there. Release builds already have `debug = "line-tables-only"`, so the stack names functions, files and lines. ## Tested Windows 11 (build 26300), Rust 1.98.1 (pinned toolchain), x86_64-pc-windows-msvc: - New test `crash::tests::a_panic_logs_our_stack`: runs the test binary again as a child (`panic_child`, the pattern of `threads::tests::exit_child`) with `RUST_BACKTRACE` removed; the child logs crashes to a temporary file and panics in an `#[inline(never)]` function. The log must hold the message, `our stack:` and that function's name. Without the fix it fails on `our stack:`. - `cargo test --workspace --no-fail-fast`: 266 passed, 0 failed, 4 ignored (main: 264 / 0 / 4; `panic_child` counts as a pass when run directly). - `cargo clippy --workspace --all-targets`: the same two warnings as main. - `rustfmt --check` on `crash.rs` shows the same six hunks as on main, none in the lines changed here. Not covered: the std unwinder stops at a frame without unwind data, so a panic on a title thread shows our frames down to the thunk, not the title's callers. Adding the file's own walker (`unwind` + `locate`, as `report_unhandled` does) would show those; I left it out to keep this small and can follow up if wanted. Not run: the title. Improvements by William "kaairim" Deivid (wdcore). AI-assisted: Claude Code with Claude Opus 5.5 wrote the change, the test and this description; a second Claude Opus 5.5 agent reviewed the diff. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jeremygold02 commented 2026-11-24 06:55:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:26:37Z.


Thanks @Kaairim for adding the Rust stack to panic reports. I tested head e125477cbd6df1267ea4e5c099d13ab5e9e03dba with:

cargo test --locked -p victory-loader --lib a_panic_logs_our_stack -- --test-threads=1

Result: 1 passed, 0 failed (19 filtered out). The regression test triggers a controlled panic and verifies the captured report includes our Rust stack. I did not inspect or reproduce any game log or title run.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7122023919 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/390#issuecomment-7122023919). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-24T04:26:37Z. --- Thanks @Kaairim for adding the Rust stack to panic reports. I tested head `e125477cbd6df1267ea4e5c099d13ab5e9e03dba` with: ``` cargo test --locked -p victory-loader --lib a_panic_logs_our_stack -- --test-threads=1 ``` Result: 1 passed, 0 failed (19 filtered out). The regression test triggers a controlled panic and verifies the captured report includes our Rust stack. I did not inspect or reproduce any game log or title run.
mercuryVM commented 2026-11-24 13:01:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T12:45:57Z.

Review: APPROVED


Tested e125477 on Windows 11, RTX 5070, MSVC: cargo test -p victory-loader 22 passed, including a_panic_logs_our_stack. That test runs a child test process with RUST_BACKTRACE removed and checks that panics_here appears in the log. cargo clippy -p victory-loader --all-targets is clean.

  • Backtrace::force_capture() in the panic hook is the right call: a panic in an extern "system" function aborts, so the log is the only place the stack survives, and release builds already carry line tables.
  • The stack has only our own frames and source paths (title code has no Rust symbols), so it adds no title data to crashes.log.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6039423735 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/390#pullrequestreview-6039423735). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T12:45:57Z. **Review:** APPROVED --- Tested e125477 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-loader` 22 passed, including `a_panic_logs_our_stack`. That test runs a child test process with `RUST_BACKTRACE` removed and checks that `panics_here` appears in the log. `cargo clippy -p victory-loader --all-targets` is clean. - `Backtrace::force_capture()` in the panic hook is the right call: a panic in an `extern "system"` function aborts, so the log is the only place the stack survives, and release builds already carry line tables. - The stack has only our own frames and source paths (title code has no Rust symbols), so it adds no title data to `crashes.log`. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 02:05:49 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-loader/src/crash.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149380410 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/390#issuecomment-7149380410). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:16:27Z. --- <!-- victory-triage v1 head=e125477cbd6df1267ea4e5c099d13ab5e9e03dba verdict=needs-rebase at=2026-11-25T01:16:26Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-loader/src/crash.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
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/390:upstream-pr/390'
git switch 'upstream-pr/390'

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/390'
git switch 'upstream-pr/390'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/390'
git switch 'upstream-pr/390'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/390'
git switch 'main'
git merge --squash 'upstream-pr/390'
git switch 'main'
git merge --ff-only 'upstream-pr/390'
git switch 'main'
git merge 'upstream-pr/390'
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!390
No description provided.