Skip to content

crashlog: write panics to a copperline-crash.txt report file#226

Merged
LinuxJedi merged 2 commits into
mainfrom
feature/crash-report-file
Jul 19, 2026
Merged

crashlog: write panics to a copperline-crash.txt report file#226
LinuxJedi merged 2 commits into
mainfrom
feature/crash-report-file

Conversation

@LinuxJedi

Copy link
Copy Markdown
Owner

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.rs into a new crashlog module) now also persists a crash report to copperline-crash.txt:

  • Contents: Copperline version, host OS/arch, timestamp, panicking thread, the panic message with its source location, and a backtrace captured with Backtrace::force_capture() so it works without RUST_BACKTRACE set (crash reporters cannot be asked to reproduce with it).
  • Location: next to the executable (the natural spot for the portable Windows zip), falling back to the working directory and then the system temp directory for read-only install layouts (Homebrew/AppImage/Flatpak). Terminal runs print the path chosen.
  • The first panic of a run replaces a stale report from an earlier run; later panics in the same process append. Concurrent panicking threads are serialized by a mutex.

Docs: new "Crash reports" section in docs/guide/getting-started.md and a Troubleshooting section in the Windows bundle's README.txt asking users to attach the file to bug reports.

Testing

  • 4 new unit tests in src/crashlog.rs cover the truncate-then-append lifecycle, directory fallback, the no-writable-candidate case, and report contents.
  • cargo test (1653 passed), cargo clippy --all-targets and cargo fmt --check clean.
  • Verified end to end with a scratch binary linking the lib: installed the hook, panicked, and confirmed the stderr pointer plus a well-formed copperline-crash.txt with a symbolized backtrace.

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.
Copilot AI review requested due to automatic review settings July 19, 2026 08:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.rs with crashlog::install() and introduces a new src/crashlog.rs module 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.

Comment thread src/crashlog.rs Outdated
Comment thread src/crashlog.rs
Comment thread src/crashlog.rs Outdated
Comment thread src/crashlog.rs Outdated
Comment thread src/crashlog.rs
Comment thread docs/guide/getting-started.md Outdated
Comment thread packaging/windows/README.txt Outdated
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.
@LinuxJedi
LinuxJedi merged commit a04d609 into main Jul 19, 2026
13 checks passed
@LinuxJedi
LinuxJedi deleted the feature/crash-report-file branch July 19, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants