crashlog: write panics to a copperline-crash.txt report file#226
Merged
Conversation
A panic prints to stderr, but the common double-click launch never shows it: on Windows the console window closes with the process (issue #225 is such a silent-exit report), and desktop launchers discard stderr on every platform. The panic hook now also writes the panic message and a backtrace (captured independently of RUST_BACKTRACE) to copperline-crash.txt next to the executable, falling back to the working directory and then the system temporary directory for read-only install layouts. The first panic of a run replaces a stale report from an earlier run; later panics in the same process append.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a dedicated crash logging facility so panics produce a persistent, user-attachable report file (copperline-crash.txt), improving diagnosability for double-click/launcher runs where stderr is lost (notably Windows).
Changes:
- Replaces the inline panic hook in
main.rswithcrashlog::install()and introduces a newsrc/crashlog.rsmodule to write a structured crash report (including forced backtrace capture). - Exposes the new crashlog module from the library crate.
- Documents crash report behavior for users (Windows portable bundle README + Getting Started guide).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.rs | Switches from an inline panic hook to the new crashlog installer. |
| src/lib.rs | Exports the new crashlog module. |
| src/crashlog.rs | Implements panic hook + report formatting, write-path selection, and unit tests. |
| packaging/windows/README.txt | Adds troubleshooting guidance directing users to attach copperline-crash.txt. |
| docs/guide/getting-started.md | Documents crash report generation and where the file is written. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Review follow-up: the report state tracked only whether a report had been written, so a second panic in the same process re-walked the candidate directories and could append to a different, stale file if the working directory had changed in between. Track the chosen path instead: later panics append to the file the first one picked, falling back to a fresh pick only if that location has vanished. Align the guide and Windows README wording with the replace-then-append behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Silent-exit reports like #225 happen because a panic only prints to stderr, which nobody sees on the common double-click launch: on Windows the console window closes with the process, and desktop launchers discard stderr on every platform.
The panic hook (moved from
main.rsinto a newcrashlogmodule) now also persists a crash report tocopperline-crash.txt:Backtrace::force_capture()so it works withoutRUST_BACKTRACEset (crash reporters cannot be asked to reproduce with it).Docs: new "Crash reports" section in
docs/guide/getting-started.mdand a Troubleshooting section in the Windows bundle'sREADME.txtasking users to attach the file to bug reports.Testing
src/crashlog.rscover the truncate-then-append lifecycle, directory fallback, the no-writable-candidate case, and report contents.cargo test(1653 passed),cargo clippy --all-targetsandcargo fmt --checkclean.copperline-crash.txtwith a symbolized backtrace.